Skip to content

Commit

Permalink
updates for commercial traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Dec 12, 2023
1 parent b1be372 commit af4555e
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 1,080 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ input/PLR_2013_2020.csv:
rm atlas.zip

$(berlin)/input/shp/Planungsraum_EPSG_25833.shp:
# This link is broken, the file is available in the public svn
curl https://www.stadtentwicklung.berlin.de/planen/basisdaten_stadtentwicklung/lor/download/LOR_SHP_EPSG_25833.zip -o tmp.zip
unzip tmp.zip -d $(berlin)/input
rm tmp.zip
Expand Down Expand Up @@ -97,8 +98,9 @@ $p/berlin-v6.1-network.xml.gz:
--input $(berlin)/../berlin-v5.5-10pct/input/berlin-v5.5-network.xml.gz\
--transit-schedule $(berlin)/../berlin-v5.5-10pct/input/berlin-v5.5-transit-schedule.xml.gz\
--output $@\
--output-transit $p/berlin-v6.0-transitSchedule.xml.gz\
--output-transit $p/berlin-v6.1-transitSchedule.xml.gz\
--input-crs EPSG:31468\
--mode freight=truck\
--target-crs $(CRS)


Expand Down Expand Up @@ -201,7 +203,7 @@ $p/berlin-longHaulFreight-$V-25pct.plans.xml.gz: $p/berlin-$V-network.xml.gz

$p/berlin-small-scale-commercialTraffic-$V-25pct.plans.xml.gz:
$(sc) prepare generate-small-scale-commercial-traffic\
input/commercialTraffic\
input/commercialTraffic/config_demand.xml\
--sample 0.25\
--jspritIterations 1\
--creationOption createNewCarrierFile\
Expand Down
42 changes: 15 additions & 27 deletions input/commercialTraffic/commercial_VehicleTypes_CV.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
<vehicleType id="golf1.4">

<description>Golf 1.4 Trendline</description>
<capacity seats="4" standingRoomInPersons="0" other="0">

</capacity>
<capacity seats="4" standingRoomInPersons="0" other="0"/>
<length meter="7.5"/>
<width meter="1.0"/>
<maximumVelocity meterPerSecond="38.89"/>
<engineInformation>
<attributes>
<attribute name="HbefaVehicleCategory" class="java.lang.String">PASSENGER_CAR</attribute>
Expand All @@ -25,19 +24,17 @@
</attributes>
</costInformation>
<passengerCarEquivalents pce="1.0"/>
<maximumVelocity meterPerSecond="38.89"/>
<networkMode networkMode="car"/>
<flowEfficiencyFactor factor="1.0"/>
</vehicleType>

<vehicleType id="vwCaddy">

<description>VW Caddy 2.0 Maxi TDI</description>
<capacity seats="4" standingRoomInPersons="0" other="0">

</capacity>
<capacity seats="4" standingRoomInPersons="0" other="0"/>
<length meter="7.5"/>
<width meter="1.0"/>
<maximumVelocity meterPerSecond="38.89"/>
<engineInformation>
<attributes>
<attribute name="HbefaVehicleCategory" class="java.lang.String">PASSENGER_CAR</attribute>
Expand All @@ -53,19 +50,17 @@
</attributes>
</costInformation>
<passengerCarEquivalents pce="1.0"/>
<maximumVelocity meterPerSecond="38.89"/>
<networkMode networkMode="car"/>
<flowEfficiencyFactor factor="1.0"/>
</vehicleType>

<vehicleType id="mercedes313">

<description>Mercedes 313 CDI</description>
<capacity seats="1" standingRoomInPersons="0" other="0">

</capacity>
<capacity seats="1" standingRoomInPersons="0" other="0"/>
<length meter="7.5"/>
<width meter="1.0"/>
<maximumVelocity meterPerSecond="38.89"/>
<engineInformation>
<attributes>
<attribute name="HbefaVehicleCategory" class="java.lang.String">LIGHT_COMMERCIAL_VEHICLE</attribute>
Expand All @@ -81,19 +76,17 @@
</attributes>
</costInformation>
<passengerCarEquivalents pce="1.0"/>
<maximumVelocity meterPerSecond="38.89"/>
<networkMode networkMode="car"/>
<flowEfficiencyFactor factor="1.0"/>
</vehicleType>

<vehicleType id="light8t">

<description>Light Vehicle 7.5t</description>
<capacity seats="1" standingRoomInPersons="0" other="10.0">

