matsim-code-examples icon indicating copy to clipboard operation
matsim-code-examples copied to clipboard

Cannot invoke "org.matsim.pt.transitSchedule.api.TransitStopFacility.getCoord()" because "stop1" is null

Open Owen295 opened this issue 1 year ago • 10 comments

Hello everyone,

Anyone who can help this minibus model implementation error?

I am running the minibus contrib I have been struggling with this error: Similar to my issue earlier #938 and #892 which I brought up but no actual solution was documented.

2023-05-29T16:28:36,099  INFO TimeProvider:120 Total weight is zero. Probably first iteration. Will pick time slots randomly.
2023-05-29T16:28:36,100  INFO TimeProvider:120 Total weight is zero. Probably first iteration. Will pick time slots randomly.
2023-05-29T16:29:36,272  INFO MemoryObserver:41 used RAM: 65 MB  free: 34 MB  total: 100 MB
Disconnected from the target VM, address: '127.0.0.1:64502', transport: 'socket'
2023-05-29T16:29:36,308  INFO RandomStopProvider:143 Initialized with 0 of 0 stops covering 0.0 percent of activities
2023-05-29T16:29:36,314  INFO RandomStopProvider:154 No weights found. Probably no population given. Falling back to old behavior.
2023-05-29T16:29:36,323  INFO MatsimRuntimeModifications:79 S H U T D O W N   ---   start shutdown.
2023-05-29T16:29:36,323  INFO ControlerListenerManagerImpl:121 calling notifyShutdown on org.matsim.core.controler.corelisteners.EventsHandlingImpl
2023-05-29T16:29:36,323  INFO ControlerListenerManagerImpl:121 calling notifyShutdown on org.matsim.core.controler.corelisteners.DumpDataAtEndImpl
2023-05-29T16:29:36,323  INFO ControlerListenerManagerImpl:126 calling notifyShutdown on org.matsim.analysis.ScoreStatsControlerListener
2023-05-29T16:29:36,324  INFO ControlerListenerManagerImpl:126 calling notifyShutdown on org.matsim.analysis.IterationTravelStatsControlerListener
2023-05-29T16:29:36,315 ERROR MatsimRuntimeModifications:75 Getting uncaught Exception in Thread main
java.lang.NullPointerException: Cannot invoke "org.matsim.pt.transitSchedule.api.TransitStopFacility.getCoord()" because "stop1" is null
	at org.matsim.contrib.minibus.replanning.CreateNewPlan.run(CreateNewPlan.java:100) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.AbstractOperator.init(AbstractOperator.java:99) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.CarefulMultiPlanOperator.init(CarefulMultiPlanOperator.java:55) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.OperatorInitializer.createAdditionalOperators(OperatorInitializer.java:98) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.PBox.notifyStartup(PBox.java:131) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.PControlerListener.notifyStartup(PControlerListener.java:81) ~[classes/:?]
	at org.matsim.core.controler.ControlerListenerManagerImpl.fireControlerStartupEvent(ControlerListenerManagerImpl.java:108) ~[classes/:?]
	at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:78) ~[classes/:?]
	at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [classes/:?]
	at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [classes/:?]
	at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [classes/:?]
	at org.matsim.core.controler.NewControler.run(NewControler.java:82) [classes/:?]
	at org.matsim.core.controler.Controler.run(Controler.java:249) [classes/:?]
	at org.matsim.contrib.minibus.RunMinibus.run(RunMinibus.java:74) [classes/:?]
	at org.matsim.contrib.minibus.RunMinibus.main(RunMinibus.java:82) [classes/:?]
2023-05-29T16:29:36,323 ERROR MatsimRuntimeModifications:81 ERROR --- This is an unexpected shutdown!

@neuma @vsp-gleich @mrieser what could be the issue because I executed the code with Cape Town data and get a similar error.

The inputs are Here

Thank you

Owen

Owen295 avatar May 29 '23 15:05 Owen295

The minibus-contrib seems to only use links with modes=car to determine potential transit stop locations.

Your network contains no car-links. All links in your network are set to modes=pt. Thus, the minibus-contrib does not detect any potential stop locations for the minibus routes, and thus fails with the observed NullPointerException.

I would suggest modifying your network such that the links also include the mode car.

mrieser avatar Jun 02 '23 19:06 mrieser

Hello @mrieser

Thank you for the response.

