Skip to content

Commit

Permalink
added calibration class, update makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Jul 30, 2024
1 parent 93a11d4 commit 140f200
Show file tree
Hide file tree
Showing 6 changed files with 299 additions and 129 deletions.
90 changes: 38 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,21 @@ JAR := matsim-$(N)-*.jar

kyoto := ../public-svn/matsim/scenarios/countries/jp/kyoto

ifndef SUMO_HOME
export SUMO_HOME := $(abspath ../../sumo-1.15.0/)
endif

osmosis := osmosis/bin/osmosis

# Scenario creation tool
sc := java -Xmx$(MEMORY) -jar $(JAR)
sc := java -Xmx$(MEMORY) -XX:+UseParallelGC -cp $(JAR) org.matsim.prepare.RunOpenKyotoCalibration

.PHONY: prepare

$(JAR):
mvn package

# Required files
input/network.osm.pbf:
curl https://download.geofabrik.de/europe/germany-210701.osm.pbf\
-o input/network.osm.pbf
input/kansai.osm.pbf:
curl https://download.geofabrik.de/asia/japan/kansai-210101.osm.pbf -o $@

input/network.osm: input/network.osm.pbf
input/network.osm: input/kansai.osm.pbf

# FIXME: Adjust level of details and area

Expand Down Expand Up @@ -74,7 +69,6 @@ input/$V/$N-$V-network.xml.gz:
--output $@



input/$V/$N-$V-network-with-pt.xml.gz: input/$V/$N-$V-network.xml.gz
# FIXME: Adjust GTFS

Expand All @@ -89,61 +83,53 @@ input/$V/$N-$V-network-with-pt.xml.gz: input/$V/$N-$V-network.xml.gz
--shp ../shared-svn/projects/$N/data/Bayern.zip\
--shp ../shared-svn/projects/$N/data/germany-area/germany-area.shp\

input/freight-trips.xml.gz: input/$V/$N-$V-network.xml.gz
# FIXME: Adjust path

$(sc) extract-freight-trips ../shared-svn/projects/german-wide-freight/v1.2/german-wide-freight-25pct.xml.gz\
--network ../shared-svn/projects/german-wide-freight/original-data/german-primary-road.network.xml.gz\
--input-crs EPSG:5677\
input/facilities.gpkg: input/kansai.osm.pbf
$(sc) prepare facility-shp\
--activity-mapping input/activity_mapping.json\
--input $<\
--target-crs $(CRS)\
--shp ../shared-svn/projects/$N/data/shp/$N.shp --shp-crs $(CRS)\
--output $@

input/$V/prepare-25pct.plans.xml.gz:
$(sc) prepare trajectory-to-plans\
--name prepare --sample-size 0.25 --output input/$V\
--population ../shared-svn/projects/$N/matsim-input-files/population.xml.gz\
--attributes ../shared-svn/projects/$N/matsim-input-files/personAttributes.xml.gz

$(sc) prepare resolve-grid-coords\
input/$V/prepare-25pct.plans.xml.gz\
--input-crs $(CRS)\
--grid-resolution 300\
--landuse ../matsim-leipzig/scenarios/input/landuse/landuse.shp\
input/$V/$N-$V-facilities.xml.gz: input/$V/$N-$V-network.xml.gz input/facilities.gpkg
$(sc) prepare facilities --network $< --shp $(word 2,$^)\
--output $@

input/$V/$N-$V-25pct.plans-initial.xml.gz: input/freight-trips.xml.gz input/$V/$N-$V-network.xml.gz input/$V/prepare-25pct.plans.xml.gz
$(sc) prepare generate-short-distance-trips\
--population input/$V/prepare-25pct.plans.xml.gz\
--input-crs $(CRS)\
--shp ../shared-svn/projects/$N/data/shp/$N.shp --shp-crs $(CRS)\
--num-trips 111111 # FIXME
# Static population only contains the home locations
input/$V/$N-static-$V-25pct.plans.xml.gz:
# TODO:

