matsim-org / matsim-code-examples

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

Error while using roadpricing module #840

Open khzannat opened 1 year ago

khzannat commented 1 year ago

Hello, I am using the road pricing module to evaluate different pricing strategy. Using the following code I managed to use distance and area based pricing. However, for the codon I am having the following error (I have used the same toll link for cordon used for distance/area). https://github.com/khzannat/dhaka-matsim-example-project/blob/master/src/main/java/org/matsim/project/RunRoadPricingModel0.java

Exception in thread "main" com.google.inject.CreationException: Unable to create injector, see the following errors:

1) [Guice/ErrorInjectingConstructor]: RuntimeException: use LINK toll behavior to implement cording pricing (just pay on links that traverse the cordon) at RoadPricingControlerListener.(RoadPricingControlerListener.java:68) while locating RoadPricingControlerListener while locating ControlerListener annotated with @Element(setName=,uniqueId=105, type=MULTIBINDER, keyType=) at NewControler.(NewControler.java:62) _ for 13th parameter while locating NewControler at NewControlerModule.install(NewControlerModule.java:29) _ installed by: Modules$CombinedModule -> Modules$CombinedModule -> AbstractModule$4 -> Modules$OverrideModule -> Controler$2 -> NewControlerModule while locating ControlerI

Learn more: https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR

1 error

====================== Full classname legend:

AbstractModule$4: "org.matsim.core.controler.AbstractModule$4" Controler$2: "org.matsim.core.controler.Controler$2" ControlerI: "org.matsim.core.controler.ControlerI" ControlerListener: "org.matsim.core.controler.listener.ControlerListener" Element: "com.google.inject.internal.Element" Modules$CombinedModule: "com.google.inject.util.Modules$CombinedModule" Modules$OverrideModule: "com.google.inject.util.Modules$OverrideModule" NewControler: "org.matsim.core.controler.NewControler" NewControlerModule: "org.matsim.core.controler.NewControlerModule" RoadPricingControlerListener: "org.matsim.contrib.roadpricing.RoadPricingControlerListener"

End of classname legend:

at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:568)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:190)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:113)
at com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:239)
at com.google.inject.internal.InjectorImpl.createChildInjector(InjectorImpl.java:244)
at org.matsim.core.controler.Injector.createInjector(Injector.java:74)
at org.matsim.core.controler.Controler.run(Controler.java:247)
at org.matsim.project.RunRoadPricingModel0.main(RunRoadPricingModel0.java:190)

Caused by: java.lang.RuntimeException: use LINK toll behavior to implement cording pricing (just pay on links that traverse the cordon) at org.matsim.contrib.roadpricing.RoadPricingTollCalculator.(RoadPricingTollCalculator.java:95) at org.matsim.contrib.roadpricing.RoadPricingControlerListener.(RoadPricingControlerListener.java:70) at org.matsim.contrib.roadpricing.RoadPricingControlerListener$$FastClassByGuice$$32603044.GUICE$TRAMPOLINE() at org.matsim.contrib.roadpricing.RoadPricingControlerListener$$FastClassByGuice$$32603044.apply() at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:82) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:296) at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:60) at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:40) at com.google.inject.internal.RealMultibinder$RealMultibinderProvider.doProvision(RealMultibinder.java:206) at com.google.inject.internal.RealMultibinder$RealMultibinderProvider.doProvision(RealMultibinder.java:159) at com.google.inject.internal.InternalProviderInstanceBindingImpl$Factory.get(InternalProviderInstanceBindingImpl.java:113) at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:40) at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:60) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:296) at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:60) at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:169) at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45) at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:213) at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:186) ... 6 more How to resolve this issue?

Janekdererste commented 1 year ago

The cordon pricing scheme is no longer supported. Use the link toll type, where you set a price on links which are located inside your cordon. Otherwise you can also charge a fee on the links which are at the boundary of your cordon (This would be closer to how one would implement a cordon in reality I guess)

tschlenther commented 1 year ago

Cordon pricing can indeed be modeled by pricing the border links (and only those). I recently implemented a script to set up a few roadpricing configs. See this for how to filter border links (basically you just have to make sure that EITHER toNode or fromNode of a link has to be within your cordon, using the XOR operator)