Measure intersection delay time

@Benjamin thank you for pointing me in the right direction. Here is my solution, guided by the suggestion. I’m sure it could be refined but in the end it is what worked for me and my limited knowledge of AnyLogic.

For a 4-way intersection, I wanted the delay for each approach, so I created 4 custom car agents, with each populations starting out empty. In each agent, I had 2 variable blocks – var_Start and var_Slow, an one event block set to Timeout, Cyclic, first read at time(), and proceeding in intervals of 0.1s. In the event action, i specidied the following:

if(getSpeed(KPH) <= 40) {
var_Slow=time();
var_Slow.suspend();
}

In main I used Histogram Data, labeled as dataDelay, and a chart with the mean showing, to see the results. I had one for each intersection.

Back in the car agent, in actions on startup:

var_Start=time();

and on destroy:

if(var_Slow = 0)
main.dataDelay.add(time()-var_Start);
else
main.dataDelay.add(time()-var_Slow);

At the car source block in main, I kept the initial and prefered speed at 60, however if there were cars backed up then new cars were often initiated at a slower speed, sometimes already below 40kph, hence the if,else code on destroy.

I had everything labeled according to its corresponding approach direction, unlike the simplified version I have here.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top