Skip to content

Commit

Permalink
added BerlinBrandenburg.mk to create Brandenburg scenario. Updated Co…
Browse files Browse the repository at this point in the history
…nvertPersonAttributes to work w/ Unix.
  • Loading branch information
jakobrehmann committed Jun 25, 2024
1 parent 1390a01 commit 3939ba1
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
WD := ../shared-svn/projects/episim/matsim-files

# All available Scenarios
ALL := BerlinWeek MunichWeek
ALL := BerlinBrandenburg

JAR := matsim-episim-*.jar
# Shortcut to the scenario creation tool
sc = java -Xmx20G -cp $(JAR) org.matsim.run.ScenarioCreation
sc = java -Xmx30G -cp $(JAR) org.matsim.run.ScenarioCreation

.PHONY: all clean $(ALL)

Expand All @@ -24,7 +24,7 @@ clean:

# Includes all the scenarios with local variables
# https://stackoverflow.com/questions/32904790/can-i-have-local-variables-in-included-makefiles
SUBDIRS := scenarios/Cologne.mk
SUBDIRS := scenarios/BerlinBrandenburg.mk
define INCLUDE_FILE
path = $S
include $S
Expand Down
160 changes: 160 additions & 0 deletions scenarios/BerlinBrandenburg.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# To run this, you need a newer version of make. 4.4.1 works (in macOS under the command of gmake)
# To run, execute "gmake BerlinBrandenburg" in terminal
in = $(WD)/snz/BerlinBrandenburg/original-data
out = $(WD)/snz/BerlinBrandenburg/episim-input
tmp = $(WD)/snz/BerlinBrandenburg/processed-data