$(sc) prepare adjust-activity-to-link-distances input/$V/prepare-25pct.plans-with-trips.xml.gz\
--shp ../shared-svn/projects/$N/data/shp/$N.shp --shp-crs $(CRS)\
--scale 1.15\
--input-crs $(CRS)\
--network input/$V/$N-$V-network.xml.gz\
--output input/$V/prepare-25pct.plans-adj.xml.gz

$(sc) prepare xy-to-links --network input/$V/$N-$V-network.xml.gz --input input/$V/prepare-25pct.plans-adj.xml.gz --output $@
# Assigns daily activity chains (without locations)
$p/$N-activities-$V-25pct.plans.xml.gz: input/$V/$N-static-$V-25pct.plans.xml.gz input/$V/$N-$V-facilities.xml.gz input/$V/$N-$V-network.xml.gz
$(sc) prepare activity-sampling --seed 1 --input $< --output $@ --persons src/main/python/table-persons.csv --activities src/main/python/table-activities.csv

$(sc) prepare fix-subtour-modes --input $@ --output $@
$(sc) prepare assign-reference-population --population $@ --output $@\
--persons src/main/python/table-persons.csv\
--activities src/main/python/table-activities.csv\
--shp $(germany)/../matsim-berlin/data/SrV/zones/zones.shp\
--shp-crs $(CRS)\
--facilities $(word 2,$^)\
--network $(word 3,$^)\

$(sc) prepare merge-populations $@ $< --output $@

$(sc) prepare extract-home-coordinates $@ --csv input/$V/$N-$V-homes.csv
# Assigns locations to the activities
$p/berlin-initial-$V-25pct.plans.xml.gz: $p/$N-activities-$V-25pct.plans.xml.gz input/$V/$N-$V-facilities.xml.gz input/$V/$N-$V-network.xml.gz
$(sc) prepare init-location-choice\
--input $<\
--output $@\
--facilities $(word 2,$^)\
--network $(word 3,$^)\
--shp $(germany)/vg5000/vg5000_ebenen_0101/VG5000_GEM.shp\
--commuter $(germany)/regionalstatistik/commuter.csv\

# For debugging and visualization
$(sc) prepare downsample-population $@\
--sample-size 0.25\
--samples 0.1 0.01\

--sample-size 0.25\
--samples 0.1 0.03 0.01\

check: input/$V/$N-$V-25pct.plans-initial.xml.gz
$(sc) analysis check-population $<\
--input-crs $(CRS)\
--shp ../shared-svn/projects/$N/data/shp/$N.shp --shp-crs $(CRS)

