2

We found the following behaviour when simulating multiple vehicles in rinsim: Vehicles can drive through each other without colliding just fine as we intend, but sometimes we get the exception below:

Taxi eda0940 is travelling on connection (30.0,22.0)-(30.0,26.0)

Taxi 3578436e is travelling in the opposite direction of that connection (30.0,26.0)-(30.0,22.0)

Both taxis seem to collide and get the exception that they can't jump or change directions. They were both travelling in the correct direction and the one they want to keep following. Can someone explain this behaviour?

If it really is a collision of two taxis we would expect a different exception. Also why would these collisions only happen in some of the cases.

taxi.Taxi@2eda0940: Current intended path: [(30.0,26.0), (30.0,30.0), (34.0,30.0), (38.0,30.0), (42.0,30.0), (46.0,30.0), (50.0,30.0), (54.0,30.0), (58.0,30.0)]
taxi.Taxi@2eda0940: Following path [(30.0,22.92888888888889), (30.0,26.0)]
taxi.Taxi@2eda0940: Current position (30.0,22.92888888888889)
taxi.Taxi@2eda0940: Current connection Optional.of(Connection{from=(30.0,22.0), to=(30.0,26.0), data=Optional.absent()})
java.lang.IllegalArgumentException: Illegal path for this object, from a position on a connection we can not jump to another connection or go back. From (30.0,22.92888888888889), to (30.0,26.0).
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:146)
at com.github.rinde.rinsim.core.model.road.GraphRoadModelImpl.checkMoveValidity(GraphRoadModelImpl.java:241)
at com.github.rinde.rinsim.core.model.road.GraphRoadModelImpl.doFollowPath(GraphRoadModelImpl.java:169)
at com.github.rinde.rinsim.core.model.road.AbstractRoadModel.followPath(AbstractRoadModel.java:94)
at taxi.Taxi.delegate_mas_impl(Taxi.java:262)
at taxi.Taxi.tickImpl(Taxi.java:366)
at com.github.rinde.rinsim.core.model.pdp.Vehicle.tick(Vehicle.java:55)
at com.github.rinde.rinsim.core.model.time.TimeModel.tickImpl(TimeModel.java:139)
at com.github.rinde.rinsim.core.model.time.SimulatedTimeModel.doStart(SimulatedTimeModel.java:32)
at com.github.rinde.rinsim.core.model.time.TimeModel.start(TimeModel.java:94)
at com.github.rinde.rinsim.ui.SimulationViewer$5.run(SimulationViewer.java:401)

taxi.Taxi@3578436e: Optional.of(Connection{from=(30.0,26.0), to=(30.0,22.0), data=Optional.absent()})
taxi.Taxi@3578436e: []
taxi.Taxi@3578436e: 1920000
taxi.Taxi@3578436e: Moving to (30.0,22.0)
taxi.Taxi@3578436e: 

taxi.Taxi@3578436e: Current intended path: [(30.0,22.0), (30.0,18.0), (30.0,14.0), (16.0,16.0), (12.0,16.0), (8.0,16.0), (4.0,16.0), (0.0,16.0), (0.0,12.0), (0.0,8.0)]
taxi.Taxi@3578436e: Following path [(30.0,22.92888888888889), (30.0,22.0)]
java.lang.IllegalArgumentException: Illegal path for this object, from a position on a connection we can not jump to another connection or go back. From (30.0,22.92888888888889), to (30.0,22.0).
taxi.Taxi@3578436e: Current position (30.0,22.92888888888889)
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:146)
taxi.Taxi@3578436e: Current connection Optional.of(Connection{from=(30.0,26.0), to=(30.0,22.0), data=Optional.absent()})
at com.github.rinde.rinsim.core.model.road.GraphRoadModelImpl.checkMoveValidity(GraphRoadModelImpl.java:241)
at com.github.rinde.rinsim.core.model.road.GraphRoadModelImpl.doFollowPath(GraphRoadModelImpl.java:169)
at com.github.rinde.rinsim.core.model.road.AbstractRoadModel.followPath(AbstractRoadModel.java:94)
at taxi.Taxi.delegate_mas_impl(Taxi.java:262)
at taxi.Taxi.tickImpl(Taxi.java:366)
at com.github.rinde.rinsim.core.model.pdp.Vehicle.tick(Vehicle.java:55)
at com.github.rinde.rinsim.core.model.time.TimeModel.tickImpl(TimeModel.java:139)
at com.github.rinde.rinsim.core.model.time.SimulatedTimeModel.doStart(SimulatedTimeModel.java:32)
at com.github.rinde.rinsim.core.model.time.TimeModel.start(TimeModel.java:94)
at com.github.rinde.rinsim.ui.SimulationViewer$5.run(SimulationViewer.java:401)

1 Answers1

0

This behavior is caused by a bug in RinSim. A workaround is to replace:

List<Point> path = rm.getShortestPathTo(start, cur_path.peek());

with:

Point start = rm.getPosition(this);
if (rm.getConnection(this).isPresent()) {
  start = rm.getConnection(this).get().to();
}
List<Point> path = rm.getShortestPathTo(start, cur_path.peek());
rinde
  • 1,181
  • 1
  • 8
  • 20
  • You can see that both taxis have a correct path: Taxi 1: `Current intended path: [(30.0,26.0), (30.0,30.0), (34.0,30.0), (38.0,30.0), (42.0,30.0), (46.0,30.0), (50.0,30.0), (54.0,30.0), (58.0,30.0)] Following path [(30.0,22.92888888888889), (30.0,26.0)] Current position (30.0,22.92888888888889) Current connection Optional.of(Connection{from=(30.0,22.0), to=(30.0,26.0), data=Optional.absent()})` so the assertion of a path beginning with the endpoint of the current connection is fullfilled. (same holds for taxi 2) – Stijn Janssens May 19 '18 at 18:17
  • Can you post minimal working example code that reproduces the behavior that you describe? In that way I can investigate the behavior. – rinde May 20 '18 at 00:00
  • 1
    Here is a github with a minimal working example, the taxis behave randomly and crash around the 11 hour mark. https://github.com/Woekiki/MAS_CollisionError – Stijn Janssens May 23 '18 at 10:42
  • Ok, I found a bug in RinSim that probably causes this. Need a little time to fix it though. Will update this thread when the fix is out. – rinde May 28 '18 at 09:36
  • Updated the answer with a workaround for the problem. – rinde May 30 '18 at 10:32
  • It seems that the best way to fix this is to change part of RinSim's API, I currently have no concrete plan of doing this. Is the workaround doable for you? – rinde Jun 11 '18 at 08:01
  • I have not tested explicitly if the workaround fixed all the "random" problems we encountered, but for now it seems to work fine with it. – Stijn Janssens Jun 11 '18 at 13:07