Skip to content

faq 108212437

Billy Charlton edited this page Sep 5, 2018 · 2 revisions

Add custom network mode other than car

by Dominik Grether on 2017-03-03 13:26:37


As far as I got it, to add a network mode "truck" I need a config containing

    <module name="qsim">
        <param name="mainMode" value="car, truck"/>
    </module>

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

and some plan with leg mode="truck".  Doing so, I get an exception:

2017-03-03 14:04:05,364 ERROR MatsimRuntimeModifications:54 Getting uncaught Exception in Thread main
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error in custom provider, java.lang.RuntimeException: No TravelTime bound for mode truck.
  at org.matsim.core.router.TripRouterModule.install(TripRouterModule.java:65) (via modules: com.google.inject.util.Modules$CombinedModule -> com.google.inject.util.Modules$CombinedModule -> org.matsim.core.controler.AbstractModule$4 -> com.google.inject.util.Modules$OverrideModule -> org.matsim.core.controler.Controler$1 -> org.matsim.core.controler.ControlerDefaultsModule -> org.matsim.core.router.TripRouterModule)
  while locating org.matsim.core.router.RoutingModule annotated with @com.google.inject.name.Named(value=truck)
  while locating org.matsim.core.router.RoutingModule annotated with @com.google.inject.multibindings.Element(setName=,uniqueId=62, type=MAPBINDER, keyType=java.lang.String)
  at org.matsim.core.router.TripRouter.<init>(TripRouter.java:72)
  while locating org.matsim.core.router.TripRouter

The exception can be reproduced by the recently pushed branch custommainmode, running the CustomMainModeConfigTest. Is another parameter missing or is this a bug?


Bests,

Dominik



Comments: 1


Re: Add custom network mode other than car

by Johan W. Joubert on 2017-03-03 14:16:06

Hi Dominik, for each mode that will assume network routes you have to provide travel time/disutility bindings. For example

Controler controler = new Controler(config);


 /* Bind the travel time and disutility functions to all modes that will assume network routes. */
 controler.addOverridingModule(new AbstractModule() {
       @Override
       public void install() {
             addTravelTimeBinding("truck").to(networkTravelTime());
             addTravelDisutilityFactoryBinding("truck").to(carTravelDisutilityFactoryKey());
       }
 });

 controler.run();

...or whatever other customer functions you want to bind it to.

Clone this wiki locally