3

I'm trying to find a way to control the traffic lights at multiple junctions in a single simulation. I've a grid of 4 x 4 with 16 traffic lights and I want to test a Global algorithm for optimizing traffic flows at each junction in the grid.

I'm using SUMO and python TRACI for this task. I've implemented several single junction local traffic light controlling algorithms earlier but I'm unable to figure out a simple method for multiple junction simulation. Some explanation/strategy or code snippets would be very helpful for me.

Thanks in advance!

  • 1
    Welcome to Stackoverflow. Please edit your question to add some minimal data and code. SO is not a code writitng service, you need to show what you have tried *first*. For guidance please read [how to ask questions](https://stackoverflow.com/help/how-to-ask) and [how to create a minimal example](https://stackoverflow.com/help/mcve) – 5th Sep 13 '18 at 12:22
  • 1
    @5th Please read my question again, I'm not asking to write code (It is virtually impossible, the code would span at least 1k llines!). I'm asking for suggestions or some generic way/strategy for attempting this problem. The code I wrote was for single junction nodes (Around 300 lines) and is not relevant for the above mentioned problem. – Khilan Ravani Sep 13 '18 at 12:54
  • 1
    Good to know. If possible add this information to your question. You might also link Github repository with the code or to other resources which you have considered. But in my experience you mostly get nowhere without adding code here – 5th Sep 13 '18 at 13:06

1 Answers1

0

Usually the pattern for a control algorithm with traci is

while traci.simulation.getMinExpectedNumber() > 0:
    # retrieve data from detectors
    # act on traffic light
    traci.simulationStep()

There is nothing wrong with doing the following

while traci.simulation.getMinExpectedNumber() > 0:
    # retrieve data from detectors
    # act on traffic light 1
    # act on traffic light 2
    # ...
    traci.simulationStep()

or even have multiple data retrieval steps interspersed. You can also use the traci step listener which calls arbitrary additional python functions or even connect multiple clients (although you need to know in advance how many). But in any case you will need to rework your existing algorithms in a way that you can separate the code which is done between two calls of simulation step and they somehow need all to operate at the same frequency.

Michael
  • 3,510
  • 1
  • 11
  • 23