-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/master' into develop
- Loading branch information
Showing
31 changed files
with
145 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
132 changes: 132 additions & 0 deletions
132
src/main/java/org/matsim/run/RunMetropoleRuhrScenarioCommercial.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package org.matsim.run; | ||
|
||
import com.google.common.collect.Sets; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.matsim.api.core.v01.Scenario; | ||
import org.matsim.application.MATSimAppCommand; | ||
import org.matsim.core.config.Config; | ||
import org.matsim.core.config.ConfigUtils; | ||
import org.matsim.core.config.groups.*; | ||
import org.matsim.core.controler.Controler; | ||
import org.matsim.core.controler.OutputDirectoryHierarchy; | ||
import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule; | ||
import org.matsim.core.scenario.ScenarioUtils; | ||
import picocli.CommandLine; | ||
|
||
import java.nio.file.Path; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@CommandLine.Command(name = "run-metropole-ruhr-commercial", description = "Runs the commercial traffic for the metropole ruhr scenario", showDefaultValues = true) | ||
public class RunMetropoleRuhrScenarioCommercial implements MATSimAppCommand { | ||
|
||
private static final Logger log = LogManager.getLogger(RunMetropoleRuhrScenarioCommercial.class); | ||
|
||
@CommandLine.Option(names = "--configPath", description = "Path to the config file", required = true, defaultValue = "scenarios/metropole-ruhr-v1.0/input/metropole-ruhr-v1.4-3pct.config.xml") | ||
private Path configPath; | ||
|
||
@CommandLine.Option(names = "--pathCommercialPopulation", description = "Path to the commercial population file", required = true, defaultValue = "../../tubCloud/rvrWirtschaftsverkehr/ruhr_commercial_0.1pct.plans.xml.gz") | ||
private Path pathCommercialPopulation; | ||
|
||
@CommandLine.Option(names = "--networkPath", description = "Path to the network file", required = true, defaultValue = "../../tubCloud/rvrWirtschaftsverkehr/metropole-ruhr-v1.x_network.xml.gz") | ||
private Path networkPath; | ||
|
||
@CommandLine.Option(names = "--output", description = "Path to the output directory", required = true, defaultValue = "output/") | ||
private Path output; | ||
|
||
@CommandLine.Option(names = "--pathVehicleTypes", description = "Path to the vehicle types file", required = true, defaultValue = "../../tubCloud/rvrWirtschaftsverkehr/metropole-ruhr-v1.x.mode-vehicles.xml") | ||
private Path pathVehicleTypes; | ||
|
||
@CommandLine.Option(names = "--sample", description = "Sample size", required = true, defaultValue = "0.001") | ||
private double sample; | ||
|
||
public static void main(String[] args) { | ||
System.exit(new CommandLine(new RunMetropoleRuhrScenarioCommercial()).execute(args)); | ||
} | ||
@Override | ||
public Integer call() throws Exception { | ||
log.info("Running Metropole Ruhr Scenario Commercial"); | ||
|
||
Config config = ConfigUtils.loadConfig(configPath.toString()); | ||
config.plans().setInputFile(configPath.getParent().relativize(pathCommercialPopulation).toString()); | ||
config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration); | ||
config.network().setInputFile(configPath.getParent().relativize(networkPath).toString()); | ||
config.vehicles().setVehiclesFile(configPath.getParent().relativize(pathVehicleTypes).toString()); | ||
config.controller().setOutputDirectory(output.resolve("commercialTraffic_Run" + (int) (sample * 100) + "pct").toString()); | ||
config.controller().setLastIteration(0); | ||
config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists); | ||
config.transit().setUseTransit(false); | ||
config.transit().setTransitScheduleFile(null); | ||
config.transit().setVehiclesFile(null); | ||
config.global().setCoordinateSystem("EPSG:25832"); | ||
config.vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); | ||
config.qsim().setLinkDynamics(QSimConfigGroup.LinkDynamics.PassingQ); | ||
config.qsim().setTrafficDynamics(QSimConfigGroup.TrafficDynamics.kinematicWaves); | ||
config.qsim().setUsingTravelTimeCheckInTeleportation(true); | ||
config.qsim().setUsePersonIdForMissingVehicleId(false); | ||
//to get no traffic jam for the iteration 0 | ||
if (config.controller().getLastIteration() == 0){ | ||
config.qsim().setFlowCapFactor(1.0); | ||
config.qsim().setStorageCapFactor(1.0); | ||
log.warn("Setting flowCapFactor and storageCapFactor to 1.0 because we have only the iteration 0 and we dont want to have traffic jams."); | ||
} | ||
config.replanning().setFractionOfIterationsToDisableInnovation(0.8); | ||
config.scoring().setFractionOfIterationsToStartScoreMSA(0.8); | ||
config.getModules().remove("intermodalTripFareCompensators"); | ||
config.getModules().remove("ptExtensions"); | ||
config.getModules().remove("ptIntermodalRoutingModes"); | ||
config.getModules().remove("swissRailRaptor"); | ||
|
||
//prepare the different modes | ||
Set<String> modes = Set.of("truck8t", "truck18t", "truck26t", "truck40t"); | ||
|
||
modes.forEach(mode -> { | ||
ScoringConfigGroup.ModeParams thisModeParams = new ScoringConfigGroup.ModeParams(mode); | ||
config.scoring().addModeParams(thisModeParams); | ||
}); | ||
Set<String> qsimModes = new HashSet<>(config.qsim().getMainModes()); | ||
config.qsim().setMainModes(Sets.union(qsimModes, modes)); | ||
|
||
Set<String> networkModes = new HashSet<>(config.routing().getNetworkModes()); | ||
config.routing().setNetworkModes(Sets.union(networkModes, modes)); | ||
|
||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("commercial_start").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("commercial_end").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("service").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("pickup").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("delivery").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("commercial_return").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("start").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("end").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_start").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_end").setTypicalDuration(30 * 60)); | ||
config.scoring().addActivityParams(new ScoringConfigGroup.ActivityParams("freight_return").setTypicalDuration(30 * 60)); | ||
|
||
for (String subpopulation : List.of("LTL_trips", "commercialPersonTraffic", "commercialPersonTraffic_service", "longDistanceFreight", | ||
"FTL_trip", "FTL_kv_trip", "goodsTraffic")) { | ||
config.replanning().addStrategySettings( | ||
new ReplanningConfigGroup.StrategySettings() | ||
.setStrategyName(DefaultPlanStrategiesModule.DefaultSelector.ChangeExpBeta) | ||
.setWeight(0.85) | ||
.setSubpopulation(subpopulation) | ||
); | ||
|
||
config.replanning().addStrategySettings( | ||
new ReplanningConfigGroup.StrategySettings() | ||
.setStrategyName(DefaultPlanStrategiesModule.DefaultStrategy.ReRoute) | ||
.setWeight(0.1) | ||
.setSubpopulation(subpopulation) | ||
); | ||
} | ||
|
||
Scenario scenario = ScenarioUtils.loadScenario(config); | ||
|
||
Controler controller = new Controler(scenario); | ||
|
||
controller.run(); | ||
|
||
return 0; | ||
} | ||
} |