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(drt): add/remove vehicles dynamically during qsim #3104

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

sebhoerl
Copy link
Contributor

@sebhoerl sebhoerl commented Feb 9, 2024

This is a draft for introducing dynamic vehicle fleets in DVRP/DRT. The PR fixes #3086.

Major changes:

  • Fleet is now an object with its own logic. In particular, it generates generats events when vehicles are added and removed; VehicleAddedEvent and VehicleRemovedEvent.
  • DVRP and DRT are responsive to a changing fleet size during the day. The DRT distance analysis has become totally independent of the fleet specification itself.
  • Instead of providing a Fleet from a FleetSpecification, users now need to implement a FleetCreator. However, it works 99% analogously to the previous logic of creating a fleet. In most cases, this is changing two lines of code (see code changes in the unit tests). The change is necessary as Fleet has now become a container object to which vehicles are added at start-up or later on during the simulation.
  • The code allows to flexibly move vehicles from one DVRP mode to another one (first removing it, then adding it to the other one).
  • Adding vehicles from scratch is a bit more tricky, as we need to register the vehicle with (1) Fleet, (2) QSim, (3) DynActivityEngine and DRT vehicles also need to get an initial task assigned. For that, two helper classes have been introduced: FleetExtensionHelper (is a MobsimEngine), and DrtFleetExtensionHelper (delegates to the former).

All of this functionality is covered by RunDrtExampleIT.testRunWithVariableFleetSize. Here is an example of the integration test's output. Three vehicles are added dynamically between 8h00 and 12h00, thus, giving additional capacity during that period:

output_occupancy_time_profiles_StackedArea_drt

@sebhoerl
Copy link
Contributor Author

sebhoerl commented Feb 9, 2024

This is a first draft. There are probably certain things to clean up still. And obviously the events files of the taxi contrib need to be updated.

@tschlenther
Copy link
Contributor

very nice. was thinking about this functionality long time ago. This enables to investigate exciting use cases, for example for goods+people DRT. Let's merge when the conflicts are solved :)

@sebhoerl
Copy link
Contributor Author

Hi @tschlenther, thanks for the feedback. The idea was indeed to switch vehicles from one drt mode to another, and this was only the first step here. As it turns out, the next step is much more complicated ;) The main reason is that a lot of code in DRT assumes that one vehicle belongs to one mode, especially in the analysis. If one switches vehicles from one mode to another there is a lot of confusion: If a task started with mode A, then the vehicle switches, and the task ends in mode B, the analysis code needs to know about this, so everywhere some kind of "vehicle removed" "vehicle added" events need to be considered. This then also means that each analysis handler needs to listen to all DRT events, not only those with a specific mode.

In general, I have the feeling we would need to have something like a global fleet manager for DRT which tracks which mode a vehicle belongs to at any time, and which then also has the functionality to send vehicles from one fleet to another. But this would require quite a bit of refactoring and we would need to agree on new conventions regarding the analysis scripts.

We can discuss this a bit more in detail, and I think I even have a first draft for this "fleet manager" somewhere.

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.

drt: adjust analysis for dynamic vehicle fleets
2 participants