matsim-org / matsim-code-examples

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

Run MultiMode DRT #426

Open elyh1992 opened 4 years ago

elyh1992 commented 4 years ago

Hi,

I tried to run a DRT scenario and I was able to do that with the run class that is attached in the following. However, when I try to have more than one DRT mode this run class is not working anymore because it has DrtControlerCreator.createControlerWithSingleModeDrt in it. I was wondering how should I change the run class to be able to have more than one DRT (Multi-Mode DRT)?

Thank you in advance.

public class RunMelbourne_drt { private static final String drt_CONFIG = "scenarios/2017-11-scenario-by-kai-from-vista/config_drt.xml"; public static void run(Config config, boolean otfvis) {

    Controler controler = DrtControlerCreator.createControlerWithSingleModeDrt(config, otfvis);

    controler.addOverridingModule(new DrtFareModule());
    controler.run();
}

public static void main(String[] args) {

    Config config = ConfigUtils.loadConfig(drt_CONFIG, new MultiModeDrtConfigGroup(),
            new DvrpConfigGroup(),
            new OTFVisConfigGroup(), new DrtFaresConfigGroup());

    config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
    config.controler().setRoutingAlgorithmType( RoutingAlgorithmType.FastAStarLandmarks);
    config.qsim().setTrafficDynamics(TrafficDynamics.kinematicWaves);
    config.plansCalcRoute().setInsertingAccessEgressWalk(true);

    run(config, false);
}

}

michalmac commented 4 years ago

Here is a multi-mode example: https://github.com/matsim-org/matsim-libs/blob/master/contribs/drt/src/main/java/org/matsim/contrib/drt/run/examples/RunMultiModeDrtExample.java

Looking deeper into DrtControlerCreator, this is what happens: https://github.com/matsim-org/matsim-libs/blob/master/contribs/drt/src/main/java/org/matsim/contrib/drt/run/DrtControlerCreator.java#L62-L78.