Does this mean that I need change my config and where or I need to add car links. I do not need to simulate cars in my implementation. I am interested in the pt. only.

What do you think ?

Best

Owen

Owen295 avatar Jun 02 '23 19:06 Owen295

In the file transitNetwork.xml, all links are defined with modes="pt". Change this in all links to modes="car,pt".

I don't know the minibus-contrib very well if it could be configured differently. So I would go ahead with changing the network.

mrieser avatar Jun 02 '23 19:06 mrieser

@mrieser I have changed mode="car,pt". on the network.

the error is different :

2023-06-02T21:57:57,186  WARN Dijkstra:306 No route was found from node pt_0212NGS to node pt_0201ENL. Some possible reasons:
2023-06-02T21:57:57,187  WARN Dijkstra:307   * Network is not connected.  Run NetworkCleaner().
2023-06-02T21:57:57,187  WARN Dijkstra:308   * Network for considered mode does not even exist.  Modes need to be entered for each link in network.xml.
2023-06-02T21:57:57,187  WARN Dijkstra:309   * Network for considered mode is not connected to starting or ending point of route.  Setting insertingAccessEgressWalk to true may help.
2023-06-02T21:57:57,187  WARN Dijkstra:310 This will now return null, but it may fail later with a null pointer exception.
2023-06-02T21:57:57,188 ERROR MatsimRuntimeModifications:75 Getting uncaught Exception in Thread main
java.lang.NullPointerException: Cannot read field "links" because "path" is null
	at org.matsim.contrib.minibus.routeProvider.ComplexCircleScheduleProvider.createRoute(ComplexCircleScheduleProvider.java:164) ~[classes/:?]
	at org.matsim.contrib.minibus.routeProvider.ComplexCircleScheduleProvider.createTransitLine(ComplexCircleScheduleProvider.java:115) ~[classes/:?]
	at org.matsim.contrib.minibus.routeProvider.ComplexCircleScheduleProvider.createTransitLineFromOperatorPlan(ComplexCircleScheduleProvider.java:107) ~[classes/:?]
	at org.matsim.contrib.minibus.replanning.CreateNewPlan.run(CreateNewPlan.java:116) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.AbstractOperator.init(AbstractOperator.java:99) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.CarefulMultiPlanOperator.init(CarefulMultiPlanOperator.java:55) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.OperatorInitializer.createAdditionalOperators(OperatorInitializer.java:98) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.PBox.notifyStartup(PBox.java:131) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.PControlerListener.notifyStartup(PControlerListener.java:81) ~[classes/:?]
	at org.matsim.core.controler.ControlerListenerManagerImpl.fireControlerStartupEvent(ControlerListenerManagerImpl.java:108) ~[classes/:?]
	at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:78) ~[classes/:?]
	at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [classes/:?]
	at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [classes/:?]
	at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [classes/:?]
	at org.matsim.core.controler.NewControler.run(NewControler.java:82) [classes/:?]
	at org.matsim.core.controler.Controler.run(Controler.java:249) [classes/:?]
	at org.matsim.contrib.minibus.RunMinibus.run(RunMinibus.java:74) [classes/:?]
	at org.matsim.contrib.minibus.RunMinibus.main(RunMinibus.java:82) [classes/:?]
2023-06-02T21:57:57,225 ERROR MatsimRuntimeModifications:81 ERROR --- This is an unexpected shutdown!
2023-06-02T21:57:57,226 ERROR MatsimRuntimeModifications:84 Shutdown possibly caused by the following Exception:
java.lang.NullPointerException: Cannot read field "links" because "path" is null
	at org.matsim.contrib.minibus.routeProvider.ComplexCircleScheduleProvider.createRoute(ComplexCircleScheduleProvider.java:164) ~[classes/:?]
	at org.matsim.contrib.minibus.routeProvider.ComplexCircleScheduleProvider.createTransitLine(ComplexCircleScheduleProvider.java:115) ~[classes/:?]
	at org.matsim.contrib.minibus.routeProvider.ComplexCircleScheduleProvider.createTransitLineFromOperatorPlan(ComplexCircleScheduleProvider.java:107) ~[classes/:?]
	at org.matsim.contrib.minibus.replanning.CreateNewPlan.run(CreateNewPlan.java:116) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.AbstractOperator.init(AbstractOperator.java:99) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.CarefulMultiPlanOperator.init(CarefulMultiPlanOperator.java:55) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.OperatorInitializer.createAdditionalOperators(OperatorInitializer.java:98) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.PBox.notifyStartup(PBox.java:131) ~[classes/:?]
	at org.matsim.contrib.minibus.hook.PControlerListener.notifyStartup(PControlerListener.java:81) ~[classes/:?]
	at org.matsim.core.controler.ControlerListenerManagerImpl.fireControlerStartupEvent(ControlerListenerManagerImpl.java:108) ~[classes/:?]
	at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:78) ~[classes/:?]
	at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [classes/:?]
	at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [classes/:?]
	at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [classes/:?]
	at org.matsim.core.controler.NewControler.run(NewControler.java:82) [classes/:?]
	at org.matsim.core.controler.Controler.run(Controler.java:249) [classes/:?]
	at org.matsim.contrib.minibus.RunMinibus.run(RunMinibus.java:74) [classes/:?]
	at org.matsim.contrib.minibus.RunMinibus.main(RunMinibus.java:82) [classes/:?]

