matsim-org / matsim-code-examples

A repository containing code examples around MATSim
GNU General Public License v3.0
84 stars 179 forks source link

Why does qsim make bike trip routes of type "generic" and did not estimate the links? #707

Open SheperoMah opened 2 years ago

SheperoMah commented 2 years ago

I have a simulation which works well for cars. Any trip, however, between the same links will for some reason have a generic route. This is true whether the plan was selected or not in the output file. Is there an explanation for why is it the case.

Note. All links in my network have the modes="bike,car,pt,walk"

When I add the mainMode <module name="qsim"> <param name="mainMode" value="car,bike,walk" /> I get a java.lang.NullPointerException: 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 learn.Main$.<clinit>(Main.scala:21) [classes/:?] at learn.Main.main(Main.scala) [classes/:?]

SheperoMah commented 2 years ago

After some debugging here is my last config fileArkiv.zip, it is essentially the equil example with modes="bicycle,walk,pt,car,taxi" added to all links in the network.

1) What is the difference between bike and bicycle? Is bike a motorbike? I am asking because If I replace bicycle with bike in my config.xml and network.xml the model doesn't work! 2) Why is my config file different from Berlin multimodal? I followed the config-with-mode-vehicles.xml 3) When I modify the module name="changeMode" or the module name="planscalcroute" to "car,bicycle,walk" I get all sorts of errors! Each one gives a different error! 4) I am very confused about how to get Matsim to do what I want. And I am not sure either that the options I select do what I want in the final output (when it works). I want to simulate a network with modes="car,bike,walk,pt." I need Matsim to modify the plan starting times, modes, routes and to select the best scoring trip before finishing the simulation. Is there an example config that does exactly this? I want to avoid missing to enable an essential parameter leading to useless results.

  1. I still did not include pt schedules, nor did add a custom scoring functions! I need to add these in my project. But I am afraid that they might not work with certain modes or not interoperate or get weird error as with (3). Are there any errors or pitfalls that I need to be aware of when updating the config file to do these?
Janekdererste commented 2 years ago

You have to include bike as network mode into your planscalcroute section of your config. The user guide chapter 11 has more details on this topic.

If you only add bike as network mode in the qsim, the routing module will generate generic routes (i.e. teleported) for your bike mode. The Qsim then doesn't know what to do with this information.

Also, if you got your config right, it might be necessary to remove the generic route information from the bike trips of your input plans file, in case any are present.

SheperoMah commented 2 years ago

First thanks for the help and swift reply. I read this chapter already, but maybe I missed something. Here is the file itself you can replace bicycle with bike and see the error yourself Arkiv.zip. I defined my config file as this:

<module name="qsim">
        <param name="mainMode" value="car,bicycle,walk" />
...
<module name="planCalcScore">
        <parameterset type="modeParams" >
            <param name="mode" value="bicycle" />
        </parameterset>
        <parameterset type="modeParams" >
            <param name="mode" value="walk" />
        </parameterset>
        <parameterset type="modeParams" >
            <param name="mode" value="car" />
        </parameterset>
...
<module name="changeMode" >
        <param name="modes" value="car,bicycle,walk" />
    </module>

    <module name="planscalcroute" >
        <param name="networkModes" value="car,bicycle,walk" />
    </module>

    <module name="travelTimeCalculator" >
        <param name="analyzedModes" value="car,bicycle,walk" />
        <param name="separateModes" value="true" />
    </module>

I get the same error with bike and walk.

Exception in thread "main" java.lang.ExceptionInInitializerError
    at learn.Main.main(Main.scala)
Caused by: java.lang.RuntimeException: mode "walk" is defined both as teleportation (mode routing param) and for network routing.  You need to remove one or the other.
    at org.matsim.core.config.groups.PlansCalcRouteConfigGroup.checkConsistency(PlansCalcRouteConfigGroup.java:589)
    at org.matsim.core.config.Config.checkConsistency(Config.java:208)
    at org.matsim.core.controler.Controler.run(Controler.java:230)
    at learn.Main$.<clinit>(Main.scala:21)
    ... 1 more
Janekdererste commented 2 years ago

Do you really want to have walk as routed mode? Usually we use it to "teleport" agents from their location onto the network. So a typical car trip for example would look like this activity -> walk -> car interaction -> car -> car interaction -> walk -> activity. This means that walk is used implicitly within non walk trips. For this reason this mode is added as a teleported mode by default.

If you really want to have a routed walking mode, it would probably easier to call it network_walk or something similiar. This would avoid a lot of trouble. You would also have to specify a vehicleType (i.e. shoes 🙃) for this with max speed and such things.

<module name="qsim">
        <param name="mainMode" value="car,bicycle,network_walk" />
        <param name="vehiclesSource" value="modeVehicleTypesFromVehiclesData" />
...
<module name="planCalcScore">
        <parameterset type="modeParams" >
            <param name="mode" value="bicycle" />
        </parameterset>
        <parameterset type="modeParams" >
            <param name="mode" value="network_walk" />
        </parameterset>
        <parameterset type="modeParams" >
            <param name="mode" value="car" />
        </parameterset>
...
<module name="changeMode" >
        <param name="modes" value="car,bicycle,network_walk" />
    </module>

    <module name="planscalcroute" >
        <param name="networkModes" value="car,bicycle,network_walk" />
    </module>

    <module name="travelTimeCalculator" >
        <param name="analyzedModes" value="car,bicycle,network_walk" />
        <param name="separateModes" value="true" />
    </module>
SheperoMah commented 2 years ago

Thanks