eqasim-org / eqasim-java

The eqasim framework features an integrated transport simulation environment. It is based on the agent-based transport simulation framework MATSim with added components for simulation of discrete choice models.
http://www.eqasim.org
GNU General Public License v2.0
23 stars 39 forks source link

Problem using RunScenarioCutter to cut the scenario #189

Closed syhwawa closed 4 months ago

syhwawa commented 5 months ago

Hello, I successfully used the ile_de_france jar file from the eqasim repo to cut a MATSim scenario, following the documentation.

Now, I'm considering if it's feasible to use this tool for scenarios outside of switzerland or ile_de_france, which could significantly enhance the efficiency of our simulations.

I intend to test the scenario cutter using a small, open-source simulation project named Londinium on GitHub. Here are the MATSim config and population files I used for testing.

I'm curious whether the cutter requires specific MATSim configuration settings and plan inputs to be compatible. An error I encountered while cutting the test scenario suggested that each activity in the plans.xml might need an associated facility:

2023-10-31T15:34:33,149 ERROR ScenarioValidator:66 Person agent_99 has park activity without facility
2023-10-31T15:34:33,149 ERROR ScenarioValidator:66 Person agent_99 has shop activity without facility
2023-10-31T15:34:33,150 ERROR ScenarioValidator:66 Person agent_99 has home activity without facility
Exception in thread "main" java.lang.IllegalStateException: Found errors while checking population
        at org.eqasim.core.scenario.validation.ScenarioValidator.checkScenario(ScenarioValidator.java:196)
        at org.eqasim.core.scenario.cutter.RunScenarioCutter.main(RunScenarioCutter.java:84)

Here's an example activity from the test plan.xml:

    </attributes>
    <plan selected="yes">
      <activity type="home" x="528634.2579046559" y="176896.66392752415" end_time="07:58:00"/>
      <leg mode="car" trav_time="00:25:00"/>

Does it require the addition of a facility to the activity plan, like so?

      <activity type="home" facility="home_hh_0" x="528634.2579046559" y="176896.66392752415" end_time="07:58:00"/>

I also wonder if specific MATSim configuration settings, such as the qsim mobility module, are necessary for compatibility with the cutter.

When I tried to comment out the validating statement in the core/src/main/java/org/eqasim/core/scenario/validation/ScenarioValidator.java, I met another error:

2024-02-01T17:48:34,359  INFO Injector:94   ==full==> ConstructorBinding{key=Key[type=org.matsim.core.trafficmonitoring.TravelTimeCalculator, annotation=[none]], source=org.matsim.core.trafficmonitoring.TravelTimeCalculatorModule.install(TravelTimeCalculatorModule.java:87), scope=Scopes.SINGLETON}
2024-02-01T17:48:34,359  INFO Injector:96 
2024-02-01T17:48:34,359  INFO Injector:99 === printInjector end ===
2024-02-01T17:48:34,368  INFO ParallelProgress:26 Cutting population ... 0/100 (0.00%)
com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInCustomProvider]: IllegalStateException: Cutter does not support teleportedModeFreespeedFactor yet!
  at PopulationCutterModule.provideModeAwareTripProcessor(PopulationCutterModule.java:120)
      \_ installed by: Modules$CombinedModule -> Modules$CombinedModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> AbstractModule$4 -> Modules$OverrideModule -> PopulationCutterModule
  while locating ModeAwareTripProcessor
  at PlanCutter.<init>(PlanCutter.java:25)
      \_ for 1st parameter
  while locating PlanCutter

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

1 error

It seems like it doesn't like some matsim config setting.

Could you please advise on any required modifications to the MATSim configuration and plans for successful testing scenario cutting?

Many thanks for your help in advance.

sebhoerl commented 5 months ago

In principle, you can use the cutter for any MATSim input data that is formatted in the right way. In the eqasim framework we make sure to follow a couple of clear conventions when we generate the MATSim data. For instance, every activity should have coordinates, a link ID, and a facility ID. And the coordinates should coincide with the coordinates of the facility. This way we make sure that everything is coherent when we look things up later in MATSim.

Also, we don't use teleportedModeFreespeedFactor for routing in our scenarios, which seems to be the case for you. You may need to extend the code to properly cut these kind of modes, or you may just define them as network modes (networkModes) with the respective data encoded in you MATSim network.

Yes, everything is cut to the provided perimeter. Have a look at chapter 4.2 here to see the whole concept: https://www.research-collection.ethz.ch/handle/20.500.11850/419837

syhwawa commented 5 months ago

Thanks for your reply and information! @sebhoerl

In principle, you can use the cutter for any MATSim input data that is formatted in the right way. In the eqasim framework, we make sure to follow a couple of clear conventions when we generate the MATSim data. For instance, every activity should have coordinates, a link ID, and a facility ID. The coordinates should coincide with the coordinates of the facility. This way we make sure that everything is coherent when we look things up later in MATSim.

Do you mean we should make a link ID, coordinates and facility ID within the created population so the cutter can cut the scenario? Does the cutter accept the empty facility file or if we have a way to ignore the facility?

Also, we don't use teleportedModeFreespeedFactor for routing in our scenarios, which seems to be the case for you. You may need to extend the code to properly cut these kinds of modes, or you may just define them as network modes (networkModes) with the respective data encoded in your MATSim network.

I think we may not use the teleportedModeFreespeedFactor since I didn't find any setting related the those parameters. Do you think it will be another module which is not compatible with the required matsim config for cutting?

I would appreciate it if you could take a look or if you have any clues that I need to check for my matsim config. Thanks.

sebhoerl commented 5 months ago

1) Yes, you need that information in the data. No, you really need the facilities (I think, but give it a try, maybe we just check for the IDs) 2) I checkd in the code in PopulationCutterModule and this error message is created if there is one mode in the routing section that has a non-null value for teleportedModeFreespeedFactor. So probably this is the case in your configuration file.