matsim-code-examples
matsim-code-examples copied to clipboard
An error in using drt
Hello, I tried running a drt simulation and I encountered the following error! Can anyone help me to solve the issue?
Exception in thread "main" jakarta.validation.ConstraintViolationException: 1 error(s) found in the config:
- org.matsim.contrib.drt.run.MultiModeDrtConfigGroup(name=multiModeDrt).parameterSetsPerType[drt].
Process finished with exit code 1
Hi, you need to provide insertion parameters inside your drt config group, i.e. to specify the insertion algorithm. Currently, there are 3 options:
- "ExtensiveInsertionSearch"
- "SelectiveInsertionSearch"
- "RepeatedSelectiveInsertionSearch"
The extensive insertion uses the highest precision and takes the longest time, option 3 is some recently evolved compromise between 1. and 2.
I would recommend to try 1. by inserting the lines from below into your input config. If you run into problems (with computation time), report back...
<parameterset type="ExtensiveInsertionSearch" >
<param name="admissibleBeelineSpeedFactor" value="1.0" />
<param name="nearestInsertionsAtEndLimit" value="10" />
</parameterset>
@tschlenther Thank you so much for your response. May I ask you please to help me implement it in code as I am not totally sure how should I do that in this case? Thank you in advance!
This is the corresponding part for my drt config group:
DrtConfigGroup drtCfg = new DrtConfigGroup();
MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup();
multiModeDrtConfigGroup.addParameterSet(drtCfg);
config.addModule(multiModeDrtConfigGroup);
config.addModule(new DvrpConfigGroup());
DrtConfigGroup drt = DrtConfigGroup.getSingleModeDrtConfig(config);
drt.setMaxTravelTimeBeta(600.0);
drt.setMaxTravelTimeAlpha(1.5);
drt.setMaxWaitTime(600.0);
drt.setStopDuration(30.0);
drt.setRejectRequestIfMaxWaitOrTravelTimeViolated(true);
drt.setMaxWalkDistance(1000.0);
drt.setVehiclesFile("drtFleet.xml.gz");
drt.setIdleVehiclesReturnToDepots(false);
drt.setPlotDetailedCustomerStats(true);
drt.setOperationalScheme(DrtConfigGroup.OperationalScheme.stopbased);
drt.setTransitStopFile("drtStops.xml");
indeed I tried editing my code as below but seems not working properly!
DrtConfigGroup drt = DrtConfigGroup.getSingleModeDrtConfig(config);
ExtensiveInsertionSearchParams extensiveInsertionSearchParams = new ExtensiveInsertionSearchParams();
drt.addParameterSet(extensiveInsertionSearchParams);
extensiveInsertionSearchParams.setAdmissibleBeelineSpeedFactor(1.0);
extensiveInsertionSearchParams.setNearestInsertionsAtEndLimit(10);
drt.setMaxTravelTimeBeta(600.0);
drt.setMaxTravelTimeAlpha(1.5);
drt.setMaxWaitTime(600.0);
drt.setStopDuration(30.0);
drt.setRejectRequestIfMaxWaitOrTravelTimeViolated(true);
drt.setMaxWalkDistance(1000.0);
drt.setVehiclesFile("drtFleet.xml.gz");
drt.setIdleVehiclesReturnToDepots(false);
drt.setPlotDetailedCustomerStats(true);
drt.setOperationalScheme(DrtConfigGroup.OperationalScheme.stopbased);
drt.setTransitStopFile("drtStops.xml");
Please try the following:
drtCfg.addDrtInsertionSearchParams(new ExtensiveInsertionSearchParams() {});
@tschlenther Thank you so much!
@tschlenther I encountered an issue: Simulation goes on and on and in between there are some errors as below:
-
[Guice/ErrorInCustomProvider]: ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 9 at AbstractModalModule.bindModal(AbstractModalModule.java:59) _ installed by: Modules$CombinedModule -> Modules$CombinedModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> MultiModeDrtModule -> DrtModeModule while locating DrtRouteUpdater annotated with @DvrpMode(value=drt)
-
[Guice/ErrorInCustomProvider]: ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 9 at AbstractModalModule.bindModal(AbstractModalModule.java:59) _ installed by: Modules$CombinedModule -> Modules$CombinedModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> MultiModeDrtModule -> DrtModeModule while locating DrtRouteUpdater annotated with @DvrpMode(value=drt) while locating ControlerListener annotated with @Element(setName=,uniqueId=174, type=MULTIBINDER, keyType=)
-
[Guice/ErrorInCustomProvider]: ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 9 at AbstractModalModule.bindModal(AbstractModalModule.java:59) _ installed by: Modules$CombinedModule -> Modules$CombinedModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> MultiModeDrtModule -> DrtModeModule while locating DrtRouteUpdater annotated with @DvrpMode(value=drt) while locating ControlerListener annotated with @Element(setName=,uniqueId=174, 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
that's a bit strange and I can't make any diagnosis right now, because I am struggling to see where the corresponding array is referenced.. maybe you can upload your logfile and your config?
@tschlenther Thank you so much for your response. May I ask you please to help me implement it in code as I am not totally sure how should I do that in this case? Thank you in advance!
This is the corresponding part for my drt config group:
DrtConfigGroup drtCfg = new DrtConfigGroup(); MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(); multiModeDrtConfigGroup.addParameterSet(drtCfg); config.addModule(multiModeDrtConfigGroup); config.addModule(new DvrpConfigGroup());
Try removing lines 1 and 3 from the code above.
Try removing lines 1 and 3 from the code above.
(This is assuming that you read the config from the file, but now I am unsure if you do that)
@tschlenther @michalmac Thank you for your responses. The problem is as the simulation does not stop and runs endlessly so it does not produce output data and also instead of config.xml I used coding which I share as text file attached to this message. Thank you in advance! JavaCode.txt .
- I see that probably you use an older matsim version.
- Without more details (like complete console output, matsim version etc.), it is hard to give any hint.
BTW. This block
drt.addDrtInsertionSearchParams(new ExtensiveInsertionSearchParams() {
{
setAdmissibleBeelineSpeedFactor(1.0);
setNearestInsertionsAtEndLimit(10);
}
});
should be refactored to:
var params = new ExtensiveInsertionSearchParams();
params.setAdmissibleBeelineSpeedFactor(1.0);
params.setNearestInsertionsAtEndLimit(10);
drt.addDrtInsertionSearchParams(params);
@michalmac Thank you for your response. I edited the point that you mentioned but unfortunately I still have the issue! I tried 3 different versions and it runs only with MATsim 14 and with newer versions there would be issues with drt paramters!
Although the simulation does not finish but I send you the current errors as a text file! IntelliJ.txt