1

Hy, I am making a AnyLogic Road traffic simulation. I want to add an event i.e., when an Ambulance cames in road traffic, all the cars lower their speed and came on low lane to give Ambulance space. Any help on how to control cars vehicles speed and lane. What is giving me errors in event action is:

if(carType.amb == true)
{ this.setPreferredSpeed(20,KPH);
this.setLane(1);}
  • 1
    unfortunately you can't control which lane your car will go to... this is done internally... you could eventually put lots of stoplines that will allow you to change the car destination "forcing" it to change lanes, but it's a big complicated if your network is too big – Felipe Jan 24 '21 at 09:34

1 Answers1

1

You can indirectly control such lane changes by giving your emergency vehicles a higher speed than normal traffic. However, this will not work 100% as some cars might not be able to move over in time.

Alternatively, have a separate road (visually right next to the normal road). Add lots of transitions to the normal road. Under normal conditions, cars use it like the normal road.

However, once an emergency arrives, make all cars leave that road and keep it clear for emergency vehicles.

In other words: use a road like a custom lane.

Not elegant, fair bit of manual work... but it works

Benjamin
  • 10,603
  • 3
  • 16
  • 28