matsim-org / matsim-libs

Multi-Agent Transport Simulation
www.matsim.org
483 stars 447 forks source link

issue creating a new scenario - engineQNetsimEngine is Null #1704

Closed federicobigi closed 3 years ago

federicobigi commented 3 years ago

Goodmorning everyone, I did a clean installation of matsim 13.0, created the network using pt2matsim, created the transit schedule and used the dummy config, changing the input accordingly, to launch the simulation. I manually created a population of 3 people that should just walk around to test the consistency of the network. When i try to launch the simulation, i get this error:

2021-10-05T12:22:57,847 ERROR QSim:344 got exception while cleaning up java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because the return value of "org.matsim.core.mobsim.qsim.qnetsimengine.AbstractQNetsimEngine.getQnetsimEngineRunner()" is null at org.matsim.core.mobsim.qsim.qnetsimengine.AbstractQNetsimEngine.afterSim(AbstractQNetsimEngine.java:183) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.QSim.cleanupSim(QSim.java:341) [matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.QSim.run(QSim.java:261) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.runMobSim(NewControler.java:124) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$8.run(AbstractController.java:211) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:243) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.mobsim(AbstractController.java:207) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:154) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:121) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:81) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-13.0.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-13.0.jar:?] at org.matsim.codeexamples.run.RunMatsim.main(RunMatsim.java:63) [classes/:?] 2021-10-05T12:22:57,854 WARN QSim:263 exception in finally block - this may be a follow-up exception of an exception thrown in the try block. java.lang.RuntimeException: got exception while cleaning up the QSim. Please check the error messages above for details. at org.matsim.core.mobsim.qsim.QSim.cleanupSim(QSim.java:349) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.QSim.run(QSim.java:261) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.runMobSim(NewControler.java:124) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$8.run(AbstractController.java:211) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:243) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.mobsim(AbstractController.java:207) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:154) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:121) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:81) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-13.0.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-13.0.jar:?] at org.matsim.codeexamples.run.RunMatsim.main(RunMatsim.java:63) [classes/:?] 2021-10-05T12:22:57,854 ERROR AbstractController:222 Mobsim did not complete normally! afterMobsimListeners will be called anyway. java.lang.ClassCastException: class org.matsim.core.population.routes.GenericRouteImpl cannot be cast to class org.matsim.core.population.routes.NetworkRoute (org.matsim.core.population.routes.GenericRouteImpl and org.matsim.core.population.routes.NetworkRoute are in unnamed module of loader 'app') at org.matsim.core.mobsim.qsim.agents.PopulationAgentSource.insertVehicles(PopulationAgentSource.java:89) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.agents.PopulationAgentSource.insertAgentsIntoMobsim(PopulationAgentSource.java:72) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.QSim.createAgents(QSim.java:293) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.QSim.prepareSim(QSim.java:278) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.QSim.run(QSim.java:237) ~[matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.runMobSim(NewControler.java:124) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$8.run(AbstractController.java:211) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:243) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.mobsim(AbstractController.java:207) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:154) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:121) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:81) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-13.0.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-13.0.jar:?] at org.matsim.codeexamples.run.RunMatsim.main(RunMatsim.java:63) [classes/:?] 2021-10-05T12:22:57,855 INFO AbstractController$9:234 ### ITERATION 0 fires after mobsim event 2021-10-05T12:22:57,855 INFO ControlerListenerManagerImpl:248 calling notifyAfterMobsim on org.matsim.analysis.LegTimesControlerListener 2021-10-05T12:22:57,861 INFO LegTimesControlerListener:50 [0] average trip (probably: leg) duration is: 0 seconds = 00:00:00 2021-10-05T12:22:57,861 INFO ControlerListenerManagerImpl:248 calling notifyAfterMobsim on org.matsim.core.events.MobsimScopeEventHandling 2021-10-05T12:22:57,862 INFO ControlerListenerManagerImpl:248 calling notifyAfterMobsim on org.matsim.core.scoring.EventsToActivities$1 2021-10-05T12:22:57,862 INFO ControlerListenerManagerImpl:251 [it.0] all ControlerAfterMobsimListeners called. 2021-10-05T12:22:57,863 ERROR MatsimRuntimeModifications:75 Getting uncaught Exception in Thread main java.lang.ClassCastException: class org.matsim.core.population.routes.GenericRouteImpl cannot be cast to class org.matsim.core.population.routes.NetworkRoute (org.matsim.core.population.routes.GenericRouteImpl and org.matsim.core.population.routes.NetworkRoute are in unnamed module of loader 'app') at org.matsim.core.mobsim.qsim.agents.PopulationAgentSource.insertVehicles(PopulationAgentSource.java:89) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.agents.PopulationAgentSource.insertAgentsIntoMobsim(PopulationAgentSource.java:72) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.QSim.createAgents(QSim.java:293) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.QSim.prepareSim(QSim.java:278) ~[matsim-13.0.jar:?] at org.matsim.core.mobsim.qsim.QSim.run(QSim.java:237) ~[matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.runMobSim(NewControler.java:124) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$8.run(AbstractController.java:211) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iterationStep(AbstractController.java:243) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.mobsim(AbstractController.java:207) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.iteration(AbstractController.java:154) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.doIterations(AbstractController.java:121) ~[matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController$1.run(AbstractController.java:81) ~[matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:69) [matsim-13.0.jar:?] at org.matsim.core.controler.MatsimRuntimeModifications.run(MatsimRuntimeModifications.java:52) [matsim-13.0.jar:?] at org.matsim.core.controler.AbstractController.run(AbstractController.java:89) [matsim-13.0.jar:?] at org.matsim.core.controler.NewControler.run(NewControler.java:82) [matsim-13.0.jar:?] at org.matsim.core.controler.Controler.run(Controler.java:249) [matsim-13.0.jar:?] at org.matsim.codeexamples.run.RunMatsim.main(RunMatsim.java:63) [classes/:?] 2021-10-05T12:22:57,863 INFO MatsimRuntimeModifications:79 S H U T D O W N --- start shutdown. What could be the issue? I tried different matsim versions (0.10.0 as well), but apparently none of them manages to find the qnetsim engine. Thanks for the attention.