</capacity>
<capacity seats="1" standingRoomInPersons="0" other="10.0"/>
<length meter="7.5"/>
<width meter="1.0"/>
<maximumVelocity meterPerSecond="22.22"/>
<engineInformation>
<attributes>
<attribute name="HbefaVehicleCategory" class="java.lang.String">LIGHT_COMMERCIAL_VEHICLE</attribute>
Expand All @@ -109,19 +102,17 @@
</attributes>
</costInformation>
<passengerCarEquivalents pce="2.0"/>
<maximumVelocity meterPerSecond="22.22"/>
<networkMode networkMode="freight"/>
<networkMode networkMode="truck"/>
<flowEfficiencyFactor factor="1.0"/>
</vehicleType>

<vehicleType id="medium18t">

<description>Medium Vehicle 18t</description>
<capacity seats="1" standingRoomInPersons="0" other="16.0">

</capacity>
<capacity seats="1" standingRoomInPersons="0" other="16.0"/>
<length meter="7.5"/>
<width meter="1.0"/>
<maximumVelocity meterPerSecond="22.22"/>
<engineInformation>
<attributes>
<attribute name="HbefaVehicleCategory" class="java.lang.String">HEAVY_GOODS_VEHICLE</attribute>
Expand All @@ -137,18 +128,16 @@
</attributes>
</costInformation>
<passengerCarEquivalents pce="3.0"/>
<maximumVelocity meterPerSecond="22.22"/>
<networkMode networkMode="freight"/>
<networkMode networkMode="truck"/>
<flowEfficiencyFactor factor="1.0"/>
</vehicleType>
<vehicleType id="heavy40t">

<description>Heavy Vehicle 40t</description>
<capacity seats="1" standingRoomInPersons="0" other="33.0">

</capacity>
<capacity seats="1" standingRoomInPersons="0" other="33.0"/>
<length meter="7.5"/>
<width meter="1.0"/>
<maximumVelocity meterPerSecond="22.22"/>
<engineInformation>
<attributes>
<attribute name="HbefaVehicleCategory" class="java.lang.String">HEAVY_GOODS_VEHICLE</attribute>
Expand All @@ -164,8 +153,7 @@
</attributes>
</costInformation>
<passengerCarEquivalents pce="4.0"/>
<maximumVelocity meterPerSecond="22.22"/>
<networkMode networkMode="freight"/>
<networkMode networkMode="truck"/>
<flowEfficiencyFactor factor="1.0"/>
</vehicleType>
</vehicleDefinitions>
4 changes: 1 addition & 3 deletions input/commercialTraffic/config_demand.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<!-- The Coordinates Reference System in which the coordinates are expressed in the input file. At import, the coordinates will be converted to the coordinate system defined in "global", and willbe converted back at export. If not specified, no conversion happens. -->
<param name="inputCRS" value="EPSG:25832" />
<param name="inputChangeEventsFile" value="null" />
<param name="inputNetworkFile" value="../v6.0/berlin-v6.0-network.xml.gz" />
<param name="inputNetworkFile" value="../v6.1/berlin-v6.1-network.xml.gz" />
<param name="laneDefinitionsFile" value="null" />
<param name="timeVariantNetwork" value="false" />
</module>
Expand Down Expand Up @@ -560,8 +560,6 @@
<param name="travelTimeAggregator" value="optimistic" />
<!-- The size of the time bin (in sec) into which the link travel times are aggregated for the router -->
<param name="travelTimeBinSize" value="900" />
<!-- possible values: TravelTimeCalculatorArray TravelTimeCalculatorHashMap -->
<param name="travelTimeCalculator" value="TravelTimeCalculatorArray" />
<!-- How to deal with link entry times at different positions during the time bin. Currently supported: average, linearinterpolation -->
<param name="travelTimeGetter" value="average" />
</module>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>matsim-all</artifactId>

<!-- PR-labelled release -->
<version>16.0-PR2976</version>
<version>16.0-PR2990</version>

<!-- snapshot == not recommended: rather use PR-labelled release!-->
<!-- <version>16.0-SNAPSHOT</version>-->
Expand All @@ -15,7 +15,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.matsim-scenarios</groupId>
<artifactId>matsim-berlin</artifactId>
<version>6.0</version>
<version>6.1-SNAPSHOT</version>

