Skip to content

Commit

Permalink
finalize small scale commercial traffic impl and creation
Browse files Browse the repository at this point in the history
  • Loading branch information
simei94 committed Aug 19, 2024
1 parent 0b914da commit 059303f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 46 deletions.
34 changes: 17 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ JAR := matsim-$(N)-*.jar
osmosis := osmosis/bin/osmosis
germany := ../shared-svn/projects/matsim-germany
shared := ../shared-svn/projects/DiTriMo
lausitz := ../public-svn/matsim/scenarios/countries/de/lausitz/lausitz-$V
lausitz := ../public-svn/matsim/scenarios/countries/de/lausitz/input/$V

MEMORY ?= 20G
SUMO_HOME ?= $(abspath ../../sumo-1.18.0/)
Expand Down Expand Up @@ -98,37 +98,37 @@ input/plans-longHaulFreight.xml.gz: input/$V/$N-$V-network.xml.gz
input/commercialFacilities.xml.gz:
$(sc) prepare create-data-distribution-of-structure-data\
--outputFacilityFile $@\
--outputDataDistributionFile input/dataDistributionPerZone.csv\
--outputDataDistributionFile $(shared)/data/commercial_traffic/input/commercialTraffic/dataDistributionPerZone.csv\
--landuseConfiguration useOSMBuildingsAndLanduse\
--regionsShapeFileName input/shp/commercialTraffic/lausitz_regions_25832.shp\
--regionsShapeFileName $(shared)/data/commercial_traffic/input/commercialTraffic/lausitz_regions_25832.shp\
--regionsShapeRegionColumn "GEN"\
--zoneShapeFileName input/shp/commercialTraffic/lausitz_zones_25832.shp\
--zoneShapeFileName $(shared)/data/commercial_traffic/input/commercialTraffic/lausitz_zones_25832.shp\
--zoneShapeFileNameColumn "GEN"\
--buildingsShapeFileName $(berlin)/input/shp/commercialTraffic/lausitz_buildings_25832.shp\
--buildingsShapeFileName $(shared)/data/commercial_traffic/input/commercialTraffic/lausitz_buildings_25832.shp\
--shapeFileBuildingTypeColumn "building"\
--landuseShapeFileName $(berlin)/input/shp/commercialTraffic/lausitz_landuse_25832.shp\
--landuseShapeFileName $(shared)/data/commercial_traffic/input/commercialTraffic/lausitz_landuse_25832.shp\
--shapeFileLanduseTypeColumn "landuse"\
--shapeCRS "EPSG:25832"\
--pathToInvestigationAreaData input/commercialTrafficAreaData.csv
--pathToInvestigationAreaData $(shared)/data/commercial_traffic/input/commercialTraffic/commercialTrafficAreaData.csv
# generate small scale commercial traffic
input/lausitz-small-scale-commercialTraffic-$V-100pct.plans.xml.gz: input/$V/$N-$V-network.xml.gz input/commercialFacilities.xml.gz
$(sc) prepare generate-small-scale-commercial-traffic\
input/$V/berlin-$V.config.xml\
--pathToDataDistributionToZones input/dataDistributionPerZone.csv\
--pathToCommercialFacilities $(notdir $(word 2,$^))\
input/$V/lausitz-$V-100pct.config.xml\
--pathToDataDistributionToZones $(shared)/data/commercial_traffic/input/commercialTraffic/dataDistributionPerZone.csv\
--pathToCommercialFacilities $(word 2,$^)\
--sample 1.0\
--jspritIterations 10\
--creationOption createNewCarrierFile\
--network $(notdir $<)\
--network $<\
--smallScaleCommercialTrafficType completeSmallScaleCommercialTraffic\
--zoneShapeFileName input/shp/commercialTraffic/lausitz_zones_25832.shp\
--zoneShapeFileName $(shared)/data/commercial_traffic/input/commercialTraffic/lausitz_zones_25832.shp\
--zoneShapeFileNameColumn "GEN"\
--shapeCRS "EPSG:25832"\
--numberOfPlanVariantsPerAgent 5\
--nameOutputPopulation $(notdir $@)\
--nameOutputPopulation $@\
--pathOutput output/commercialPersonTraffic

