1+ package org .eqasim .switzerland ;
2+
3+ import java .util .HashSet ;
4+ import java .util .Set ;
5+
6+ import org .eqasim .core .simulation .vdf .VDFConfigGroup ;
7+ import org .eqasim .core .simulation .vdf .engine .VDFEngineConfigGroup ;
8+ import org .matsim .api .core .v01 .Scenario ;
9+ import org .matsim .core .config .CommandLine ;
10+ import org .matsim .core .config .CommandLine .ConfigurationException ;
11+ import org .matsim .core .config .Config ;
12+ import org .matsim .core .config .ConfigUtils ;
13+ import org .matsim .core .config .groups .QSimConfigGroup ;
14+ import org .matsim .core .controler .Controler ;
15+ import org .matsim .core .scenario .ScenarioUtils ;
16+
17+ public class RunVDFSimulation {
18+ static public void main (String [] args ) throws ConfigurationException {
19+ // set preventwaitingtoentertraffic to y if you want to to prevent that waiting
20+ // traffic has to wait for space in the link buffer
21+ // this is especially important to avoid high waiting times when we cutout
22+ // scenarios from a larger scenario.
23+ CommandLine cmd = new CommandLine .Builder (args ) //
24+ .requireOptions ("config-path" ) //
25+ .allowPrefixes ("mode-parameter" , "cost-parameter" , "preventwaitingtoentertraffic" ) //
26+ .build ();
27+
28+ SwitzerlandConfigurator configurator = new SwitzerlandConfigurator (cmd );
29+ Config config = ConfigUtils .loadConfig (cmd .getOptionStrict ("config-path" ));
30+ configurator .updateConfig (config );
31+ cmd .applyConfiguration (config );
32+
33+ if (cmd .hasOption ("preventwaitingtoentertraffic" )) {
34+ if (cmd .getOption ("preventwaitingtoentertraffic" ).get ().equals ("y" )) {
35+ ((QSimConfigGroup ) config .getModules ().get (QSimConfigGroup .GROUP_NAME ))
36+ .setPcuThresholdForFlowCapacityEasing (1.0 );
37+ }
38+ }
39+
40+ // VDF: Add config group
41+ config .addModule (new VDFConfigGroup ());
42+
43+ // VDF: Set capacity factor instead (~0.1 for a 10% simulation in theory... any
44+ // better advice?)
45+ // we can use the same as for the queue logic
46+ VDFConfigGroup .getOrCreate (config ).setCapacityFactor (
47+ ((QSimConfigGroup ) config .getModules ().get (QSimConfigGroup .GROUP_NAME )).getFlowCapFactor ());
48+
49+ // VDF: Disable queue logic
50+ config .qsim ().setFlowCapFactor (1e9 );
51+
52+ // maybe we do not want to disable storage capacity logic
53+ // as we might want to have some back propagation delays
54+ config .qsim ().setStorageCapFactor (1e9 );
55+
56+ // VDF: Optional
57+ VDFConfigGroup .getOrCreate (config ).setWriteInterval (1 );
58+ VDFConfigGroup .getOrCreate (config ).setWriteFlowInterval (1 );
59+
60+ // VDF Engine: Add config group
61+ config .addModule (new VDFEngineConfigGroup ());
62+
63+ // VDF Engine: Decide whether to genertae link events or not
64+ VDFEngineConfigGroup .getOrCreate (config ).setGenerateNetworkEvents (false );
65+
66+ // VDF Engine: Remove car from main modes
67+ Set <String > mainModes = new HashSet <>(config .qsim ().getMainModes ());
68+ mainModes .remove ("car" );
69+ config .qsim ().setMainModes (mainModes );
70+
71+ Scenario scenario = ScenarioUtils .createScenario (config );
72+ configurator .configureScenario (scenario );
73+ ScenarioUtils .loadScenario (scenario );
74+ configurator .adjustScenario (scenario );
75+
76+ Controler controller = new Controler (scenario );
77+ configurator .configureController (controller );
78+ controller .run ();
79+ }
80+ }
0 commit comments