# Aggregated target
prepare: input/$V/$N-$V-25pct.plans-initial.xml.gz input/$V/$N-$V-network-with-pt.xml.gz
echo "Done"
# TODO:
#prepare: input/$V/$N-$V-25pct.plans-initial.xml.gz input/$V/$N-$V-network-with-pt.xml.gz
# echo "Done"
135 changes: 135 additions & 0 deletions input/activity_mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"building": {
"hotel": ["work"],
"commercial": ["shop", "work", "delivery"],
"retail": ["shop", "work", "delivery"],
"supermarket": ["shop", "shop_daily", "dining", "work", "delivery"],
"industrial": ["work", "delivery"],
"office": ["work"],
"warehouse": ["work", "depot", "delivery"],
"bakehouse": ["work", "depot", "delivery"],
"firestation": ["work"],
"government": ["work"],
"cathedral": ["religious"],
"chapel": ["religious"],
"church": ["religious"],
"mosque": ["religious"],
"religious": ["religious"],
"shrine": ["religious"],
"synagogue": ["religious"],
"temple": ["religious"],
"hospital": ["medical", "work"],
"veterinary": ["p_business", "work"],
"kindergarden": ["edu_kiga", "work"],
"school": ["edu_prim", "work"],
"university": ["edu_higher", "work"],
"college": ["edu_higher", "work"],
"sports_hall": ["leisure", "work"],
"stadium": ["leisure", "work"],
"apartments": ["resident"],
"yes": ["resident"]
},
"amenity": {
"bar": ["leisure", "work", "delivery", "dining"],
"pub": ["leisure", "work", "delivery", "dining"],
"cafe": ["leisure", "work", "delivery", "dining"],
"fast_food": ["work", "delivery", "dining"],
"food_court": ["work", "delivery", "dining"],
"ice_cream": ["work", "delivery", "dining"],
"restaurant": ["work", "delivery", "dining"],
"college": ["edu_higher", "work"],
"kindergarten": ["edu_kiga", "work"],
"language_school": ["edu_other", "work"],
"library": ["leisure", "work"],
"music_school": ["edu_other", "work"],
"school": ["edu_prim", "leisure", "work"],
"university": ["edu_higher", "work"],
"bank": ["p_business", "work"],
"clinic": ["medical", "work"],
"dentist": ["medical", "work"],
"doctors": ["medical", "work"],
"hospital": ["medical", "work"],
"pharmacy": ["shop", "work"],
"social_facility": ["medical", "work"],
"vetinary": ["p_business", "work"],
"arts_centre": ["leisure", "work"],
"casino": ["leisure", "work"],
"cinema": ["leisure", "work"],
"community_centre": ["leisure", "work"],
"gambling": ["leisure", "work"],
"studio": ["leisure", "work"],
"theatre": ["leisure", "work"],
"courthouse": ["p_business", "work"],
"crematorium": ["p_business", "work"],
"embassy": ["p_business", "work"],
"fire_station": ["work"],
"funeral_hall": ["p_business", "work"],
"internet_cafe": ["leisure", "work"],
"marketplace": ["shop", "shop_daily", "work", "dining", "delivery"],
"place_of_worship": ["religious"],
"police": ["p_business", "work"],
"post_box": ["p_business", "work"],
"post_depot": ["p_business", "work"],
"post_office": ["p_business", "work"],
"prison": ["p_business", "work"],
"townhall": ["p_business", "work"]
},
"landuse": {
"commercial": ["shop", "work", "delivery"],
"industrial": ["shop", "work", "delivery", "depot"],
"retail": ["shop", "work", "delivery"],
"depot": ["depot"],
"port": ["depot"],
"quary": ["depot"],
"religious": ["religious"],
"residential": ["resident"]
},
"leisure": {
"adult_gaming_centre": ["leisure", "work"],
"amusement_arcade": ["leisure", "work"],
"beach_resort": ["leisure"],
"dance": ["leisure", "work"],
"escape_game": ["leisure", "work"],
"fishing": ["leisure"],
"fitness_centre": ["leisure", "work"],
"fitness_station": ["leisure"],
"garden": ["leisure"],
"horse_riding": ["leisure", "work"],
"ice_rink": ["leisure", "work"],
"marina": ["leisure", "work"],
"miniature_golf": ["leisure"],
"nature_reserve": ["leisure"],
"park": ["leisure"],
"pitch": ["leisure"],
"playground": ["leisure"],
"sports_centre": ["leisure", "work"],
"stadium": ["leisure", "work"],
"swimming_pool": ["leisure", "work"],
"track": ["leisure"],
"water_park": ["leisure", "work"]
},
"medicalcare": {
"*": ["medical", "work"]
},
"healthcare": {
"*": ["medical", "work"]
},
"office": {
"*": ["work"],
"tax_advisor": ["p_business", "work"],
"insurance": ["p_business", "work"]
},
"government": {
"*": ["work"],
"tax": ["p_business","work"],
"register_office": ["p_business","work"]
},
"shop": {
"*": ["shop", "work"],
"supermarket": ["shop_daily", "work"],
"convenience": ["shop_daily", "work"],
"chemist": ["shop_daily", "work"],
"bakery": ["shop_daily", "work"],
"deli": ["shop_daily", "work"]
}
}
File renamed without changes.
14 changes: 10 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<!-- <version>15.0</version> -->

