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.49k stars 1.41k forks source link

Bus priority without TraCI #15226

Open aminissn opened 2 months ago

aminissn commented 2 months ago

I am working on a function to add bus priority by modifying tllogic mainly using next and earlyTarget attributes. It is working on single intersections coming with certain limitations, but I would like share my code and ask for anyone to contribute and improve it. There are certain cases where it doesn't work, for example if two buses come from two directions, or when time since detection is shorter than required minimum green + amber times from conflicting approaches. This function also requires some extra functionalities from sumolib for which I will create pull request. Hopefully, they won't causes any backward compatibility or test failures. bus_priority.py.zip

namdre commented 2 months ago

Looks useful. My first thought is on the feasibility of adding this code within SUMO to the actuated controller and activate it with params. (#9163 or even #9595). But having this out there as a well-contained tool is a good start and with a bit of polish could be included in the distribution.

aminissn commented 2 months ago

I wasn't aware of these issues. Would be nice to push this. I also think this can be a tool of its own and maintained in the future distributions. How could I better share the code? I still think it is not clear enough what is happening in the code because I was testing a few things on the network and of course there are special cases in there.

ambuehll commented 2 months ago

cc: @AlessioRimoldi

aminissn commented 2 months ago

I made a pull request to add the code to tools/tls/busPriority.py. Maybe on a new branch would have been better until the code gets an acceptable state for distribution? see https://github.com/eclipse-sumo/sumo/pull/15230

namdre commented 2 months ago

Here would be my criteria for acceptability:

  1. add an option module so that no relevant parameters/paths are hard-coded
  2. have test cases for the stuff that works. Two levels of tests make sense:
    • a test in tests/tools that compares the generated .add.xml
    • a test in tests/complex that generates the .add.xml and runs a simulation in which different types of preemption occurs
  3. clean up typos in code

Nice to have:

  1. have (complex) test cases for the stuff that doesn't work yet (as a form of documentation)
aminissn commented 1 month ago

To agree on the logic and to suggest ideas to improve my initial logic, I would like to ask for your opinion if I can already improve it. This is what I have currently in mind: 1) bus signin, 2) phase transition and 3) bus signout we have signin detectors x meters upstream of a tls that detect incoming buses, and then a phase transition starts to accommodate the bus going through the tls with a specific and dedicated green phase with a maxDur (60sec). This is important because, in offline mode, we cannot know in which direction the bus might turn at the tls, therefore we need a phase that has green for all lanes for that edge from which the bus is approaching the tls. Downstream of the tls, we have signout detectors that immediately switch back to the original tls logic. Limitation 1: once a priority transition starts, we cannot consider another bus coming from another approach. Limitation 2: If there is a long queue or a bus stop and the bus cannot pass through the tls in 60sec, it cannot be re-detected. Limitation 3: Switching back to normal tls logic may not be ideal, to compensate the conflicting phases.

namdre commented 1 month ago