-
Notifications
You must be signed in to change notification settings - Fork 140
/
Makefile
324 lines (250 loc) · 12.2 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
JAR := matsim-berlin-*.jar
V := v6.3
CRS := EPSG:25832
p := input/$V
germany := ../shared-svn/projects/matsim-germany
berlin := ../public-svn/matsim/scenarios/countries/de/berlin/berlin-$V
MEMORY ?= 20G
REGIONS := brandenburg
osmosis := osmosis/bin/osmosis
# Scenario creation tool
sc := java -Xmx$(MEMORY) -XX:+UseParallelGC -cp $(JAR) org.matsim.prepare.RunOpenBerlinCalibration
.PHONY: prepare
$(JAR):
mvn package
input/brandenburg.osm.pbf:
curl https://download.geofabrik.de/europe/germany/brandenburg-230101.osm.pbf -o $@
input/facilities.osm.pbf:
# Same OSM version as reference visitations
curl https://download.geofabrik.de/europe/germany/brandenburg-210101.osm.pbf -o $@
$(germany)/RegioStaR-Referenzdateien.xlsx:
curl https://mcloud.de/downloads/mcloud/536149D1-2902-4975-9F7D-253191C0AD07/RegioStaR-Referenzdateien.xlsx -o $@
input/facilities.gpkg: input/brandenburg.osm.pbf
$(sc) prepare facility-shp\
--activity-mapping input/activity_mapping.json\
--input $<\
--output $@
input/PLR_2013_2020.csv:
curl https://instantatlas.statistik-berlin-brandenburg.de/instantatlas/interaktivekarten/kommunalatlas/Kommunalatlas.zip --insecure -o atlas.zip
unzip atlas.zip -d input
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
input/network.osm: input/brandenburg.osm.pbf
$(osmosis) --rb file=$<\
--tf accept-ways highway=motorway,motorway_link,trunk,trunk_link,primary,primary_link,secondary_link,secondary,tertiary,motorway_junction,residential,living_street,unclassified\
--bounding-polygon file="$p/area/area.poly"\
--used-node --wb input/network-detailed.osm.pbf
$(osmosis) --rb file=$<\
--tf accept-ways highway=motorway,motorway_link,trunk,trunk_link,primary,primary_link,secondary_link,secondary,tertiary,motorway_junction\
--used-node --wb input/network-coarse.osm.pbf
$(osmosis) --rb file=input/network-coarse.osm.pbf --rb file=input/network-detailed.osm.pbf\
--merge\
--tag-transform file=input/remove-railway.xml\
--wx $@
rm input/network-detailed.osm.pbf
rm input/network-coarse.osm.pbf
input/sumo.net.xml: input/network.osm
$(SUMO_HOME)/bin/netconvert --geometry.remove --ramps.guess --ramps.no-split\
--type-files $(SUMO_HOME)/data/typemap/osmNetconvert.typ.xml,$(SUMO_HOME)/data/typemap/osmNetconvertUrbanDe.typ.xml\
--tls.guess-signals true --tls.discard-simple --tls.join --tls.default-type actuated\
--junctions.join --junctions.corner-detail 5\
--roundabouts.guess --remove-edges.isolated\
--no-internal-links --keep-edges.by-vclass passenger,truck,bicycle\
--remove-edges.by-vclass hov,tram,rail,rail_urban,rail_fast,pedestrian\
--output.original-names --output.street-names\
--osm.lane-access true --osm.bike-access true\
--osm.all-attributes\
--osm.extra-attributes tunnel,highway,traffic_sign,bus:lanes,bus:lanes:forward,bus:lanes:backward,cycleway,cycleway:right,cycleway:left\
--proj "+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"\
--osm-files $< -o=$@
$p/berlin-$V-network.xml.gz: input/sumo.net.xml
$(sc) prepare network-from-sumo $< --target-crs $(CRS) --lane-restrictions REDUCE_CAR_LANES --output $@
$(sc) prepare clean-network $@ --output $@ --modes car,ride,truck --remove-turn-restrictions
$(sc) prepare reproject-network\
--input $@ --output $@\
--input-crs $(CRS) --target-crs $(CRS)\
--mode truck=freight\
$(sc) prepare apply-network-params freespeed capacity\
--network $@ --output $@\
--input-features $p/berlin-$V-network-ft.csv.gz\
--model org.matsim.prepare.network.BerlinNetworkParams
$(sc) prepare apply-network-params capacity\
--network $@ --output $@\
--input-features $p/berlin-$V-network-ft.csv.gz\
--road-types residential,living_street\
--capacity-bounds 0.3\
--model org.matsim.application.prepare.network.params.hbs.HBSNetworkParams\
--decrease-only
$p/berlin-$V-network-with-pt.xml.gz: $p/berlin-$V-network.xml.gz
$(sc) prepare transit-from-gtfs --network $< --output=$p\
--name berlin-$V --date "2023-06-07" --target-crs $(CRS) \
$(germany)/gtfs/complete-pt-2023-06-06.zip\
--shp $p/pt-area/pt-area.shp
$p/berlin-$V-counts-vmz.xml.gz: $p/berlin-$V-network.xml.gz
$(sc) prepare counts-from-vmz\
--excel ../shared-svn/projects/matsim-berlin/berlin-v5.5/original_data/vmz_counts_2018/Datenexport_2018_TU_Berlin.xlsx\
--network $<\
--network-geometries $p/berlin-$V-network-linkGeometries.csv\
--output $@\
--input-crs EPSG:31468\
--target-crs $(CRS)\
--counts-mapping input/counts_mapping.csv
$p/berlin-$V-facilities.xml.gz: $p/berlin-$V-network.xml.gz input/facilities.gpkg
$(sc) prepare facilities --network $< --shp $(word 2,$^)\
--output $@
$p/berlin-only-$V-25pct.plans.xml.gz: input/PLR_2013_2020.csv $(berlin)/input/shp/Planungsraum_EPSG_25833.shp input/facilities.gpkg
$(sc) prepare berlin-population\
--input $<\
--shp $(word 2,$^) --shp-crs EPSG:25833\
--facilities $(word 3,$^) --facilities-attr resident\
--output $@
$p/brandenburg-only-$V-25pct.plans.xml.gz: input/facilities.gpkg
$(sc) prepare brandenburg-population\
--shp $(germany)/vg5000/vg5000_ebenen_0101/VG5000_GEM.shp\
--population $(germany)/regionalstatistik/population.csv\
--employees $(germany)/regionalstatistik/employed.json\
--facilities $< --facilities-attr resident\
--output $@
$p/berlin-static-$V-25pct.plans.xml.gz: $p/berlin-only-$V-25pct.plans.xml.gz $p/brandenburg-only-$V-25pct.plans.xml.gz
$(sc) prepare merge-populations $^\
--output $@
$(sc) prepare lookup-regiostar --input $@ --output $@ --xls $(germany)/RegioStaR-Referenzdateien.xlsx
$p/berlin-activities-$V-25pct.plans.xml.gz: $p/berlin-static-$V-25pct.plans.xml.gz $p/berlin-$V-facilities.xml.gz $p/berlin-$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 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,$^)\
$p/berlin-initial-$V-25pct.plans.xml.gz: $p/berlin-activities-$V-25pct.plans.xml.gz $p/berlin-$V-facilities.xml.gz $p/berlin-$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.03 0.01\
$p/berlin-longHaulFreight-$V-25pct.plans.xml.gz: $p/berlin-$V-network.xml.gz
$(sc) prepare extract-freight-trips ../public-svn/matsim/scenarios/countries/de/german-wide-freight/v2/german_freight.25pct.plans.xml.gz\
--network ../public-svn/matsim/scenarios/countries/de/german-wide-freight/v2/germany-europe-network.xml.gz\
--input-crs $(CRS)\
--target-crs $(CRS)\
--shp $p/area/area.shp\
--cut-on-boundary\
--output $@
$p/commercialFacilities.xml.gz:
$(sc) prepare create-data-distribution-of-structure-data\
--outputFacilityFile $@\
--outputDataDistributionFile $p/dataDistributionPerZone.csv\
--landuseConfiguration useOSMBuildingsAndLanduse\
--regionsShapeFileName $(berlin)/input/shp/region_4326.shp\
--regionsShapeRegionColumn "GEN"\
--zoneShapeFileName $(berlin)/input/shp/berlinBrandenburg_Zones_VKZ_4326.shp\
--zoneShapeFileNameColumn "id"\
--buildingsShapeFileName $(berlin)/input/shp/buildings_BerlinBrandenburg_4326.shp\
--shapeFileBuildingTypeColumn "type"\
--landuseShapeFileName $(berlin)/input/shp/berlinBrandenburg_landuse_4326.shp\
--shapeFileLanduseTypeColumn "fclass"\
--shapeCRS "EPSG:4326"\
--pathToInvestigationAreaData input/commercialTrafficAreaData.csv
$p/berlin-small-scale-commercialTraffic-$V-25pct.plans.xml.gz: $p/berlin-$V-network.xml.gz $p/commercialFacilities.xml.gz
$(sc) prepare generate-small-scale-commercial-traffic\
input/$V/berlin-$V.config.xml\
--pathToDataDistributionToZones $p/dataDistributionPerZone.csv\
--pathToCommercialFacilities $(notdir $(word 2,$^))\
--sample 0.25\
--jspritIterations 10\
--creationOption createNewCarrierFile\
--network $(notdir $<)\
--smallScaleCommercialTrafficType completeSmallScaleCommercialTraffic\
--zoneShapeFileName $(berlin)/input/shp/berlinBrandenburg_Zones_VKZ_4326.shp\
--zoneShapeFileNameColumn "id"\
--shapeCRS "EPSG:4326"\
--numberOfPlanVariantsPerAgent 5\
--nameOutputPopulation $(notdir $@)\
--pathOutput output/commercialPersonTraffic
mv output/commercialPersonTraffic/$(notdir $@) $@
$p/berlin-cadyts-input-$V-25pct.plans.xml.gz: $p/berlin-initial-$V-25pct.plans.xml.gz $p/berlin-small-scale-commercialTraffic-$V-25pct.plans.xml.gz
$(sc) prepare merge-populations $^\
--output $@
# This file requires eval runs
$p/berlin-initial-$V-25pct.experienced_plans.xml.gz:
$(sc) prepare merge-plans output/exp-*/*.output_experienced_plans.xml.gz\
--output $@
# Only for debugging
$(sc) prepare downsample-population $@\
--sample-size 0.25\
--samples 0.05 0.01\
ERROR_METRIC ?= log_error
eval-opt: $p/berlin-initial-$V-25pct.experienced_plans.xml.gz
$(sc) prepare run-count-opt\
--input $<\
--network $p/berlin-$V-network-with-pt.xml.gz\
--counts $p/berlin-$V-counts-vmz.xml.gz\
--output $p/berlin-$V-25pct.plans_selection_$(ERROR_METRIC).csv\
--metric $(ERROR_METRIC)
$(sc) prepare select-plans-idx\
--input $p/berlin-cadyts-input-$V-25pct.plans.xml.gz\
--csv $p/berlin-$V-25pct.plans_selection_$(ERROR_METRIC).csv\
--output $p/berlin-$V-25pct.plans_$(ERROR_METRIC).xml.gz
$(sc) run --mode "routeChoice" --iterations 20 --all-car --output "output/eval-$(ERROR_METRIC)" --25pct --population "berlin-$V-25pct.plans_$(ERROR_METRIC).xml.gz"\
--config $p/berlin-$V.config.xml
$p/berlin-$V-25pct.plans_cadyts.xml.gz:
$(sc) prepare extract-plans-idx\
--input output/cadyts/cadyts.output_plans.xml.gz\
--output $p/berlin-$V-25pct.plans_selection_cadyts.csv
$(sc) prepare select-plans-idx\
--input $p/berlin-cadyts-input-$V-25pct.plans.xml.gz\
--csv $p/berlin-$V-25pct.plans_selection_cadyts.csv\
--output $@
# These depend on the output of optimization runs
$p/berlin-$V-25pct.plans-initial.xml.gz: $p/berlin-$V-facilities.xml.gz $p/berlin-$V-network.xml.gz $p/berlin-longHaulFreight-$V-25pct.plans.xml.gz
$(sc) prepare filter-relevant-agents\
--input $p/berlin-$V-25pct.plans_log_error.xml.gz --output $@\
--shp input/$V/area/area.shp\
--facilities $<\
--network $(word 2,$^)
$(sc) prepare split-activity-types-duration\
--exclude commercial_start,commercial_end,freight_start,freight_end\
--input $@ --output $@
$(sc) prepare set-car-avail --input $@ --output $@
$(sc) prepare check-car-avail --input $@ --output $@ --mode walk
$(sc) prepare fix-subtour-modes --input $@ --output $@ --coord-dist 100
$(sc) prepare merge-populations $@ $(word 3,$^)\
--output $@
$(sc) prepare downsample-population $@\
--sample-size 0.25\
--samples 0.1 0.03 0.01 0.001\
$p/berlin-$V-10pct.plans.xml.gz:
$(sc) prepare clean-population\
--plans mode-choice-10pct-default-v2/runs/008/008.output_plans.xml.gz\
--remove-unselected-plans\
--output $@
$(sc) prepare downsample-population $@\
--sample-size 0.1\
--samples 0.03 0.01 0.001\
$p/berlin-$V.drt-by-rndLocations-10000vehicles-4seats.xml.gz: $p/berlin-$V-network.xml.gz
$(sc) prepare create-drt-vehicles\
--network $<\
--shp "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/berlin-$V/input/shp/Berlin_25832.shp"\
--output $p/berlin-$V.\
--vehicles 10000\
--seats 4
prepare-calibration: $p/berlin-cadyts-input-$V-25pct.plans.xml.gz $p/berlin-$V-network-with-pt.xml.gz $p/berlin-$V-counts-vmz.xml.gz
echo "Done"
prepare-initial: $p/berlin-$V-25pct.plans-initial.xml.gz $p/berlin-$V-network-with-pt.xml.gz
echo "Done"
prepare-drt: $p/berlin-$V.drt-by-rndLocations-10000vehicles-4seats.xml.gz
echo "Done"
prepare: $p/berlin-$V-10pct.plans.xml.gz
echo "Done"