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

An error in using drt

Open Areza622 opened this issue 1 year ago • 11 comments

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:

  1. org.matsim.contrib.drt.run.MultiModeDrtConfigGroup(name=multiModeDrt).parameterSetsPerType[drt].[0].drtInsertionSearchParams: must not be null at org.matsim.core.config.consistency.BeanValidationConfigConsistencyChecker.checkConsistency(BeanValidationConfigConsistencyChecker.java:67) at org.matsim.core.config.Config.checkConsistency(Config.java:239) at org.matsim.core.controler.Controler.run(Controler.java:230) at org.matsim.project.lecture11.RunMatsim.main(RunMatsim.java:96)

Process finished with exit code 1

Areza622 avatar Nov 18 '23 15:11 Areza622

Hi, you need to provide insertion parameters inside your drt config group, i.e. to specify the insertion algorithm. Currently, there are 3 options:

  1. "ExtensiveInsertionSearch"
  2. "SelectiveInsertionSearch"
  3. "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 avatar Nov 20 '23 11:11 tschlenther

@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");

Areza622 avatar Nov 21 '23 22:11 Areza622

Please try the following: drtCfg.addDrtInsertionSearchParams(new ExtensiveInsertionSearchParams() {});

tschlenther avatar Nov 22 '23 09:11 tschlenther

@tschlenther Thank you so much!

Areza622 avatar Nov 23 '23 18:11 Areza622

@tschlenther I encountered an issue: Simulation goes on and on and in between there are some errors as below:

  1. [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)

  2. [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=)

  3. [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

Areza622 avatar Nov 25 '23 22:11 Areza622

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 avatar Nov 28 '23 09:11 tschlenther

@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.

michalmac avatar Nov 28 '23 21:11 michalmac

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)

michalmac avatar Nov 28 '23 21:11 michalmac

@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 .

Areza622 avatar Dec 01 '23 11:12 Areza622

  • 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 avatar Dec 01 '23 21:12 michalmac

@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

Areza622 avatar Dec 05 '23 00:12 Areza622