-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(application): introduce agent unit and agent operating system #457
base: main
Are you sure you want to change the base?
Conversation
cc7f6c1
to
671ffc8
Compare
* spawning of agents via mapping_config.json * creating agent units in mosaic-application * provide AgentOperatingSystem with access to public transport routing and other really basic API * still no functionality, as the core Agent-Simulator is still missing
671ffc8
to
a4ea233
Compare
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private final double walkingSpeed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment here or probably better at getter including the unit the walking speed is handled in.
"items": { "type": "string" } | ||
}, | ||
"walkingSpeed": { | ||
"description": "Speed which is used for walking, in m/s.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least the walking speed unit is here :)
public GeoPoint destination; | ||
|
||
/** | ||
* Walking speed of this agent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be ultra verbose.
* Walking speed of this agent. | |
* Walking speed of this agent. [m/s] |
public void fillInPrototype(CPrototype prototypeConfiguration) { | ||
super.fillInPrototype(prototypeConfiguration); | ||
|
||
if (prototypeConfiguration != null && prototypeConfiguration.maxSpeed != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check here if the walkingSpeed
has been set by the CAgent
beforehand?
In the VehicleFlowGenerator
we do maxSpeed = defaultIfNull(maxSpeed, prototypeConfiguration.maxSpeed);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
...cation/src/main/java/org/eclipse/mosaic/fed/application/app/api/os/AgentOperatingSystem.java
Show resolved
Hide resolved
public PtRoutingResponse calculateRoute(long requestTime, GeoPoint origin, GeoPoint destination, PtRoutingParameters routingParameters) { | ||
PtRoutingRequest routingRequest = new PtRoutingRequest(requestTime, origin, destination, routingParameters); | ||
if (routingParameters.getWalkingSpeedMps() == null) { | ||
routingParameters.walkingSpeedMps(defaultWalkingSpeed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PtRoutingParameters
already has a default value for the walking speed, do we need it here again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not anymore. Since every agent can be defined with its own walking speed in the mapping_config, we should use that value instead. Only if it's re-defined by the user with custom routing parameters, than we use that what the user/app specifies, otherwise the value from mapping.
/** | ||
* Returns the individual legs of this multi-modal route. | ||
*/ | ||
public List<Leg> getLegs() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a multi-modal or a pt route? Or is the comment referring to different modes of public transport?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that is from before refactoring. Will change that.
ghRequest.setWalkSpeedKmH(SpeedUtils.ms2kmh(request.getRoutingParameters().getWalkingSpeedMps())); | ||
|
||
if (request.getRoutingParameters().getWalkingSpeedMps() == null) { | ||
ghRequest.setWalkSpeedKmH(5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a magic number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will throw an exception if it is not set, since with the current code it will be never null here.
@@ -136,7 +136,12 @@ public PtRoutingResponse findPtRoute(PtRoutingRequest request) { | |||
); | |||
// ghRequest.setBlockedRouteTypes(request.getRoutingParameters().excludedPtModes);//FIXME generalize this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be fair, currently we don't need anything of this 🫣 But yes, I will delete that and we will see once we actually use this if we would need to exclude certain public transport modes.
@@ -136,7 +136,12 @@ public PtRoutingResponse findPtRoute(PtRoutingRequest request) { | |||
); | |||
// ghRequest.setBlockedRouteTypes(request.getRoutingParameters().excludedPtModes);//FIXME generalize this | |||
ghRequest.setEarliestDepartureTime(departureTime); | |||
ghRequest.setWalkSpeedKmH(SpeedUtils.ms2kmh(request.getRoutingParameters().getWalkingSpeedMps())); | |||
|
|||
if (request.getRoutingParameters().getWalkingSpeedMps() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be easier to initialize the walking speed in the PtRoutingParameters
with a default value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For correctness, we need to use the speed of the mapping config as default. That's not possible by defining it in PtRoutingParameters.
* unified naming of Pt vs PublicTransport * moved `vehicle.PublicTransportData` to `pt.PtVehicleData`. * added missing javadoc * fixed walking speed configuration in mapping
Description
Issue(s) related to this PR
Affected parts of the online documentation
Changes in the documentation required?
Definition of Done
Prerequisites
Required
type(scope): description
(in the style of Conventional Commits)enhancement
, orbugfix
)origin/main
has been merged into your Fork.Requested (can be enforced by maintainers)
Special notes to reviewer