Skip to content

Commit

Permalink
update matsim version
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Oct 24, 2023
1 parent f8014d9 commit 71a2b44
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 93 deletions.
98 changes: 49 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
N := lausitz
V := v1.0
CRS := EPSG:25832

JAR := matsim-$(N)-*.jar

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

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

.PHONY: prepare
MEMORY ?= 20G
SUMO_HOME ?= $(abspath ../../sumo-1.18.0/)
NETWORK := $(germany)/maps/germany-230101.osm.pbf

#$(JAR):
# mvn package
# Scenario creation tool
sc := java -Xmx$(MEMORY) -XX:+UseParallelGC -jar $(JAR)

# Required files
input/network.osm.pbf:
curl https://download.geofabrik.de/europe/germany-230101.osm.pbf -o input/network.osm.pbf
.PHONY: prepare

# Bast count data
input/2019_A_S.zip:
Expand All @@ -30,16 +28,16 @@ input/2019_B_S.zip:
input/Jawe2019.csv:
curl "https://www.bast.de/DE/Verkehrstechnik/Fachthemen/v2-verkehrszaehlung/Daten/2019_1/Jawe2019.csv?view=renderTcDataExportCSV&cms_strTyp=A" -o $@

input/network.osm: input/network.osm.pbf
input/network.osm: $(NETWORK)

