1
votes

I am simulating a traffic intersection in AnyLogic. I need to find out how many cars are in queue at a traffic light at any point in the simulation run. I have setup a traffic light with stoplines. when the simulator runs, I see cars queuing but I can't find a function that actually returns the number of cars in the queue. So I decided to put a queue before the CarMoveTo block. The problem is that queue takes a car and spits it out immediately or based on a timeout. I need it to ingest the car, queue it and only exit the car when the traffic light is green for a particular stopline. Having problems figuring out how to implement the functionality.

1

1 Answers

1
votes

The reasons why you don't find the function is because it doesn't exist. You have to consider that a queue before the traffic light is an ambiguous idea. How far away from the traffic light do you stop counting the cars as part of the queue? There's no objective answer on that... So an example of this would be to generate a stop line for example 200 meters away from the intersection and create a variable that increases or decreases every time a car passes through one of the stop lines:

road stop line action

In these cases it's a good idea to generate a class corresponding to a traffic light queue if your network is too big... but it also depends on whether this solution works for you or not