Janekdererste commented 3 years ago

This is a little difficult to answer without further information. Could you please provide your config, network and possibly your run class?

federicobigi commented 3 years ago

lux_scenario.zip

Please find the required documents attached! :)

Janekdererste commented 3 years ago

I'm sorry, I guess I was not precise. I would try to run your set up but the class contained in the zip file only contains the run class which seems to have external dependencies.

It looks like you have forked the matsim-example-project. Would it be possible for you to share your repository? Then I could check it out myself and try to run it. Since your input files look fine on first sight this would be the easiest way for me to spot possibile errors.

federicobigi commented 3 years ago

I'm having issue pulling the repo on github, please find the link here attached. Thanks!

https://drive.google.com/file/d/1d0Qsa8hHzRsuBlywBKeUmc5EdqY-oCsb/view?usp=sharing

Janekdererste commented 3 years ago

I don't have access.

federicobigi commented 3 years ago

Try now please!

Janekdererste commented 3 years ago

I'm sorry, but this seems to be our example repository. I can't find the run class which you prevously provided in that repository. Please sort things out on your side first before you reach out for help.

I can look at your project but please make sure that everything is sorted and presentable, and that it is available to be checked out as a git repository. No more zip files please except maybe for input files.

federicobigi commented 3 years ago

I preferred to send you the clean installation given that both the clean installation and the installation that I was working on give me the same problem. Also, I figured out that the installation that I have is highly customized with a lot of references to direct path into my pc and I thought it would have been a nightmare for you to sort it out! Even though the error changes, I think it still refers to a problem with the QNetsimEngine. That's why I think it could be a problem refered to the input files. Please find the repo attached here https://github.com/federicobigi/matsim-lux Thanks again for the help!

Janekdererste commented 3 years ago

Thanks, I checked out your repository. Your plans file has its own doctype which refers to a file I don't have. So I can't really verify your problem.

In case you wrote your own dtd to have properties such as age, car_avail etc. in your person tag, I'd recommend to use the person's Attributes for this purpose. Most MATSim container have an Attributes field where you can story a collection of any key, value combination.

If you want to use the MATSim-SDK for generating your population you could add these attributes by doing something like the following

person.getAttributes().putAttribute("age", 22);

Examples on how to generate a population with our SDK can be found here for example

Also, your config has car,pt,walk as main modes. This is quite unusual as well. Pt doesn't neet to be specified as main mode, since it is treated differently something along the lines with this

 <module name="transit">
        <param name="transitScheduleFile" value="transit-schedule-file"/>
        <param name="useTransit" value="true"/>
        <param name="vehiclesFile" value="transit-vehilces-file"/>
    </module>

A good starting point for sorting out such things could be the user guide

federicobigi commented 3 years ago

Thanks for the reply! I'll go through the matsim guide as well, I'm quite new to generation population. I'll try to find some solutions there. I tried to change the main mode config, adding as well the module for transit, but still the problem persist. I've updated the plans file, adhering to the plans_v4.dtd version. If you'd like to check it out now, I don't think you will have problem running the simulation and find the error that I'm finding as well.

Janekdererste commented 3 years ago

Okay, so I was able to run your scenario. The error you were seing was indeed unfortunate because the Mobsim was crashing when it tried to insert your walk legs into the QSim and then crashed again when trying to handle the first crash 🙄. When you specify a main mode to be simulated on the network you also need to specify this mode as a network mode in the routing module of your config. Otherwise the Qsim doesn't know how to handle the routes of such a leg. Please read the user guide chapter 7 on this topic.

That said, the standard approach is to have 'car' as network mode but having 'walk' as a teleported mode. I'd suggest to do it this way as well, unless you have a very good reason to do it differently.

Also, your re-planning strategies are not set up well. This would be chapter 4.6 in the user guide.

Also, your scoring parameters are not set up correctly. This is described in chapter 5 of the user guide.

I know it is difficult to get started from the example projects. A configuration for a more real world set up can be found here for example. You would have to replace the file paths with your files of course.

I've updated the plans file, adhering to the plans_v4.dtd version.

Please note that the current plans version is 6 i think. Matsim's plan reader is backwards compatible with this version, however, since you are generating your plans right now, it makes sense to use the current version I guess.

Please also note, that the recommended starting point for a MATSim project is the matsim-example-project. It contains a sceleton for creating your own matsim project from which you can start.

federicobigi commented 3 years ago

Thank you very much for your detailed answer! I finally managed to run the scenario smoothly. I tried as well changing the base file for the plans to the pop_v6, but the plans_v4 works for now starting with the clean project.