Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
paulheinr committed Nov 15, 2024
2 parents 391af1c + 6ac6fbe commit 26b063a
Show file tree
Hide file tree
Showing 31 changed files with 145 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ This repository provides a MATSim transport model for the metropolitan area Ruhr

The **MATSim program code** in this repository is distributed under the terms of the [GNU General Public License as published by the Free Software Foundation (version 2)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html). The MATSim program code are files that reside in the `src` directory hierarchy and typically end with `*.java`.

The **MATSim input files, output files, analysis data and visualizations** are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/80x15.png" /></a> MATSim input files are those that are used as input to run MATSim. They often, but not always, have a header pointing to matsim.org. They typically reside in the `scenarios` directory hierarchy. MATSim output files, analysis data, and visualizations are files generated by MATSim runs, or by postprocessing. They typically reside in a directory hierarchy starting with `output`.
The **MATSim input population** is licensed under the <a rel="license" href="https://creativecommons.org/licenses/by-nc/3.0/de/deed.de"> Creative Commons Attribution CC-BY-NC 3.0 DE License </a> and was provided in its initial version by Senozon Deutschland GmbH.
The **MATSim output files, analysis data and visualizations** are licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution 4.0 International License</a>.
<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/80x15.png" /></a> MATSim input files are those that are used as input to run MATSim. They often, but not always, have a header pointing to matsim.org. They typically reside in the `scenarios` directory hierarchy. MATSim output files, analysis data, and visualizations are files generated by MATSim runs, or by postprocessing. They typically reside in a directory hierarchy starting with `output`.

[//]: # (**Other data files**, in particular in `original-input-data`, have their own individual licenses that need to be individually clarified with the copyright holders.)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
</module>
<module name="network">
<param name="inputNetworkFile"
value="./metropole-ruhr-v2.0.network_resolutionHigh-with-pt.xml.gz"/>
value="../../../../../public-svn/matsim/scenarios/countries/de/metropole-ruhr/metropole-ruhr-v2.0/input/metropole-ruhr-v2024.0.network_resolutionHigh-with-pt.xml.gz"/>
</module>
<module name="plans">
<param name="inputPlansFile"
value="./metropole-ruhr-v2.0-3pct.plans.xml.gz"/>
value="../../../../../public-svn/matsim/scenarios/countries/de/metropole-ruhr/metropole-ruhr-v2.0/input/metropole-ruhr-v2024.0-3pct.plans.xml.gz"/>
<param name="removingUnnecessaryPlanAttributes" value="true"/>
</module>
<module name="vehicles">
Expand All @@ -34,13 +34,13 @@
</module>
<module name="transit">
<param name="transitScheduleFile"
value="./metropole-ruhr-v2.0-transitSchedule.xml.gz"/>
value="../../../../../public-svn/matsim/scenarios/countries/de/metropole-ruhr/metropole-ruhr-v2.0/input/metropole-ruhr-v2024.0-transitSchedule.xml.gz"/>
<param name="useTransit" value="true"/>
<param name="vehiclesFile"
value="./metropole-ruhr-v2.0-transitVehicles.xml.gz"/>
value="../../../../../public-svn/matsim/scenarios/countries/de/metropole-ruhr/metropole-ruhr-v2.0/input/metropole-ruhr-v2024.0-transitVehicles.xml.gz"/>
</module>
<module name="counts">
<param name="inputCountsFile" value="./metropole-ruhr-v2.0.counts.xml.gz"/>
<param name="inputCountsFile" value="../../../../../public-svn/matsim/scenarios/countries/de/metropole-ruhr/metropole-ruhr-v2.0/input/metropole-ruhr-v2024.0.counts.xml.gz"/>
<param name="countsScaleFactor" value="0.03"/>
</module>
<module name="routing">
Expand Down Expand Up @@ -143,13 +143,13 @@
<param name="mode" value="car" />
<!-- We use -3 to fit the approximate value for Berlin -->
<param name="dailyMonetaryConstant" value="-3" />
<param name="constant" value="0.8379675427416293" />
<param name="constant" value="0.56" />
<param name="marginalUtilityOfTraveling_util_hr" value="0.0" />
<param name="monetaryDistanceRate" value="-0.000149" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="ride" />
<param name="constant" value="-2.2644332732845336" />
<param name="constant" value="0.27" />
<!-- alpha=2, gamma=0.0 -->
<!-- adapted in code -->
<param name="marginalUtilityOfTraveling_util_hr" value="0" />
Expand All @@ -160,13 +160,13 @@
<param name="mode" value="pt" />
<!-- 49 EUR Ticket -->
<param name="dailyMonetaryConstant" value="-2.35" />
<param name="constant" value="0.07469218978843763" />
<param name="constant" value="-0.38" />
<param name="marginalUtilityOfTraveling_util_hr" value="0.0" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="bike" />
<param name="constant" value="-0.1502904438227941" />
<param name="marginalUtilityOfTraveling_util_hr" value="0.0" />
<param name="constant" value="0.33" />
<param name="marginalUtilityOfTraveling_util_hr" value="-5.0" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="walk" />
Expand Down
132 changes: 132 additions & 0 deletions src/main/java/org/matsim/run/RunMetropoleRuhrScenarioCommercial.java
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;
}
}

0 comments on commit 26b063a

Please sign in to comment.