2

在 rinsim 中模拟多辆车辆时,我们发现了以下行为:车辆可以相互行驶而不会发生碰撞,正如我们预期的那样,但有时我们会遇到以下异常:

出租车 eda0940 正在连接 (30.0,22.0)-(30.0,26.0)

出租车 3578436e 与该连接方向相反 (30.0,26.0)-(30.0,22.0)

两辆出租车似乎都发生了碰撞,并获得了无法跳跃或改变方向的例外情况。他们都朝着正确的方向前进,也是他们想要继续追随的方向。有人可以解释这种行为吗?

如果它真的是两辆出租车的碰撞,我们会期待一个不同的例外。还有为什么这些碰撞只会在某些情况下发生。

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)
4

1 回答 1

0

此行为是由 RinSim 中的错误引起的。一种解决方法是替换:

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

和:

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());
于 2018-05-19T05:54:22.843 回答