MATSIM
RunConfigurableQNetworkFactoryExample.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.* *
3  * *
4  * *********************************************************************** *
5  * *
6  * copyright : (C) 2008 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 package org.matsim.core.mobsim.qsim.qnetsimengine;
20 
21 import org.matsim.api.core.v01.Scenario;
24 import org.matsim.core.config.Config;
30 
36 
37  public static void main(String[] args) {
38 
39  Config config = ConfigUtils.createConfig(args[0]) ;
40 
41  run(config);
42 
43  }
44 
45  static void run(Config config) {
46  final Scenario scenario = ScenarioUtils.createScenario( config ) ;
47 
48  Controler controler = new Controler( scenario ) ;
49 
50  final EventsManager events = controler.getEvents() ;
51 
53  @Override public void configureQSim() {
54  final ConfigurableQNetworkFactory factory = new ConfigurableQNetworkFactory(events, scenario);
56  @Override public double getMaximumVelocity( QVehicle vehicle, Link link, double time ){
57  return 1.; // replace by something meaningful
58  }
59  } );
60  factory.setTurnAcceptanceLogic(new DefaultTurnAcceptanceLogic()); // You would obviously set something else than the default
61  bind(QNetworkFactory.class).toInstance(factory);
62  // NOTE: Other than when using a provider, this uses the same factory instance over all iterations, re-configuring
63  // it in every iteration via the initializeFactory(...) method. kai, mar'16
64  }
65  });
66 
67  controler.run();
68  }
69 
70 }
final EventsManager getEvents()
Definition: Controler.java:328
final void setLinkSpeedCalculator(LinkSpeedCalculator linkSpeedCalculator)
final Controler addOverridingQSimModule(AbstractQSimModule qsimModule)
Definition: Controler.java:489
final void setTurnAcceptanceLogic(TurnAcceptanceLogic turnAcceptanceLogic)
static Scenario createScenario(final Config config)
static Config createConfig(final String context)