1

I am designing an AnyLogic Road traffic simulation. I want to make the traffic signal go green for a lane when an ambulance appears on that lane, To give the Ambulances top priority.

Any help on how to control traffic signal lights for a specific car type?

Toufiq
  • 11
  • 1

1 Answers1

1

You can put a stopline on your road and call the code as below: enter image description here

This assumes you have cars on the road of a custom CarType Emergency obviously. Then, each car checks "am I an emergency" and if so, it checks if the traffic light is currently red (assuming phase 0 is the red phase). If so, it goes to the next phase (which should be defined as green, obviously).

this is just 1 suggestion to get you started

PS: You will not be able to model true emergency-car interactions as you see them in reality, this is beyond the Roadtraffic library capabilities. You can only "nudge" towards it and mimic real behavior.

Benjamin
  • 10,603
  • 3
  • 16
  • 28
  • Hi Benjamin, why do you say that true emergency-car interactions is beyond Road traffic library capabilities? if we use self defined stop lines (not traffic lights) I think it can be done. – Mohammad Hasan N. Sep 21 '21 at 12:01
  • Depends on what level of detail you want to achieve. If you want 99% accurate driver & emergency behavior, you will struggle. If this level here is good enough, all is well :) – Benjamin Sep 21 '21 at 12:56
  • @MohammadHasanN. Can you help me doing this on anydesk or Teamviewer? I would be really grateful. – Toufiq Sep 21 '21 at 15:25
  • @Toufiq feel free to reach out via benjamin@benjamin-schumann.com to discuss :) – Benjamin Sep 21 '21 at 18:33
  • @Toufiq Do you mean using self defined stop lines? there is no problem for a session. But it is simple. Just using self defined stop lines instead of traffic light and then using the similar actions explained by Benjamin, and use SetSignal method to set stop lines' signal programmatically. – Mohammad Hasan N. Sep 22 '21 at 06:29
  • @MohammadHasanN. I think he is more worried about my comment that you cannot really (99%) replicate emergency-car interactions as you see them in reality (cars moving out of the way to the side, emergency vehicles navigating around cars, ...) – Benjamin Sep 22 '21 at 06:35
  • Look, I am very weak in programming. Also new to Anylogic. That is why I am not getting it right. I need this simulation for my thesis. I can not afford paid consultancy. If someone could help me remotely, I would be very grateful. – Toufiq Sep 22 '21 at 12:54
  • @Toufiq, you need to learn how to ask good questions then to make it work. No one can simply do the thesis work for you :) See here to get started: https://www.benjamin-schumann.com/blog/2021/4/1/how-to-win-at-anylogic-on-stackoverflow – Benjamin Sep 22 '21 at 13:07