forked from matsim-scenarios/matsim-leipzig
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
184 lines (156 loc) · 8.41 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
JAR := matsim-leipzig-*.jar
V := v1.2
CRS := EPSG:25832
MEMORY ?= 20G
export SUMO_HOME ?= $(abspath ../../sumo-1.8.0/)
osmosis := osmosis/bin/osmosis
NETWORK := germany-220327.osm.pbf
germany := ../shared-svn/projects/matsim-germany
shared ?= ../shared-svn/projects/NaMAV
.PHONY: prepare
# Scenario creation tool
sc := java -Xmx$(MEMORY) -jar $(JAR)
$(JAR):
mvn package
# Required files
$(germany)/maps/$(NETWORK):
curl https://download.geofabrik.de/europe/$(NETWORK)\
-o scenarios/input/network.osm.pbf
input/gtfs-lvb.zip:
curl https://opendata.leipzig.de/dataset/8803f612-2ce1-4643-82d1-213434889200/resource/b38955c4-431c-4e8b-a4ef-9964a3a2c95d/download/gtfsmdvlvb.zip\
-o $@
input/network.osm: $(germany)/maps/$(NETWORK)
#osmosisi is an osm tool, that allows to cut out the detailed network, there are 3 levels of detail
# detailed inside the study area, this is only Leipzig with a small buffer
$(osmosis) --rb file=$<\
--tf accept-ways bicycle=yes highway=motorway,motorway_link,trunk,trunk_link,primary,primary_link,secondary_link,secondary,tertiary,motorway_junction,residential,unclassified,living_street\
--bounding-box top=51.457 left=12.137 bottom=51.168 right=12.703\
--used-node --wb network-detailed.osm.pbf
# coarse outside the study area
$(osmosis) --rb file=$<\
--tf accept-ways highway=motorway,motorway_link,trunk,trunk_link,primary,primary_link,secondary_link,secondary,tertiary,motorway_junction\
--bounding-box top=51.92 left=11.45 bottom=50.83 right=13.36\
--used-node --wb network-coarse.osm.pbf
# rest of germany
$(osmosis) --rb file=$<\
--tf accept-ways highway=motorway,motorway_link,motorway_junction,trunk,trunk_link,primary,primary_link\
--used-node --wb network-germany.osm.pbf
# remove railways as this causes problems with the SUMO converter
$(osmosis) --rb file=network-germany.osm.pbf --rb file=network-coarse.osm.pbf --rb file=network-detailed.osm.pbf\
--merge --merge\
--tag-transform file=input/remove-railway.xml\
--wx $@
rm network-detailed.osm.pbf
rm network-coarse.osm.pbf
rm network-germany.osm.pbf
# here a sumo network is created, the default options from Sumo are used or advised
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,bicycle --remove-edges.by-type highway.track,highway.services,highway.unsurfaced\
--remove-edges.by-vclass hov,tram,rail,rail_urban,rail_fast,pedestrian\
--output.original-names --output.street-names\
--proj "+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"\
--osm-files $< -o=$@
#create a masim network based on the sumo network, free speed factor is based on experiments derived from a paper:
#Christan Rakow ABMTrans Road network free flow speed estimation using microscopic
input/$V/leipzig-$V-network.xml.gz: input/sumo.net.xml
$(sc) prepare network-from-sumo $< --output $@ --free-speed-factor 0.75
$(sc) prepare fix-network $@ --output $@
$(sc) prepare clean-network $@ --output $@ --modes bike
# create transit schedule from gtfs dataset
input/$V/leipzig-$V-network-with-pt.xml.gz: input/$V/leipzig-$V-network.xml.gz input/gtfs-lvb.zip
$(sc) prepare transit-from-gtfs --network $< $(filter-out $<,$^)\
--name leipzig-$V --date "2023-04-19" --target-crs $(CRS)\
--output input/$V
$(sc) prepare prepare-transit-schedule\
--input input/$V/leipzig-$V-transitSchedule.xml.gz\
--output input/$V/leipzig-$V-transitSchedule.xml.gz\
--shp $(shared)/data/shapefiles/leipzig-utm32n/leipzig-utm32n.shp
input/plans-longHaulFreight.xml.gz: input/$V/leipzig-$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 ../shared-svn/projects/NaMAV/data/shapefiles/freight-area/freight-area.shp\
--cut-on-boundary\
--output $@
input/plans-completeSmallScaleCommercialTraffic.xml.gz:
$(sc) prepare generate-small-scale-commercial-traffic\
input/commercialTraffic\
--sample 0.25\
--jspritIterations 1\
--creationOption createNewCarrierFile\
--landuseConfiguration useOSMBuildingsAndLanduse\
--smallScaleCommercialTrafficType completeSmallScaleCommercialTraffic\
--zoneShapeFileName $(shared)/data/input-commercialTraffic/leipzig_zones_25832.shp\
--buildingsShapeFileName $(shared)/data/input-commercialTraffic/leipzig_buildings_25832.shp\
--landuseShapeFileName $(shared)/data/input-commercialTraffic/leipzig_landuse_25832.shp\
--shapeCRS "EPSG:25832"\
--resistanceFactor "0.005"\
--nameOutputPopulation $(notdir $@)\
--pathOutput output/commercialTraffic
mv output/commercialTraffic/$(notdir $@) $@
input/$V/leipzig-$V-25pct.plans-initial.xml.gz: input/plans-longHaulFreight.xml.gz input/plans-completeSmallScaleCommercialTraffic.xml.gz
# remove modes etc. from the SNZ plans. max-typ-dur=0 means activity types are kept. sample size is _input_ sample size.
$(sc) prepare trajectory-to-plans\
--name prepare --sample-size 0.25\
--max-typical-duration 0\
--output input/\
--population $(shared)/matsim-input-files/senozon/20210520_leipzig/population.xml.gz\
--attributes $(shared)/matsim-input-files/senozon/20210520_leipzig/personAttributes.xml.gz
$(sc) prepare population input/prepare-25pct.plans.xml.gz --phase pre\
--shp $(shared)/matsim-input-files/senozon/20210520_leipzig/dilutionArea.shp --shp-crs $(CRS)\
--output input/prepare-25pct.plans.xml.gz
# everything from SNZ comes on grid. we randomize into the grid cells:
$(sc) prepare resolve-grid-coords input/prepare-25pct.plans.xml.gz\
--input-crs $(CRS)\
--grid-resolution 300\
--landuse $(germany)/landuse/landuse.shp\
--output input/prepare-25pct.plans.xml.gz
# SNZ has problems with short trips since cells are too small. This generations additional trips in some (yyyy which one???) distance class. The number of short trips comes from yyyy ???.
$(sc) prepare generate-short-distance-trips\
--population input/prepare-25pct.plans.xml.gz\
--input-crs $(CRS)\
--shp $(shared)/data/shapefiles/leipzig-utm32n/leipzig-utm32n.shp --shp-crs $(CRS)\
--num-trips 67395
# this is needed as we have a very coarse network outside the study area and agents should not have very long access or egress walks
$(sc) prepare adjust-activity-to-link-distances input/prepare-25pct.plans-with-trips.xml.gz\
--shp $(shared)/data/shapefiles/leipzig-utm32n/leipzig-utm32n.shp --shp-crs $(CRS)\
--scale 1.15\
--input-crs $(CRS)\
--network input/$V/leipzig-$V-network.xml.gz\
--output input/prepare-25pct.plans-adj.xml.gz
# as the call of this in prepare trajectory-to-plans is deprecated we call this explity here
$(sc) prepare split-activity-types-duration\
--input input/prepare-25pct.plans-with-trips.xml.gz\
--exclude commercial_start,commercial_end,freight_start,freight_end\
--output $@
$(sc) prepare merge-populations $@ $^ --output $@
# see class comment
$(sc) prepare population $@ --phase post\
--shp $(shared)/matsim-input-files/senozon/20210520_leipzig/dilutionArea.shp --shp-crs $(CRS)\
--output $@
# we added trips and so on so we need to ensure plans are consistent with subTourModeChoice
$(sc) prepare fix-subtour-modes --input $@ --coord-dist 100 --output $@
$(sc) prepare extract-home-coordinates $@ --csv input/$V/leipzig-$V-homes.csv
$(sc) prepare downsample-population $@\
--sample-size 0.25\
--samples 0.1 0.01 0.001\
counts:
java -cp $(JAR) org.matsim.run.prepare.CreatingCountsFromZaehldaten\
--network input/leipzig-$V-network.xml.gz\
--excel $(shared)/NaMAV/data/Zaehldaten/Zaehldaten.xlsx\
-i input/ignored_counts.csv -m input/manuallyMatsimLinkShift.csv\
--output input/$V/leipzig-$V-counts
check: input/$V/leipzig-$V-25pct.plans-initial.xml.gz
$(sc) analysis check-population $<\
--input-crs $(CRS)\
--attribute carAvail\
--shp ../shared-svn/projects/NaMAV/data/shapefiles/leipzig-utm32n/leipzig-utm32n.shp\
# Aggregated target
prepare: input/$V/leipzig-$V-25pct.plans-initial.xml.gz input/$V/leipzig-$V-network-with-pt.xml.gz
echo "Done"