Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

kschrab
Copy link
Contributor

@kschrab kschrab commented Jan 15, 2025

Description

  • 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

Issue(s) related to this PR

  • Resolves issue # / internal issue

Affected parts of the online documentation

Changes in the documentation required?

Definition of Done

Prerequisites

  • You have read CONTRIBUTING.md carefully.
  • You have signed the Contributor License Agreement.
  • Your GitHub user id is linked with your Eclipse Account.

Required

  • The title of this merge request follows the scheme type(scope): description (in the style of Conventional Commits)
  • You have assigned a suitable label to this pull request (e.g., enhancement, or bugfix)
  • origin/main has been merged into your Fork.
  • Coding guidelines have been followed (see CONTRIBUTING.md).
  • All checks on GitHub pass.
  • All tests on Jenkins pass.

Requested (can be enforced by maintainers)

  • New functionality is covered by unit tests or integration tests. Code coverage must not decrease.
  • If a bug has been fixed, a new unit test has been written (beforehand) to prove misbehavior
  • There are no new SpotBugs warnings.

Special notes to reviewer

@kschrab kschrab force-pushed the 974-create-agent-unit branch from cc7f6c1 to 671ffc8 Compare January 15, 2025 14:41
* 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
@kschrab kschrab force-pushed the 974-create-agent-unit branch from 671ffc8 to a4ea233 Compare January 16, 2025 16:39
@kschrab kschrab requested a review from schwepmo January 16, 2025 16:40
@kschrab kschrab marked this pull request as ready for review January 20, 2025 09:58

private static final long serialVersionUID = 1L;

private final double walkingSpeed;
Copy link
Contributor

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.",
Copy link
Contributor

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.
Copy link
Contributor

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.

Suggested change
* 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) {
Copy link
Contributor

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);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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() {
Copy link
Contributor

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?

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@kschrab kschrab requested a review from schwepmo January 24, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants