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

Help with error: "mode "bike" is defined both as teleportation (mode routing param) and for network routing. You need to remove one or the other."

Open erotnem opened this issue 3 years ago • 11 comments

Hello,

I recently was trying to add modes other than cars to my router and encountered the following error, no matter what I did: "mode "bike" is defined both as teleportation (mode routing param) and for network routing. You need to remove one or the other."

I've tried to add new modes in the way mentioned by the book in chapter 7.2; this means I first put them in my config.xml file with teleported mode speed (this works great). The book then says I should transition to a detailed router for the mode; so, I deleted the teleported mode speed information and added the simple "" code under the "planscalcroute" module.

That is when I run into this error. Later, in the book, I see that it mentions a similar error. It then says to use 'clearDefaultTeleportedModeParams'; however, if I put this into my code, I get that the calcRoute object is null; follow stack trace.

What should I do from this point onwards? Any help would be appreciated.

erotnem avatar Oct 06 '21 14:10 erotnem

Hello,

Keep the bike teleported section in the config.xml, but comment it. Then, try again.

jalal1 avatar Oct 08 '21 03:10 jalal1

Hello! Thanks for the quick reply and sorry for the late follow-up. I tried this, but the same error remains. Could you take a look at my code and see if I'm doing what you said correctly? I've attached my config.xml textfile to this reply config - Copy - Copy.txt .

erotnem avatar Oct 12 '21 12:10 erotnem

Did you assign the available modes to the links in your network file? By default they are probably only allowing car mode, but if you want also other modes to be routed on the network you need to define which links can use these modes. The easiest would be to assign to all links that have car also other modes. Otherwise, you need to make sure that subnetworks (i.e., walk network) is also connected.

balacmi avatar Oct 13 '21 09:10 balacmi

I believe I did so -- that was initially my issue with running any of the modes at all (even via teleportation). I have attached my network.xml, in case I might have done it wrong networkcopy.txt

erotnem avatar Oct 13 '21 20:10 erotnem

If you can attach the log file, I may see something. I also suggest you remove all sections related to bike in the config file, then run it to be sure it works. After that, start adding one section a time and try again. To do this quickly, you may create a plan.xml file with one plan only.

jalal1 avatar Oct 14 '21 04:10 jalal1

I tried this, but the same error remains.

This is unusual. If you run with the config - Copy - Copy.txt you should not see that very error.

I see that it mentions a similar error. It then says to use 'clearDefaultTeleportedModeParams'; however, if I put this into my code,

As far as I know, bike is not part of the default teleported modes. It could be helpful if you provide a link to your repository, so that we can try to run your example.

My guess is, that you have conflicting layers of configuration - from your config file you've provided here, as well as from the configuration done in your run class.

Janekdererste avatar Oct 14 '21 07:10 Janekdererste

Hi all! Thanks for the help so far. @jalal1 : I did as you said and started from scratch (adding one section at a time); interestingly enough, now it says that there is an issue with the object being null. The log file is as follows: logfileWarningsErrors.log

@Janekdererste : Thanks for the input, it's interesting that that error occurs -- you're right, there must be some discrepancy between the config I run and the config I have put here. I'm still a new user to Github so not really sure how to put everything on here in a repository, but once I figure it out, I'll be sure to link that. Thank you both!

erotnem avatar Oct 14 '21 15:10 erotnem

@Janekdererste https://github.com/erotnem/MATSIM-Aachen provides a link to the files I'm currently using for this simulation.

erotnem avatar Oct 14 '21 15:10 erotnem

I think now you have another problem, different than what you reported before. It is in the method "getVehicleTypesForAllNetworkAndMainModes" as you can see below:

java.lang.RuntimeException: Object is null; follow stack trace
	at org.matsim.core.gbl.Gbl.assertNotNull(Gbl.java:209) ~[matsim-13.0.jar:?]
	at org.matsim.core.controler.PrepareForSimImpl.getVehicleTypesForAllNetworkAndMainModes(PrepareForSimImpl.java:258) ~[matsim-13.0.jar:?]

I checked quickly the java code, and I think it happens because you made a change to the config file:

It was: <param name="mainMode" value="car,bike,walk,pt" /> now: <param name="mainMode" value="car, bike" />

The problem with the space after the comma and before 'bike' in the line above. Remove it and it should work.

jalal1 avatar Oct 14 '21 23:10 jalal1

This seems to work! Thanks so much. It's crazy to think that the spacing was a problem. Thanks again!

erotnem avatar Oct 15 '21 07:10 erotnem

Hm, someone should put a trim into the parser somewhere 🤔

Janekdererste avatar Oct 15 '21 08:10 Janekdererste