Do you think this has changed the simulation ?

Best

Owen

Owen295 avatar Jun 02 '23 20:06 Owen295

The first 5 lines describe the issue really good:

2023-06-02T21:57:57,186  WARN Dijkstra:306 No route was found from node pt_0212NGS to node pt_0201ENL. Some possible reasons:
2023-06-02T21:57:57,187  WARN Dijkstra:307   * Network is not connected.  Run NetworkCleaner().
2023-06-02T21:57:57,187  WARN Dijkstra:308   * Network for considered mode does not even exist.  Modes need to be entered for each link in network.xml.
2023-06-02T21:57:57,187  WARN Dijkstra:309   * Network for considered mode is not connected to starting or ending point of route.  Setting insertingAccessEgressWalk to true may help.
2023-06-02T21:57:57,187  WARN Dijkstra:310 This will now return null, but it may fail later with a null pointer exception.

So, the issue is with your network.

To my understanding, the minibus contrib needs a proper road network, because the minibuses will run on roads.

You use a transitNetwork.xml, which sounds as if it is a public transport network only. Maybe even just trains? Based on the error message, this is not a proper road network.

MATSim requires that a road network is what we call "fully connected". That means it must be possible to drive from any link to any other link. Your (transit) network currently does not fulfill this.

mrieser avatar Jun 02 '23 20:06 mrieser

@mrieser

Thank you for the responding promptly.

I made my network from the PT2MATSim converting my GTFS for Nairobi to MATSim inputs. Do you think should use probably use OSM layers for the simulation not the network file I generated from the GTFS conversion?

Best

Owen

Owen295 avatar Jun 02 '23 20:06 Owen295

PT2MATSim can use OSM to create multi-modal networks. So yes, try to use OSM in addition to the GTFS to create a network with PT2MATSim (there should be documentation around on how to do this). This will give you a better, more complete network that also contains actual roads, that should work better with the minibus-contrib.

mrieser avatar Jun 02 '23 20:06 mrieser

@mrieser

Thank you for the response.

I am only interested in simulating the paratransit's which I have the the schedules from the GTFS , if my network becomes multi-modal don't I need to add the car traffic counts to get the congestion levels ?

My interests deals with how the paratransit behave within the network infrastructure available for my study area. I have done a few validation checks for the network and makes sense using distance or time based routing on Qgis.

Can I avoid having a multi modal network ? or does this make the quality of work less?

Best

Owen

Owen295 avatar Jun 02 '23 20:06 Owen295

paratransit's which I have the the schedules from the GTFS

Then you don't need the minibus contrib! The minibus contrib will try to create a schedule. If you already have a schedule and don't want to change it, don't use the minibus contrib. Just the standard MATSim release should be enough to simulate the vehicles according to the given schedule.

mrieser avatar Jun 02 '23 21:06 mrieser

@mrieser Thank you so much.

That is great news I did not know that if I already have an existing schedule , I can use the standard MATSim release which works so far. My main task is to develop an optimization framework for the minibus that outputs an optimized network.

My optimization will be based on the business strategies. Well if the schedules can remain the same can the network output change based on the optimization criteria used? or does it mean that I need an updated schedule every iteration which then would give me a new network configuration for the site. I may have a knowledge gap with it come to MATSim in that sense.

Best

Owen

Owen295 avatar Jun 02 '23 22:06 Owen295