mv output/commercialPersonTraffic/$(notdir $@) $@
mv output/commercialPersonTraffic/$@ $@


# trajectory-to-plans formerly was a collection of methods to prepare a given population
Expand Down Expand Up @@ -162,7 +162,7 @@ input/$V/$N-$V-100pct.plans-initial.xml.gz: input/plans-longHaulFreight.xml.gz i
--range 700\
--num-trips 324430

# adapt coords of activitzies in the wider network such that they are closer to a link
# adapt coords of activities in the wider network such that they are closer to a link
# such that agents do not have to walk as far as before
$(sc) prepare adjust-activity-to-link-distances input/$V/prepare-100pct.plans-with-trips.xml.gz\
--shp input/shp/lausitz.shp --shp-crs $(CRS)\
Expand All @@ -180,11 +180,11 @@ input/$V/$N-$V-100pct.plans-initial.xml.gz: input/plans-longHaulFreight.xml.gz i
# split activity types to type_duration for the scoring to take into account the typical duration
$(sc) prepare split-activity-types-duration\
--input $@\
--exclude commercial_start,commercial_end,freight_start,freight_end\
--exclude commercial_start,commercial_end,freight_start,freight_end,service\
--output $@

# merge person and freight pops
$(sc) prepare merge-populations $@ $< --output $@
$(sc) prepare merge-populations $@ $< $(word 3,$^) --output $@

$(sc) prepare downsample-population $@\
--sample-size 1\
Expand Down
16 changes: 0 additions & 16 deletions input/commercialTrafficAreaData.csv

This file was deleted.

27 changes: 14 additions & 13 deletions src/main/java/org/matsim/run/LausitzScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
public class LausitzScenario extends MATSimApplication {

public static final String VERSION = "1.1";
private static final String FREIGHT = "freight";

@CommandLine.Mixin
private final SampleOptions sample = new SampleOptions( 100, 25, 10, 1);
Expand Down Expand Up @@ -132,10 +133,10 @@ protected void prepareScenario(Scenario scenario) {
Set<String> modes = link.getAllowedModes();

// allow freight traffic together with cars
if (modes.contains("car")) {
if (modes.contains(TransportMode.car)) {
Set<String> newModes = Sets.newHashSet(modes);
newModes.add("freight");
newModes.add("truck");
newModes.add(FREIGHT);
newModes.add(TransportMode.truck);

link.setAllowedModes(newModes);
}
Expand All @@ -157,8 +158,8 @@ public void install() {
addTravelTimeBinding(TransportMode.ride).to(networkTravelTime());
addTravelDisutilityFactoryBinding(TransportMode.ride).to(carTravelDisutilityFactoryKey());

addTravelTimeBinding("freight").to(Key.get(TravelTime.class, Names.named(TransportMode.truck)));
addTravelDisutilityFactoryBinding("freight").to(Key.get(TravelDisutilityFactory.class, Names.named(TransportMode.truck)));
addTravelTimeBinding(FREIGHT).to(Key.get(TravelTime.class, Names.named(TransportMode.truck)));
addTravelDisutilityFactoryBinding(FREIGHT).to(Key.get(TravelDisutilityFactory.class, Names.named(TransportMode.truck)));
// we do not need to add SwissRailRaptor explicitely! this is done in core
}

Expand All @@ -170,7 +171,7 @@ public void install() {
*/
public static void prepareCommercialTrafficConfig(Config config) {

Set<String> modes = Set.of("freight", "truck");
Set<String> modes = Set.of(FREIGHT, TransportMode.truck);

modes.forEach(mode -> {
ScoringConfigGroup.ModeParams thisModeParams = new ScoringConfigGroup.ModeParams(mode);
Expand All @@ -183,13 +184,13 @@ public static void prepareCommercialTrafficConfig(Config config) {
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("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("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("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.));

//TODO: add freight and remove from config or change freight subpopulation and mode for long distance freight
for (String subpopulation : List.of("commercialPersonTraffic", "commercialPersonTraffic_service", "goodsTraffic")) {
Expand Down

0 comments on commit 059303f

Please sign in to comment.