MATSIM
RunWithinDayReplanningFromPlansExample.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * *
4  * *********************************************************************** *
5  * *
6  * copyright : (C) 2010 by the members listed in the COPYING, *
7  * LICENSE and WARRANTY file. *
8  * email : info at matsim dot org *
9  * *
10  * *********************************************************************** *
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * See also COPYING, LICENSE and WARRANTY file *
17  * *
18  * *********************************************************************** */
19 
20 package tutorial.programming.withinDayReplanningFromPlans;
21 
22 import java.util.HashSet;
23 import java.util.Set;
24 
25 import org.matsim.api.core.v01.Scenario;
27 import org.matsim.core.config.Config;
35 
37 
38  public static void main(String[] args){
39  final Config config = ConfigUtils.loadConfig( "examples/tutorial/programming/example50VeryExperimentalWithinDayReplanning/withinday-config.xml" );
40  final Scenario scenario = ScenarioUtils.createScenario( config );
41  final Controler controler = new Controler( scenario );
42 
44  // (need to make sure that test fails if it does not get the output directory right! kai, nov'15)
45 
46  // define the travel time collector (/predictor) that you want to use for routing:
47  Set<String> analyzedModes = new HashSet<>();
48  analyzedModes.add(TransportMode.car);
49  final TravelTimeCollector travelTime = new TravelTimeCollector(controler.getScenario(), analyzedModes);
50  controler.addOverridingModule(new AbstractModule() {
51  @Override
52  public void install() {
53  this.addEventHandlerBinding().toInstance( travelTime );
54  this.bind(TravelTime.class).toInstance(travelTime);
55  this.addMobsimListenerBinding().to(MyWithinDayMobsimListener.class);
56  this.addMobsimListenerBinding().toInstance(travelTime);
57  }
58  });
59  controler.run();
60  }
61 
62 }
final void addOverridingModule(AbstractModule abstractModule)
Definition: Controler.java:410
ControlerConfigGroup controler
Definition: Config.java:87
static Config loadConfig(final String filename, ConfigGroup...customModules)
static Scenario createScenario(final Config config)