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

Handle mode restriction correctly #3348

Merged
merged 21 commits into from
Aug 1, 2024
Merged

Handle mode restriction correctly #3348

merged 21 commits into from
Aug 1, 2024

Conversation

paulheinr
Copy link
Contributor

@paulheinr paulheinr commented Jun 28, 2024

If you restrict modes on links, there are in general two problems:

  1. The network can then have local dead ends, i.e. the network is not connected any more for the mode.
  2. The initial plans may have routes that use the restricted links, thus agents still use the links.

Both should be tackled with this PR. Therefore, several changes are needed.

New Config Parameter

In the Routing Config, there is the parameter networkRouteConsistencyCheck. If used with abortOnInconsistency, in NetworkRoutingProvider the network is checked against problem (1) and in PersonPrepareForSim the routes of the agents are checked against problem (2).

New Utils

For (1), there is now the class NetworkModeRestriction, which applies mode restriction and cleans the network. There is a corresponding function in NetworkUtils

For (2), there is now the class PersonRouteCheck, which deletes routes, if they use links which do not allow the mode any more. There is a corresponding function in PopulationUtils.

To discuss:

  • The default value of the config is abortOnInconsistency. This is quite restrictive, but helpful. Unfortunately, lots of tests are broken because of that :-( -> corrected all tests in the contribs. I will continue with the core, if this approach is accepted.
  • Check the result of ModeRestrictionTest against whole events file and not against first leg. Need to comment the result very well then.

@paulheinr
Copy link
Contributor Author

@kainagel @rakow what do you think about this approach?

* @param network the network
* @param modesToRemoveByLinkId map of modes that should be removed from the links
*/
public static void restrictModesAndCleanNetwork(Network network, Map<Id<Link>, Set<String>> modesToRemoveByLinkId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Using a lambda Function<Id, Set here is probably a lot more flexible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good idea!

@paulheinr paulheinr enabled auto-merge August 1, 2024 13:54
@paulheinr paulheinr merged commit ad2da0c into master Aug 1, 2024
49 checks passed
@paulheinr paulheinr deleted the mode-restriction branch August 1, 2024 14:15
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