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

Assign routes with travel times from events #1131

Open
Janekdererste opened this issue Jun 10, 2024 · 1 comment
Open

Assign routes with travel times from events #1131

Janekdererste opened this issue Jun 10, 2024 · 1 comment

Comments

@Janekdererste
Copy link
Member

I have an output population to which I want to add new agents before the next run. It is important to me that all agents have fully specified routes before I start the next simulation. The routes should be based on the travel times of my last iteration. So far, I'm using PrepareForSimImpl to assign routes like so:

        var injector = Injector.createMinimalMatsimInjector(scenario.getConfig(), scenario);
        var prepareForSim = injector.getInstance(PrepareForSim.class);
        prepareForSim.run();

However, prepareForSim.run() assigns routes based on the empty network. I would like to extend my example so that the Router has travel times from the last iteration of my previous simulation run. E.g., I would like to parse the events file to update travel times in the router and then execute prepareForSim.run() something like the following:

        var injector = Injector.createMinimalMatsimInjector(scenario.getConfig(), scenario);
        var manager = injector.getInstance(EventsManager.class);
        EventsUtils.readEvents(manager, "/path/to/events.xml");

        // here the travel time listener should have updated travel times according to events
        var prepareForSim = injector.getInstance(PrepareForSim.class);
        prepareForSim.run();

Unfortunately, I can't really see how I am supposed to combine all the moving parts.

@Janekdererste
Copy link
Member Author

Ok, after stepping through the code I suspect that this might just work?

When creating the minimal injector, everything is set up, including the TravelTimeCalculator which is the events handler that keeps track of travel times. Now, the question is, whether the AStarLandmarks router, which takes TraveTime as constructor argument works on live TravelTimes provided by TravelTimeCalculator which is bound as a Provider<TravelTime> in the injector. It doesn't really look like that because there is a preprocessing call in the constructor.

Maybe @mrieser can help here?

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

No branches or pull requests

1 participant