Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/calibration'
Browse files Browse the repository at this point in the history
  • Loading branch information
CorinStaves committed Sep 17, 2024
2 parents 76e401a + 051b505 commit f2dc7b0
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 10 deletions.
82 changes: 82 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE config SYSTEM "http://www.matsim.org/files/dtd/config_v2.dtd">
<config>
<module name="controler" >
<!-- Default=1000. Last Iteration of a simulation. -->
<param name="lastIteration" value="150" />
<!-- Possible values: failIfDirectoryExists, overwriteExistingFiles, deleteDirectoryIfExists -->
<param name="overwriteFiles" value="deleteDirectoryIfExists" />
</module>
<module name="network" >
<param name="inputNetworkFile" value="placeholder.xml" />
</module>
<module name="planCalcScore" >
<parameterset type="scoringParameters" >
<parameterset type="activityParams" >
<param name="activityType" value="dummy" />
<!-- typical duration of activity. needs to be defined and non-zero. in sec. -->
<param name="typicalDuration" value="02:00:00" />
</parameterset>
<parameterset type="activityParams" >
<param name="activityType" value="loc" />
<param name="typicalDuration" value="23:00:00" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="car" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="truck" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="pt" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="walk" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="bike" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="ride" />
</parameterset>
<parameterset type="modeParams" >
<param name="mode" value="other" />
</parameterset>
</parameterset>
</module>
<module name="plans" >
<param name="inputPlansFile" value="placeholder.xml" />
</module>
<module name="planscalcroute" >
<!-- All the modes for which the router is supposed to generate network routes (like car) -->
<param name="networkModes" value="truck,car" />
</module>
<module name="qsim" >
<param name="flowCapacityFactor" value="0.1" />
<!-- default: FIFO; options: FIFO PassingQ SeepageQ -->
<param name="linkDynamics" value="FIFO" />
<!-- [comma-separated list] Defines which modes are congested modes. Technically, these are the modes that the departure handler of the netsimengine handles. Effective cell size, effective lane width, flow capacity factor, and storage capacity factor need to be set with diligence. Need to be vehicular modes to make sense. -->
<param name="mainMode" value="car,truck" />
<param name="storageCapacityFactor" value="0.1" />
<!-- If vehicles should all be the same default vehicle, or come from the vehicles file, or something else. Possible values: defaultVehicle modeVehicleTypesFromVehiclesData fromVehiclesData -->
<param name="vehiclesSource" value="modeVehicleTypesFromVehiclesData" />
</module>
<module name="strategy" >
<!-- fraction of iterations where innovative strategies are switched off. Something like 0.8 should be good. E.g. if you run from iteration 400 to iteration 500, innovation is switched off at iteration 480 -->
<param name="fractionOfIterationsToDisableInnovation" value="0.8" />
<parameterset type="strategysettings" >
<!-- strategyName of strategy. Possible default names: SelectRandom BestScore KeepLastSelected ChangeExpBeta SelectExpBeta SelectPathSizeLogit (selectors), ReRouteTimeAllocationMutatorTimeAllocationMutator_ReRouteChangeSingleTripModeChangeTripModeSubtourModeChoice (innovative strategies). -->
<param name="strategyName" value="ReRoute" />
<!-- weight of a strategy: for each agent, a strategy will be selected with a probability proportional to its weight -->
<param name="weight" value="0.15" />
</parameterset>
<parameterset type="strategysettings" >
<param name="strategyName" value="ChangeExpBeta" />
<param name="weight" value="0.85" />
</parameterset>
</module>
<module name="vehicles" >
<param name="vehiclesFile" value="placeholder.xml" />
</module>

</config>
21 changes: 11 additions & 10 deletions src/main/java/demand/CreateVehicleNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.Set;

public class CreateVehicleNetwork {
private final static double URBAN_NONPRIMARY_CAPACITY_REDUCTION_FACTOR = 0.25;
private final static double URBAN_NONPRIMARY_FREESPEED_REDUCTION_FACTOR = 0.25;
private final static double CAPACITY_REDUCTION_FACTOR = 0.3;
private final static double FREESPEED_REDUCTION_FACTOR = 0.25;
private final static Logger log = Logger.getLogger(CreateVehicleNetwork.class);
private static final List<String> PAIRS_TO_CONNECT = List.of("227825out","224795out","164749out","298027out",
"220563out","128831out","367168out","273137out","124102out","124103out","81480out","8582out","4084out","4083out",
Expand All @@ -49,17 +49,18 @@ public static void main(String[] args) throws FactoryException, IOException {

for (Link link : vehicleNetwork.getLinks().values()) {

// Double capacity of short links
if(link.getLength() < 100.) {
link.setCapacity(2 * link.getCapacity());
// REDUCE CAPACITY FOR PRIMARY AND SECONDARY LINKS
boolean primary = (boolean) link.getAttributes().getAttribute("primary");
String type = (String) link.getAttributes().getAttribute("type");
boolean secondary = type != null && type.contains("secondary");
if(primary || secondary) {
link.setCapacity((1-CAPACITY_REDUCTION_FACTOR) * link.getCapacity());
}

// REDUCE CAPACITY AND FREESPEED OF URBAN NON-PRIMARY LINKS
// REDUCE FREESPEED FOR URBAN LINKS
boolean urban = (boolean) link.getAttributes().getAttribute("urban");
boolean primary = (boolean) link.getAttributes().getAttribute("primary");
if(urban && !primary) {
link.setCapacity((1-URBAN_NONPRIMARY_CAPACITY_REDUCTION_FACTOR) * link.getCapacity());
link.setFreespeed((1-URBAN_NONPRIMARY_FREESPEED_REDUCTION_FACTOR) * link.getFreespeed());
if(urban) {
link.setFreespeed((1-FREESPEED_REDUCTION_FACTOR) * link.getFreespeed());
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/demand/RunSimulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

public class RunSimulation {
public static void main(String[] args) {
if (args.length>2) {
throw new RuntimeException("Program requires 2 arguments:\n" +
"(0) Properties file \n" +
"(1) Simulation output directory [optional] \n");
}

Resources.initializeResources(args[0]);

Expand All @@ -29,6 +34,11 @@ public static void main(String[] args) {
config.qsim().setFlowCapFactor(scaleFactor);
config.qsim().setStorageCapFactor(scaleFactor);

// Set output directory
if(args.length == 2){
config.controler().setOutputDirectory(args[1]);
}

Scenario scenario = ScenarioUtils.loadScenario(config);
Controler controler = new Controler(scenario);
controler.run();
Expand Down

0 comments on commit f2dc7b0

Please sign in to comment.