MATSIM
RunTimeDependentNetworkExample.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 tutorial.programming.timeDependentNetwork;
20 
21 import org.matsim.api.core.v01.Scenario;
24 import org.matsim.core.config.Config;
32 
38 
42  public static void main(String[] args) {
43  Config config = ConfigUtils.loadConfig( args[0] ) ;
44  config.network().setTimeVariantNetwork(true);
45 
46  // ---
47 
48  Scenario scenario = ScenarioUtils.loadScenario(config) ;
49 
50  // ---
51 
52  for ( Link link : scenario.getNetwork().getLinks().values() ) {
53  double speed = link.getFreespeed() ;
54  final double threshold = 5./3.6;
55  if ( speed > threshold ) {
56  {
57  NetworkChangeEvent event = new NetworkChangeEvent(7.*3600.) ;
58  event.setFreespeedChange(new ChangeValue( ChangeType.ABSOLUTE_IN_SI_UNITS, threshold/10 ));
59  event.addLink(link);
60  final NetworkChangeEvent event1 = event;
62  }
63  {
64  NetworkChangeEvent event = new NetworkChangeEvent(11.5*3600.) ;
65  event.setFreespeedChange(new ChangeValue( ChangeType.ABSOLUTE_IN_SI_UNITS, speed ));
66  event.addLink(link);
67  final NetworkChangeEvent event1 = event;
69  }
70  }
71  }
72 
73  // ---
74 
75  Controler controler = new Controler( scenario ) ;
76 
77  controler.run() ;
78 
79  }
80 
81 }
Map< Id< Link >,?extends Link > getLinks()
static Config loadConfig(final String filename, ConfigGroup...customModules)
NetworkConfigGroup network
Definition: Config.java:92
static Scenario loadScenario(final Config config)
static void addNetworkChangeEvent(Network network, NetworkChangeEvent event)