Skip to content

Commit

Permalink
updated freespeed and capacity of primary and secondary links
Browse files Browse the repository at this point in the history
  • Loading branch information
MahsaAll committed Aug 30, 2024
1 parent 51c88f7 commit 4ab549e
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 7 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.9" />
<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>
20 changes: 13 additions & 7 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.25;
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 Down Expand Up @@ -54,12 +54,18 @@ public static void main(String[] args) throws FactoryException, IOException {
link.setCapacity(2 * link.getCapacity());
}

// REDUCE CAPACITY AND FREESPEED OF URBAN NON-PRIMARY LINKS
// REDUCE CAPACITY FOR PRIMARY AND SECONDARY LINKS
String type = (String) link.getAttributes().getAttribute("type");
boolean primary = type != null && type.contains("primary");
boolean secondary = type != null && type.contains("secondary");
if(primary || secondary) {
link.setCapacity((1-CAPACITY_REDUCTION_FACTOR) * link.getCapacity());
}

// 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

0 comments on commit 4ab549e

Please sign in to comment.