eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.5k stars 1.41k forks source link

Impossible to analyze default taxi dispatch algorithms with traci #15245

Open nomadflamingo opened 2 months ago

nomadflamingo commented 2 months ago

I wanted to analyze the greedyClosest (or any other) taxi dispatch algorithms to later compare with my solution based on reinforcement learning.

My idea was to collect different statistics for the duration of the simulation, such as the number of unserved passengers, and busy taxis thought traci interface and later visualize it.

I can do this for my own solution, but I cannot get access to any default algorithm, since this requires overwriting the --device.taxi.dispatch-algorithm option which prevents traci from making use of functions traci.person.getTaxiReservations() and traci.vehicle.getTaxiFleet(), which is what I need from my understanding.

While I can simply copy the greedyClosest algorithm from the source code into my script, I don't want to risk breaking anything, since the code would need to be ported from C++ into Python.

Is there any other workaround for this problem as of SUMO version 1.20?

m-kro commented 2 months ago

traci.vehicle.getTaxiFleet() works independently from dispatching via TraCI. You are right that traci.person.getTaxiReservations() will throw an exception if used without the TraCI dispatch, although from the code it looks like reading only the reservations should be fine with any dispatch algorithm...?!

You can probably aggregate statistics from other SUMO output like tripinfo and FCD output as well to meaningful metrics for taxi dispatch, but that might be some more work.

nomadflamingo commented 2 months ago

Thank you for your answer. Yes, I was also thinking that calling traci.person.getTaxiReservations() with traci should be allowed even if the --device.taxi.dispatch-algorithm traci option was not set.

But from the code I see that it tries to dynamically cast the dispatcher to MSDispatch_TraCI, and doesn't support any other dispatchers because the method splitReservation is only defined for TraCI dispatcher.

I'm curious if it would be possible to implement this method for other dispatchers because the reservation lookups are only defined for TraCI dispatcher for some reason judging by this line. I'm curious why this is the case.

namdre commented 1 month ago

the other dispatches don't require a lookup based on reservation id. They simply iterate over all known reservations. I think it should be possible to obtain all reservations regardless of dispatcher.