Skip to content

Commit 8d60d8c

Browse files
authored
feat: adding the script to run switzerland with vdf (#319)
* adding the script to run switzerland with vdf * Update CHANGELOG.md
1 parent 835e2bb commit 8d60d8c

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ included in the (note yet determined) next version number.
1515
- Switched to MATSim 2025 (PR)
1616
- In switzerland one can now switch off vehicles waiting to enter traffic
1717
- In swiss module: adjusted the adapt config to allow parametrizing capacity factors and freight in config
18+
- In swiss module: added vehicles to chonfig
19+
- In swiss module: adding the possibility to run a simulation with VDF
1820

1921
**1.5.0**
2022

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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

Comments
 (0)