matsim-org / matsim-libs

Multi-Agent Transport Simulation
www.matsim.org
490 stars 452 forks source link

Running Withinday Replanning with MATSim 12 #1407

Open ClarissaLiv opened 3 years ago

ClarissaLiv commented 3 years ago

Hello,

I am trying to learn how to run and use withinday replanning. I had withinday running with the example project (with the equil scenario) when using a snapshot of matsim 12 from 2019, week 48.

But now that I've updated to 12.0 (instead of using the snapshot) I get a warning about the InternalInterface being null. Then, an error occurs saying that there was an exception while replanning in that time was undefined. (See below). Since that is a public transit thing, I tried running withinday replanning (using the ExampleWithinDayController) on the SouixFalls scenario, which has transit, but I still got the exact same error and warning messages.

Is this a bug, or does something need to be changed in the ExampleWithinDayController?

I did try following the error messages through the code, but it seems to dead-end (at least for me) in that the EditTrips.replanFutureTrip method(s) eventually lead to a depreciated method (line 680 of EditTrips). But I don't see how that would lead to the error I'm getting. Nor have I yet been able to deduce what might need to be changed in the ExampleWithinDayControlloer to avoid this error.

Thank you for your assistance.

Clarissa

2021-03-04T19:00:03,757 INFO Counter:69 [VehiclesImpl] added vehicle # 32 2021-03-04T19:00:03,758 INFO Counter:69 [VehiclesImpl] added vehicle # 64 2021-03-04T19:00:03,764 INFO AbstractQNetsimEngine:427 Assigned 15 nodes and 23 links to QSimEngineRunner #0 2021-03-04T19:00:03,774 INFO WithinDayTravelTime:441 WithinDayTravelTime at 05:58:30 #links=0 2021-03-04T19:00:03,783 WARN EditTrips:94 InternalInterface is null. Replanning of pt/transit legs will not work properly and will likely fail. 2021-03-04T19:00:03,784 WARN EditTrips:111 no TransitStopAgentTracker found in qsim. Replanning of pt/transit legs will not work properly and will likely fail. 2021-03-04T19:00:03,784 ERROR ParallelReplanner$ExceptionHandler:341 Thread ParallelDuringActivityReplanner1 died with exception while replanning. java.util.NoSuchElementException: Undefined time at org.matsim.core.utils.misc.OptionalTime.seconds(OptionalTime.java:69) ~[matsim-12.0.jar:?] at org.matsim.withinday.replanning.replanners.NextLegReplanner.doReplanning(NextLegReplanner.java:72) ~[matsim-12.0.jar:?] at org.matsim.withinday.replanning.parallel.ReplanningRunnable.doReplanning(ReplanningRunnable.java:170) ~[matsim-12.0.jar:?] at org.matsim.withinday.replanning.parallel.ReplanningRunnable.run(ReplanningRunnable.java:220) ~[matsim-12.0.jar:?] at java.lang.Thread.run(Thread.java:834) [?:?] 2021-03-04T19:00:03,799 ERROR ParallelReplanner$ExceptionHandler:341 Thread ParallelDuringLegReplanner0 died with exception while replanning. java.lang.RuntimeException: java.util.concurrent.BrokenBarrierException at org.matsim.withinday.replanning.parallel.ReplanningRunnable.run(ReplanningRunnable.java:222) ~[matsim-12.0.jar:?] at java.lang.Thread.run(Thread.java:834) [?:?] Caused by: java.util.concurrent.BrokenBarrierException at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:251) ~[?:?] at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:363) ~[?:?] at org.matsim.withinday.replanning.parallel.ReplanningRunnable.run(ReplanningRunnable.java:213) ~[matsim-12.0.jar:?] ... 1 more 2021-03-04T19:00:03,799 ERROR ParallelReplanner$ExceptionHandler:341 Thread ParallelDuringLegReplanner1 died with exception while replanning. java.lang.RuntimeException: java.util.concurrent.BrokenBarrierException at org.matsim.withinday.replanning.parallel.ReplanningRunnable.run(ReplanningRunnable.java:222) ~[matsim-12.0.jar:?] at java.lang.Thread.run(Thread.java:834) [?:?] Caused by: java.util.concurrent.BrokenBarrierException at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:251) ~[?:?] at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:363) ~[?:?] at org.matsim.withinday.replanning.parallel.ReplanningRunnable.run(ReplanningRunnable.java:213) ~[matsim-12.0.jar:?] ... 1 more 2021-03-04T19:01:02,990 INFO MemoryObserver:41 used RAM: 43 MB free: 274 MB total: 318 MB

kainagel commented 3 years ago

Dear Clarissa,

my intuition is that these two things are not related.

The EditTrips complaint has to do with within-day re-routing of public transport trips, for which it needs infrastructure that is not available in older setups. I think that you can ignore it as long as you are doing within-day replanning for cars.

What seems to be missing is some time information; the specs were tightened here around release 12. Indeed, if you check ExampleWithinDayControllerTest, you find the preparePlans(...) method, which voids all routes in plans, and then recomputes the routes. If you look at the commit history, you find that that method was added when the time specs were changed.

(I can't say why this is needed; it should work without. But this is not enough to trigger a bug fix in 12.x, and I also don't have time right now to work on this. So I hope you can work with this information. Or stay on your weekly snapshot.)

Best wishes, Kai