<name>MATSim Open Berlin scenario</name>
<description>MATSim Open Berlin scenario</description>
Expand Down Expand Up @@ -348,7 +348,7 @@
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${project.basedir}/${project.build.finalName}.jar</outputFile>
<outputFile>${project.basedir}/${project.build.finalName}-${git.commit.id.describe-short}.jar</outputFile>
<transformers>
<!-- This bit sets the main class for the executable jar as you otherwise would with the assembly plugin -->
<transformer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ public void notifyIterationStarts(IterationStartsEvent iterationStartsEvent) {
boolean modeConverged = false;
if (!activeMetricsMode.isEmpty()) {
String metricType = "mode";
Map<String, Map<Integer, Double>> modeHistories = modeStatsControlerListener.getModeHistories();
if (true)
throw new RuntimeException(" modeStatsControlerListener.getModeHistories() not implemented anymore. Check if this is still needed.");
Map<String, Map<Integer, Double>> modeHistories =null;
bestFitLineGeneric(prevIteration, modeHistories, slopesMode, activeMetricsMode);
produceDynShutdownGraphs(modeHistories, slopesMode, metricType, activeMetricsMode, cfg.getModeThreshold(), iteration);

Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/matsim/prepare/ReprojectNetwork.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.matsim.prepare;

import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.application.MATSimAppCommand;
import org.matsim.application.options.CrsOptions;
import org.matsim.core.config.Config;
Expand All @@ -11,6 +12,9 @@
import picocli.CommandLine;

import java.nio.file.Path;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

@CommandLine.Command(name = "reproject-network", description = "Change the CRS of a network")
public class ReprojectNetwork implements MATSimAppCommand {
Expand All @@ -24,6 +28,9 @@ public class ReprojectNetwork implements MATSimAppCommand {
@CommandLine.Option(names = "--output", description = "Desired output path", required = true)
private Path output;

@CommandLine.Option(names = "--mode", description = "Remap existing modes in the network", required = false, split = ",")
private Map<String, String> remapModes;

@CommandLine.Option(names = "--output-transit", description = "Desired output path", required = true)
private Path outputTransit;

Expand All @@ -49,6 +56,19 @@ public Integer call() throws Exception {
// Scenario loader does the reprojection for the network
Scenario scenario = ScenarioUtils.loadScenario(config);

if (!remapModes.isEmpty()) {
for (Link link : scenario.getNetwork().getLinks().values()) {
Set<String> modes = new HashSet<>(link.getAllowedModes());
remapModes.forEach((oldMode, newMode) -> {
if (modes.contains(oldMode)) {
modes.remove(oldMode);
modes.add(newMode);
}
});
link.setAllowedModes(modes);
}
}

NetworkUtils.writeNetwork(scenario.getNetwork(), output.toString());

TransitScheduleWriter writer = new TransitScheduleWriter(scenario.getTransitSchedule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.application.MATSimAppCommand;
import org.matsim.counts.Counts;
Expand Down Expand Up @@ -98,7 +99,7 @@ private void createCountsFile(String outputFile) {

if (berlinCounts.isLKW_Anteil()) {

Measurable truckVolume = station.createVolume("freight");
Measurable truckVolume = station.createVolume(TransportMode.truck);

double[] PERC_Q_LKW_TYPE = berlinCounts.getPERC_Q_LKW_TYPE();
for (int i = 1; i < 25; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void main(String[] args) {
@SuppressWarnings("IllegalCatch")
public Integer call() throws Exception {

if (shp.getShapeFile() == null) {
if (!shp.isDefined()) {
log.error("Shape file with LOR zones is required.");
return 2;
}
Expand All @@ -93,7 +93,7 @@ public Integer call() throws Exception {

// Collect all LORs
for (SimpleFeature ft : fts) {
lors.put((String) ft.getAttribute("SCHLUESSEL"), (MultiPolygon) ft.getDefaultGeometry());
lors.put((String) ft.getAttribute("PLR_ID"), (MultiPolygon) ft.getDefaultGeometry());
}

log.info("Found {} LORs", lors.size());
Expand Down Expand Up @@ -158,6 +158,11 @@ private void processLOR(CSVRecord row) throws ParseException {
AgeGroup.OLD, old
));

if (!lors.containsKey(raumID)) {
log.warn("LOR {} not found", raumID);
return;
}

MultiPolygon geom = lors.get(raumID);

PopulationFactory f = population.getFactory();
Expand Down
Loading

0 comments on commit af4555e

Please sign in to comment.