$(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-polygon file="../shared-svn/projects/DiTriMo/data/cottbus.poly"\
--bounding-polygon file="$(shared)/data/cottbus.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\
--bounding-polygon file="../shared-svn/projects/DiTriMo/data/lausitz.poly"\
--bounding-polygon file="$(shared)/data/lausitz.poly"\
--used-node --wb input/network-coarse.osm.pbf

$(osmosis) --rb file=$<\
Expand Down Expand Up @@ -71,93 +69,95 @@ input/sumo.net.xml: input/network.osm


input/$V/$N-$V-network.xml.gz: input/sumo.net.xml
java -jar $(JAR) prepare network-from-sumo $<\
--output $@

java -jar $(JAR) prepare clean-network $@ --output $@ --modes car --modes bike
$(sc) prepare network-from-sumo $< --output $@ --free-speed-factor 0.75
$(sc) prepare fix-network $@ --output $@
$(sc) prepare clean-network $@ --output $@ --modes car --modes bike


input/$V/$N-$V-network-with-pt.xml.gz: input/$V/$N-$V-network.xml.gz
java -Xmx20G -jar $(JAR) prepare transit-from-gtfs --network $<\
$(sc) prepare transit-from-gtfs --network $<\
--output=input/$V\
--name $N-$V --date "2023-01-11" --target-crs $(CRS) \
../shared-svn/projects/DiTriMo/data/gtfs/20230113_regio.zip\
../shared-svn/projects/DiTriMo/data/gtfs/20230113_train_short.zip\
../shared-svn/projects/DiTriMo/data/gtfs/20230113_train_long.zip\
$(shared)/data/gtfs/20230113_regio.zip\
$(shared)/data/gtfs/20230113_train_short.zip\
$(shared)/data/gtfs/20230113_train_long.zip\
--prefix regio_,short_,long_\
--shp ../shared-svn/projects/DiTriMo/data/network-area/network-area.shp\
--shp ../shared-svn/projects/DiTriMo/data/network-area/network-area.shp\
--shp ../shared-svn/projects/DiTriMo/data/germany-area/germany-area.shp\

input/freight-trips.xml.gz: input/$V/$N-$V-network.xml.gz
java -jar $(JAR) prepare extract-freight-trips ../shared-svn/projects/german-wide-freight/v1.2.1/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\
--shp $(shared)/data/network-area/network-area.shp\
--shp $(shared)/data/network-area/network-area.shp\
--shp $(shared)/data/germany-area/germany-area.shp\

input/plans-longHaulFreight.xml.gz: input/$V/$N-$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/DiTriMo/data/shp/$N.shp --shp-crs $(CRS)\
--shp $(shared)/data/shp/$N.shp --shp-crs $(CRS)\
--cut-on-boundary\
--output $@

input/$V/prepare-100pct.plans.xml.gz:
java -jar $(JAR) prepare trajectory-to-plans\
$(sc) prepare trajectory-to-plans\
--name prepare --sample-size 1 --output input/$V\
--population ../shared-svn/projects/DiTriMo/matsim-input-files/senozon/20230111_teilmodell_lausitz/population.xml.gz\
--attributes ../shared-svn/projects/DiTriMo/matsim-input-files/senozon/20230111_teilmodell_lausitz/additionalPersonAttributes.xml.gz
--population $(shared)/matsim-input-files/senozon/20230111_teilmodell_lausitz/population.xml.gz\
--attributes $(shared)/matsim-input-files/senozon/20230111_teilmodell_lausitz/additionalPersonAttributes.xml.gz

java -jar $(JAR) prepare resolve-grid-coords\
$(sc) prepare resolve-grid-coords\
input/$V/prepare-100pct.plans.xml.gz\
--input-crs $(CRS)\
--grid-resolution 300\
--landuse ../shared-svn/projects/matsim-germany/landuse/landuse.shp\
--output $@

input/$V/$N-$V-100pct.plans.xml.gz: input/freight-trips.xml.gz input/$V/prepare-100pct.plans.xml.gz
input/$V/$N-$V-100pct.plans.xml.gz: input/plans-longHaulFreight.xml.gz input/$V/prepare-100pct.plans.xml.gz

java -jar $(JAR) prepare generate-short-distance-trips\
$(sc) prepare generate-short-distance-trips\
--population input/$V/prepare-100pct.plans.xml.gz\
--input-crs $(CRS)\
--shp ../shared-svn/projects/DiTriMo/data/shp/$N.shp --shp-crs $(CRS)\
--shp $(shared)/data/shp/$N.shp --shp-crs $(CRS)\
--num-trips 1 # TODO

java -jar $(JAR) prepare adjust-activity-to-link-distances input/$V/prepare-100pct.plans-with-trips.xml.gz\
--shp ../shared-svn/projects/DiTriMo/data/shp/$N.shp --shp-crs $(CRS)\
$(sc) prepare adjust-activity-to-link-distances input/$V/prepare-100pct.plans-with-trips.xml.gz\
--shp $(shared)/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-100pct.plans-adj.xml.gz

java -jar $(JAR) prepare fix-subtour-modes --coord-dist 100 --input input/$V/prepare-100pct.plans-adj.xml.gz --output $@
$(sc) prepare fix-subtour-modes --coord-dist 100 --input input/$V/prepare-100pct.plans-adj.xml.gz --output $@

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

java -jar $(JAR) prepare merge-populations $@ $< --output $@
# TODO: set home coordinates attributes

java -jar $(JAR) prepare extract-home-coordinates $@ --csv input/$V/$N-$V-homes.csv
$(sc) prepare extract-home-coordinates $@ --csv input/$V/$N-$V-homes.csv

java -jar $(JAR) prepare downsample-population $@\
$(sc) prepare downsample-population $@\
--sample-size 1\
--samples 0.25 0.01\

input/$V/$N-$V-counts-car-bast.xml.gz: input/2019_A_S.zip input/2019_B_S.zip input/Jawe2019.csv input/$V/$N-$V-network-with-pt.xml.gz

java -Xmx20G -jar $(JAR) prepare counts-from-bast\
$(sc) prepare counts-from-bast\
--network input/$V/$N-$V-network-with-pt.xml.gz\
--motorway-data input/2019_A_S.zip\
--primary-data input/2019_B_S.zip\
--station-data input/Jawe2019.csv\
--year 2019\
--shp ../shared-svn/projects/DiTriMo/data/shp/$N.shp --shp-crs $(CRS)\
--shp $(shared)/data/shp/$N.shp --shp-crs $(CRS)\
--car-output $@\
--freight-output $(subst car,freight,$@)

check: input/$V/$N-$V-100pct.plans.xml.gz
java -jar $(JAR) analysis commuter\
$(sc) analysis commuter\
--population $<\
--input-crs $(CRS)\
--shp ../shared-svn/projects/matsim-germany/vg5000/vg5000_ebenen_0101/VG5000_GEM.shp\
--attr ARS\
--output input/$V/$N-$V-commuter.csv

java -jar $(JAR) analysis check-population $<\
$(sc) analysis check-population $<\
--input-crs $(CRS)\
--shp ../shared-svn/projects/DiTriMo/data/shp/$N.shp --shp-crs $(CRS)
--shp $(shared)/data/shp/$N.shp --shp-crs $(CRS)

# Aggregated target
prepare: input/$V/$N-$V-100pct.plans.xml.gz input/$V/$N-$V-network-with-pt.xml.gz input/$V/$N-$V-counts-car-bast.xml.gz
Expand Down
43 changes: 39 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!--<matsim.version>14.0-PR1452</matsim.version>-->

<!-- snapshot == not recommended: rather use PR-labelled release!-->
<version>15.0-SNAPSHOT</version>
<version>16.0-PR2888</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -65,6 +65,17 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>simwrapper</artifactId>
<version>${matsim.version}</version>
</dependency>
<dependency>
<groupId>org.matsim.contrib</groupId>
<artifactId>vsp</artifactId>
<version>${matsim.version}</version>
</dependency>


<!-- Custom dependencies -->
<dependency>
Expand All @@ -76,12 +87,16 @@
<groupId>org.matsim</groupId>
<artifactId>matsim</artifactId>
</exclusion>
<exclusion>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.7.1</version>
<version>2.7.2</version>
</dependency>

<!-- Test dependencies -->
Expand Down Expand Up @@ -122,7 +137,7 @@
<configuration>
<forkMode>once</forkMode>
<!-- avoid out of memory errors: -->
<argLine>@{argLine} -Xmx9500m -Djava.awt.headless=true -Dmatsim.preferLocalDtds=true</argLine>
<argLine>@{argLine} -Xmx6500m -Djava.awt.headless=true -Dmatsim.preferLocalDtds=true</argLine>
<!--necessary in tu berlin gitlab. BUT not good in other places, so solve by command line switch only where needed. kai, nov'18-->
<!--<useSystemClassLoader>false</useSystemClassLoader>-->
</configuration>
Expand All @@ -148,6 +163,25 @@
</executions>
</plugin>

<!-- Fetch Git information -->
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
</configuration>
</plugin>

<plugin>
<!-- The maven-shade-plugin replaces the maven-assembly-plugin to configure "mvn package". The assembly-plugin regularly-->
<!-- creates problems when GeoTools are used, which the shade-plugin does not (see-->
Expand All @@ -162,7 +196,7 @@
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${project.basedir}/${project.build.finalName}.jar</outputFile>
<outputFile>${project.basedir}/${project.build.finalName}-${git.commit.id.describe-short}.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 All @@ -171,6 +205,7 @@
<Specification-Vendor>org.matsim</Specification-Vendor>
<Implementation-Vendor>org.matsim</Implementation-Vendor>
<Implementation-Version>${project.version}</Implementation-Version>
<SCM-Revision>${git.commit.id.describe-short}</SCM-Revision>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
Expand Down
50 changes: 10 additions & 40 deletions src/main/java/org/matsim/run/RunLausitzScenario.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.matsim.run;

import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorModule;
import com.google.common.collect.Sets;
import org.matsim.analysis.ModeChoiceCoverageControlerListener;
import org.matsim.api.core.v01.Scenario;
Expand All @@ -9,7 +8,6 @@
import org.matsim.application.MATSimApplication;
import org.matsim.application.analysis.CheckPopulation;
import org.matsim.application.analysis.traffic.LinkStats;
import org.matsim.application.analysis.travelTimeValidation.TravelTimeAnalysis;
import org.matsim.application.options.SampleOptions;
import org.matsim.application.prepare.CreateLandUseShp;
import org.matsim.application.prepare.counts.CreateCountsFromBAStData;
Expand All @@ -18,17 +16,17 @@
import org.matsim.application.prepare.network.CreateNetworkFromSumo;
import org.matsim.application.prepare.population.*;
import org.matsim.application.prepare.pt.CreateTransitScheduleFromGtfs;
import org.matsim.contrib.vsp.scenario.SnzActivities;
import org.matsim.core.config.Config;
import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
import org.matsim.core.config.groups.PlansCalcRouteConfigGroup;
import org.matsim.core.config.groups.RoutingConfigGroup;
import org.matsim.core.config.groups.VspExperimentalConfigGroup;
import org.matsim.core.controler.AbstractModule;
import org.matsim.core.controler.Controler;
import org.matsim.run.analysis.CommuterAnalysis;
import org.matsim.simwrapper.SimWrapperModule;
import picocli.CommandLine;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;

@CommandLine.Command(header = ":: Open Lausitz Scenario ::", version = RunLausitzScenario.VERSION, mixinStandardHelpOptions = true)
Expand All @@ -39,7 +37,7 @@
CreateCountsFromBAStData.class
})
@MATSimApplication.Analysis({
TravelTimeAnalysis.class, LinkStats.class, CheckPopulation.class, CommuterAnalysis.class,
LinkStats.class, CheckPopulation.class, CommuterAnalysis.class,
})
public class RunLausitzScenario extends MATSimApplication {

Expand All @@ -66,43 +64,17 @@ public static void main(String[] args) {
protected Config prepareConfig(Config config) {

// Add all activity types with time bins
SnzActivities.addScoringParams(config);

for (long ii = 600; ii <= 97200; ii += 600) {

for (String act : List.of("home", "restaurant", "other", "visit", "errands", "accomp_other", "accomp_children",
"educ_higher", "educ_secondary", "educ_primary", "educ_tertiary", "educ_kiga", "educ_other")) {
config.planCalcScore()
.addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams(act + "_" + ii).setTypicalDuration(ii));
}

config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("work_" + ii).setTypicalDuration(ii)
.setOpeningTime(6. * 3600.).setClosingTime(20. * 3600.));
config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("business_" + ii).setTypicalDuration(ii)
.setOpeningTime(6. * 3600.).setClosingTime(20. * 3600.));
config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("leisure_" + ii).setTypicalDuration(ii)
.setOpeningTime(9. * 3600.).setClosingTime(27. * 3600.));