BerlinBrandenburg: $(JAR) $(out)/bb_2020-week_snz_episim_events_wt_25pt_split.xml.gz $(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_25pt_split.xml.gz \
$(out)/bb_2020-week_snz_episim_events_wt_100pt_split.xml.gz $(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt_split.xml.gz
echo "Building Berlin Brandenburg Week scenario"

BerlinBrandenburgSamples: $(JAR) $(out)/samples/bb_2020-week_snz_episim_events_wt_10pt_split.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_wt_5pt_split.xml.gz \
$(out)/samples/bb_2020-week_snz_episim_events_wt_1pt_split.xml.gz
echo "Building Berlin Brandenburg Week samples"

$(tmp)/personIds.diluted.txt.gz:
$(sc) filterPersons $(in)/de2020gsmwt_events_reduced.xml.gz\
--facilities $(in)/facilities_assigned_simplified.xml.gz\
--attributes $(in)/populationAttributes.xml.gz\
--shape-file $(out)/shape-File/BerlinBrandenburg.shp\
--shape-crs EPSG:25833\
--output $@



$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_100pt.xml.gz: $(tmp)/personIds.diluted.txt.gz
$(sc) convertPersonAttributes $(in)/populationAttributes.xml.gz\
--ids $<\
--requireAttribute "microm:modeled:age"\
--output $@

$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt.xml.gz: $(out)/bb_2020-week_snz_entirePopulation_emptyPlans_100pt.xml.gz
$(sc) districtLookup $<\
--output $@\
--shp ../public-svn/matsim/scenarios/countries/de/episim/original-data/landkreise-in-germany/landkreise-in-germany.shp

########
# 25pct
########

$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_25pt.xml.gz $(out)/bb_2020-week_snz_episim_events_wt_25pt.xml.gz &: \
$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt.xml.gz
$(sc) downSample 0.25\
--population $<\
--events $(in)/de2020gsmwt_events_reduced.xml.gz\
--events $(in)/de2020gsmsa_events_reduced.xml.gz\
--events $(in)/de2020gsmso_events_reduced.xml.gz\
--output $(tmp)

mv $(tmp)/population0.25.xml.gz $(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_25pt.xml.gz
mv $(tmp)/de2020gsmwt_events_reduced-0.25.xml.gz $(out)/bb_2020-week_snz_episim_events_wt_25pt.xml.gz
mv $(tmp)/de2020gsmsa_events_reduced-0.25.xml.gz $(out)/bb_2020-week_snz_episim_events_sa_25pt.xml.gz
mv $(tmp)/de2020gsmso_events_reduced-0.25.xml.gz $(out)/bb_2020-week_snz_episim_events_so_25pt.xml.gz

$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_25pt_split.xml.gz $(out)/bb_2020-week_snz_episim_events_wt_25pt_split.xml.gz &: \
$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_25pt.xml.gz $(out)/bb_2020-week_snz_episim_events_wt_25pt.xml.gz
$(sc) splitHomeFacilities $<\
--events $(out)/bb_2020-week_snz_episim_events_wt_25pt.xml.gz\
--events $(out)/bb_2020-week_snz_episim_events_sa_25pt.xml.gz\
--events $(out)/bb_2020-week_snz_episim_events_so_25pt.xml.gz\
--shape-file $(out)/../shape-File/BerlinBrandenburg.shp\
--output $(out)

$(out)/wLeisure/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_25pt_split.xml.gz $(out)/wLeisure/bb_2020-week_snz_episim_events_wt_25pt_split.xml.gz &: \
$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_25pt.xml.gz $(out)/bb_2020-week_snz_episim_events_wt_25pt.xml.gz
$(sc) splitHomeFacilities $<\
--events $(out)/bb_2020-week_snz_episim_events_wt_25pt.xml.gz\
--events $(out)/bb_2020-week_snz_episim_events_sa_25pt.xml.gz\
--events $(out)/bb_2020-week_snz_episim_events_so_25pt.xml.gz\
--shape-file $(out)/../shape-File/dilutionArea.shp\
--remap visit --remap leisure\
--output $(out)/wLeisure

###########
# 100 pct
###########

$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt_filtered.xml.gz $(out)/bb_2020-week_snz_episim_events_wt_100pt.xml.gz &: \
$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt.xml.gz
$(sc) downSample 1.0\
--population $<\
--events $(in)/de2020gsmwt_events_reduced.xml.gz\
--events $(in)/de2020gsmsa_events_reduced.xml.gz\
--events $(in)/de2020gsmso_events_reduced.xml.gz\
--output $(tmp)

mv $(tmp)/population1.0.xml.gz $(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt_filtered.xml.gz
mv $(tmp)/de2020gsmwt_events_reduced-1.0.xml.gz $(out)/bb_2020-week_snz_episim_events_wt_100pt.xml.gz
mv $(tmp)/de2020gsmsa_events_reduced-1.0.xml.gz $(out)/bb_2020-week_snz_episim_events_sa_100pt.xml.gz
mv $(tmp)/de2020gsmso_events_reduced-1.0.xml.gz $(out)/bb_2020-week_snz_episim_events_so_100pt.xml.gz

$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt_split.xml.gz $(out)/bb_2020-week_snz_episim_events_wt_100pt_split.xml.gz &: \
$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt_filtered.xml.gz $(out)/bb_2020-week_snz_episim_events_wt_100pt.xml.gz
$(sc) splitHomeFacilities $<\
--events $(out)/bb_2020-week_snz_episim_events_wt_100pt.xml.gz\
--events $(out)/bb_2020-week_snz_episim_events_sa_100pt.xml.gz\
--events $(out)/bb_2020-week_snz_episim_events_so_100pt.xml.gz\
--shape-file $(out)/../shape-File/dilutionArea.shp\
--output $(out)

#################
# 10pct 5pct 1pct
#################


$(out)/samples/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_10pt.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_wt_10pt.xml.gz &: \
$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt.xml.gz
$(sc) downSample 0.1\
--population $<\
--events $(in)/de2020gsmwt_events_reduced.xml.gz\
--events $(in)/de2020gsmsa_events_reduced.xml.gz\
--events $(in)/de2020gsmso_events_reduced.xml.gz\
--output $(tmp)

mkdir $(out)/samples

mv $(tmp)/population0.1.xml.gz $(out)/samples//bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_10pt.xml.gz
mv $(tmp)/de2020gsmwt_events_reduced-0.1.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_wt_10pt.xml.gz
mv $(tmp)/de2020gsmsa_events_reduced-0.1.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_sa_10pt.xml.gz
mv $(tmp)/de2020gsmso_events_reduced-0.1.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_so_10pt.xml.gz


$(out)/samples/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_5pt_split.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_wt_5pt_split.xml.gz &: \
$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt.xml.gz
$(sc) downSample 0.05\
--population $<\
--events $(in)/de2020gsmwt_events_reduced.xml.gz\
--events $(in)/de2020gsmsa_events_reduced.xml.gz\
--events $(in)/de2020gsmso_events_reduced.xml.gz\
--output $(tmp)

mkdir $(out)/samples
mv $(tmp)/population0.05.xml.gz $(out)/samples//bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_5pt_split.xml.gz
mv $(tmp)/de2020gsmwt_events_reduced-0.05.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_wt_5pt_split.xml.gz
mv $(tmp)/de2020gsmsa_events_reduced-0.05.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_sa_5pt_split.xml.gz
mv $(tmp)/de2020gsmso_events_reduced-0.05.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_so_5pt_split.xml.gz

$(out)/samples/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_1pt_split.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_wt_1pt_split.xml.gz &: \
$(out)/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_100pt.xml.gz
$(sc) downSample 0.01\
--population $<\
--events $(in)/de2020gsmwt_events_reduced.xml.gz\
--events $(in)/de2020gsmsa_events_reduced.xml.gz\
--events $(in)/de2020gsmso_events_reduced.xml.gz\
--output $(tmp)

mkdir $(out)/samples
mv $(tmp)/population0.01.xml.gz $(out)/samples//bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_1pt_split.xml.gz
mv $(tmp)/de2020gsmwt_events_reduced-0.01.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_wt_1pt_split.xml.gz
mv $(tmp)/de2020gsmsa_events_reduced-0.01.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_sa_1pt_split.xml.gz
mv $(tmp)/de2020gsmso_events_reduced-0.01.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_so_1pt_split.xml.gz


$(out)/samples/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_10pt_split.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_wt_10pt_split.xml.gz &: \
$(out)/samples/bb_2020-week_snz_entirePopulation_emptyPlans_withDistricts_10pt.xml.gz $(out)/samples/bb_2020-week_snz_episim_events_wt_10pt.xml.gz
$(sc) splitHomeFacilities $<\
--events $(out)/samples/bb_2020-week_snz_episim_events_wt_10pt.xml.gz\
--events $(out)/samples/bb_2020-week_snz_episim_events_sa_10pt.xml.gz\
--events $(out)/samples/bb_2020-week_snz_episim_events_so_10pt.xml.gz\
--shape-file $(out)/../shape-File/dilutionArea.shp\
--output $(out)/samples
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public Integer call() throws Exception {
String attributesFileForConversion = input.toString();
if (personIds != null) {
String outputPath = output.toAbsolutePath().toString();
attributesFileForConversion = outputPath.substring(0, outputPath.lastIndexOf('\\')) + "/filtered_" + input.getFileName();
attributesFileForConversion = outputPath.substring(0, outputPath.lastIndexOf('/')) + "/filtered_" + input.getFileName();
new ObjectAttributesXmlWriter(attributes).writeFile(attributesFileForConversion);
}

Expand Down

0 comments on commit 3939ba1

Please sign in to comment.