<!-- PR-labelled release -->
<!-- FIXME: Decide on version -->
<version>2025.0-PR3332</version>
<version>2025.0-PR3350</version>

<!-- snapshot == not recommended: rather use PR-labelled release!-->
<!-- <version>2025.0-SNAPSHOT</version>-->
Expand All @@ -19,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.matsim-scenarios</groupId>
<artifactId>matsim-kyoto</artifactId>
<version>1.x-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>

<name>MATSim Open Kyoto</name>
<description>A transport model of Kyoto</description>
Expand Down Expand Up @@ -65,6 +64,13 @@

<!-- Custom dependencies -->

<!-- Uses the demand generation from the Berlin repo -->
<dependency>
<groupId>com.github.matsim-scenarios</groupId>
<artifactId>matsim-berlin</artifactId>
<version>70c8076e1e</version>
</dependency>


<!-- Include the JUnit testing library. Not transitive. -->
<dependency>
Expand Down Expand Up @@ -170,7 +176,7 @@
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${project.basedir}/${project.build.finalName}-${git.commit.id.describe-short}.jar</outputFile>
<outputFile>${project.basedir}/${project.build.finalName}-${git.commit.id.describe}.jar</outputFile>
<transformers>
<!-- The following sets the main class for the executable jar as you otherwise would with the assembly plugin -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/org/matsim/prepare/RunOpenKyotoCalibration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.matsim.prepare;

import org.matsim.application.MATSimApplication;
import org.matsim.application.prepare.freight.tripExtraction.ExtractRelevantFreightTrips;
import org.matsim.application.prepare.network.CleanNetwork;
import org.matsim.application.prepare.network.CreateNetworkFromSumo;
import org.matsim.application.prepare.network.params.ApplyNetworkParams;
import org.matsim.application.prepare.population.*;
import org.matsim.application.prepare.pt.CreateTransitScheduleFromGtfs;
import org.matsim.prepare.choices.ComputePlanChoices;
import org.matsim.prepare.choices.ComputeTripChoices;
import org.matsim.prepare.facilities.CreateMATSimFacilities;
import org.matsim.prepare.facilities.ExtractFacilityGeoPkg;
import org.matsim.prepare.opt.ExtractPlanIndexFromType;
import org.matsim.prepare.opt.RunCountOptimization;
import org.matsim.prepare.opt.SelectPlansFromIndex;
import org.matsim.prepare.population.AssignReferencePopulation;
import org.matsim.prepare.population.CreateFixedPopulation;
import org.matsim.prepare.population.InitLocationChoice;
import org.matsim.prepare.population.RunActivitySampling;
import org.matsim.run.OpenKyotoScenario;
import picocli.CommandLine;

@CommandLine.Command(header = ":: Open Kyoto Calibration ::", version = OpenKyotoScenario.VERSION, mixinStandardHelpOptions = true)
@MATSimApplication.Prepare({
MergePopulations.class, CreateFixedPopulation.class,
ExtractFacilityGeoPkg.class, DownSamplePopulation.class,
CreateNetworkFromSumo.class, CreateTransitScheduleFromGtfs.class,
CleanNetwork.class, CreateMATSimFacilities.class, InitLocationChoice.class, FilterRelevantAgents.class,
RunActivitySampling.class, MergePlans.class, SplitActivityTypesDuration.class, CleanPopulation.class, CleanAttributes.class,
RunCountOptimization.class, SelectPlansFromIndex.class, ExtractPlanIndexFromType.class, AssignReferencePopulation.class,
ExtractRelevantFreightTrips.class, CheckCarAvailability.class, FixSubtourModes.class, ComputeTripChoices.class, ComputePlanChoices.class,
ApplyNetworkParams.class, SetCarAvailabilityByAge.class
})
public class RunOpenKyotoCalibration extends MATSimApplication {

public static void main(String[] args) {
MATSimApplication.run(RunOpenKyotoCalibration.class, args);
}

}
Loading

0 comments on commit 140f200

Please sign in to comment.