config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("shop_daily_" + ii).setTypicalDuration(ii)
.setOpeningTime(8. * 3600.).setClosingTime(20. * 3600.));
config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("shop_other_" + ii).setTypicalDuration(ii)
.setOpeningTime(8. * 3600.).setClosingTime(20. * 3600.));
}

config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("car interaction").setTypicalDuration(60));
config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("other").setTypicalDuration(600 * 3));

config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("freight_start").setTypicalDuration(60 * 15));
config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("freight_end").setTypicalDuration(60 * 15));

config.controler().setOutputDirectory(sample.adjustName(config.controler().getOutputDirectory()));
config.controller().setOutputDirectory(sample.adjustName(config.controller().getOutputDirectory()));
config.plans().setInputFile(sample.adjustName(config.plans().getInputFile()));
config.controler().setRunId(sample.adjustName(config.controler().getRunId()));
config.controller().setRunId(sample.adjustName(config.controller().getRunId()));

config.qsim().setFlowCapFactor(sample.getSize() / 100.0);
config.qsim().setStorageCapFactor(sample.getSize() / 100.0);

config.vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.info);
config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink);
config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink);

// TODO: Config options

Expand All @@ -123,21 +95,19 @@ protected void prepareScenario(Scenario scenario) {
link.setAllowedModes(newModes);
}
}

}

@Override
protected void prepareControler(Controler controler) {

controler.addOverridingModule(new SimWrapperModule());

controler.addOverridingModule(new AbstractModule() {
@Override
public void install() {
install(new SwissRailRaptorModule());

addControlerListenerBinding().to(ModeChoiceCoverageControlerListener.class);
addTravelTimeBinding(TransportMode.ride).to(networkTravelTime());
addTravelDisutilityFactoryBinding(TransportMode.ride).to(carTravelDisutilityFactoryKey());

}

});
Expand Down

0 comments on commit 71a2b44

Please sign in to comment.