Skip to content

Commit

Permalink
Merge pull request #2473 from LBNL-UCB-STI/rw/#2472-scale-network-speed
Browse files Browse the repository at this point in the history
Rw/#2472 scale network speed
  • Loading branch information
wrashid authored Mar 30, 2020
2 parents 7043fe5 + 6955d9a commit 8d45fc6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/main/java/beam/router/r5/R5MnetBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,21 @@ public class R5MnetBuilder {
private final GeotoolsTransformation transform;
private final String osmFile;
private final Map<Coord, Id<Node>> coordinateNodes = new HashMap<>();
private final BeamConfig.Beam beamConfig;

private int matsimNetworkNodeId = 0;

/**
* @param r5Net R5 network.
* @param r5Net R5 network.
* @param beamConfig config to get Path to mapdb file with OSM data and from-to CRS
*/
public R5MnetBuilder(TransportNetwork r5Net, BeamConfig beamConfig) {
BeamConfig.Beam beam = beamConfig.beam();
this.beamConfig = beamConfig.beam();

osmFile = beam.routing().r5().osmMapdbFile();
osmFile = this.beamConfig.routing().r5().osmMapdbFile();

transform = new GeotoolsTransformation(beam.routing().r5().mNetBuilder().fromCRS(),
beam.routing().r5().mNetBuilder().toCRS());
transform = new GeotoolsTransformation(this.beamConfig.routing().r5().mNetBuilder().fromCRS(),
this.beamConfig.routing().r5().mNetBuilder().toCRS());

r5Network = r5Net;

Expand Down Expand Up @@ -81,7 +82,7 @@ public void buildMNet() {
final Set<String> flagStrings = new HashSet<>();
for (EdgeStore.EdgeFlag eF : cursor.getFlags()) {
String flagString = flagToString(eF);
if(!flagString.isEmpty()){
if (!flagString.isEmpty()) {
flagStrings.add(flagToString(eF));
}
}
Expand All @@ -107,13 +108,13 @@ public void buildMNet() {
mNetwork.addLink(link);
log.debug("Created special link: {}", link);
} else {
link = OTM.createLink(way, osmID, edgeIndex, fromNode, toNode, length, (HashSet<String>)flagStrings);
link = OTM.createLink(way, osmID, edgeIndex, fromNode, toNode, length, (HashSet<String>) flagStrings);
mNetwork.addLink(link);
log.debug("Created regular link: {}", link);
}
if (fromNode.getId() == toNode.getId()) {
cursor.setLengthMm(1);
cursor.setSpeed((short)2905); // 65 miles per hour
cursor.setSpeed((short) 2905); // 65 miles per hour
link.setLength(0.001);
link.setCapacity(10000);
link.setFreespeed(29.0576); // 65 miles per hour
Expand All @@ -123,6 +124,11 @@ public void buildMNet() {
if (numberOfFixes > 0) {
log.warn("Fixed {} links which were having the same `fromNode` and `toNode`", numberOfFixes);
}


for (Link link : mNetwork.getLinks().values()) {
link.setFreespeed(link.getFreespeed() * this.beamConfig.physsim().speedScalingFactor());
}
}

private Link buildLink(Integer edgeIndex, Set<String> flagStrings, double length, Node fromNode, Node toNode) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/beam-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ beam.agentsim.scenarios.frequencyAdjustmentFile = ${beam.inputDirectory}"/r5/Fre
# PhysSim Scaling Params
beam.physsim.flowCapacityFactor = "double | 1.0"
beam.physsim.storageCapacityFactor = "double | 1.0"
beam.physsim.speedScalingFactor = "double | 1.0"
beam.physsim.linkStatsWriteInterval = "int | 1"
beam.physsim.linkStatsBinSize = "int | 3600"
beam.physsim.ptSampleSize = "double | 1.0"
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/beam/sim/config/BeamConfig.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// generated by tscfg 0.9.4 on Wed Mar 25 13:53:11 BRT 2020
// generated by tscfg 0.9.4 on Sun Mar 29 21:55:55 CDT 2020
// source: src/main/resources/beam-template.conf

package beam.sim.config
Expand Down Expand Up @@ -2034,6 +2034,7 @@ object BeamConfig {
ptSampleSize: scala.Double,
quick_fix_minCarSpeedInMetersPerSecond: scala.Double,
skipPhysSim: scala.Boolean,
speedScalingFactor: scala.Double,
storageCapacityFactor: scala.Double,
writeEventsInterval: scala.Int,
writeMATSimNetwork: scala.Boolean,
Expand Down Expand Up @@ -2154,6 +2155,7 @@ object BeamConfig {
c.getDouble("quick_fix_minCarSpeedInMetersPerSecond")
else 0.5,
skipPhysSim = c.hasPathOrNull("skipPhysSim") && c.getBoolean("skipPhysSim"),
speedScalingFactor = if (c.hasPathOrNull("speedScalingFactor")) c.getDouble("speedScalingFactor") else 1.0,
storageCapacityFactor =
if (c.hasPathOrNull("storageCapacityFactor")) c.getDouble("storageCapacityFactor") else 1.0,
writeEventsInterval = if (c.hasPathOrNull("writeEventsInterval")) c.getInt("writeEventsInterval") else 0,
Expand Down

0 comments on commit 8d45fc6

Please sign in to comment.