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

Store FleetState as a vector instead of a map? #208

Open
matdahl opened this issue May 25, 2022 · 0 comments
Open

Store FleetState as a vector instead of a map? #208

matdahl opened this issue May 25, 2022 · 0 comments
Labels
cython/C++ cython/c++ related

Comments

@matdahl
Copy link
Collaborator

matdahl commented May 25, 2022

In the current Python version of the FleetState, the VehicleStates are stored in a dictionary/map.

However, if I see it correctly, there are no vehicles removed during a simulation run. Thus, instead of putting the VehicleStates into a map that requires a search for the correct index each time a VehicleState is accessed, one could also store them into a vector, using the index of the vehicle as its vehicle_id (thus, all vehicle_ids would be in [0,numVehicles-1] )

In this case, the access of a random VehicleState would be (in C++) a trivial operation, as the program immediately knows where to find the vehicle_id-th entry of a vector.

If later vehicles should be "mutable", i.e. put out of service e.g. for maintenance work, one could add a flag inService to VehicleState to tell the dispatcher, whether this vehicle is available or not.

Or is there another reason to use a dictionary/map here?

@fxjung fxjung added the cython/C++ cython/c++ related label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cython/C++ cython/c++ related
Projects
None yet
Development

No branches or pull requests

2 participants