Running Scenario
MATSim Run overview
Requirements
OpenJDK (11), or any JDK v.11+ (not 16)
Python 3.8
MATSim version 13.0+
Input files
pt-network-prague.xml.gz
- multi-modal network with mapped public transit (from OSM + GTFS)population.xml.gz
- population/plans (demand) file with daily plans of agentstransit-schedule.xml.gz
- schedule for public transit (from GTFS)transit-vehicles.xml.gz
- description of public transit vehicles (trams, buses, trains)vehicles.xml
- description of non-public vehicles (cars, bikes, ...)config.xml
- configuration file that defines inputs and other simulation parameters (see Config File page)
Running the Simulation
Clone the Metacity-MATSim repository
Optional: Import the matsim folder into an IDE as a Maven Project
Insert input data (MATSim input files: network.xml, plans.xml ... ) into
matsim/data/matsim-files/input
directoryMove into the
matsim
folder~~Run the downsampling of population if needed. The script samples the population xml file:
./downsample.sh 0.1
~~This step is moved to the SYNPP pipeline (see Synthetic Population pages)Create a new MATSim configuration file to run the simulation:
./generate_config.sh
``Make sure to change the values of parameters in the json property file (e.g. simulation seed, correct population file name...) before running the config generator script. You can add more key-value pairs but make sure it follows the MATSim configuration file standard. A new MATSim configuration file with suffix-run
will be created inmatsim/data/matsim-files
.Build a JAR file using a maven-wrapper:
./mvnw clean package
``Dependencies are installed into your/home/yourusername/.m2
directory. The used packages are specified inmatsim/pom.xml
file.(a) Either run:
./run_matsim.sh
The script defines how much memory will be used for the Java app, change it to your wanted size (option-Xmx
, e.g.-Xmx10g
will allocate 10GB RAM)(b) Or run something like:
java -Xmx10g -cp matsim-13.0-v1.0.0-SNAPSHOT.jar org.matsim.run.Controler data/matsim-files/config-prague-run.xml
The simulation results will be in
matsim/output
directory by default.
Preparing MATSim Input Data
All these following steps are prepared in the CreateMatsimNetwork.java
, and can be run directly given that OSM-Network and mapping configuration files are located in matsim/data/matsim-files
directory. All the input properties used in creating the network are listen in matsim/resources/config.properties
, including the EPSG coordinates, GTFS sample day etc.
Network
Before running the simulation, a MATSim network must be created.
First, a multimodal network has to be created (roads for cars, buses, tram, rail, ...). The network is created using the OSM (see here). The conversion is controlled using the OSM-Network configuration file osm-network-config-file.xml.
The OSM road structure is projected into coordinates in which the Euclidean distance is valid.
Output: a multimodal network in MATSim XML format (probably zipped as well)
OSM-Network configuration file
Parameters involving paths (and need to be changed accordingly):
osmFile
- path to the OSM fileoutputNetworkFile
- output file for the multimodal network in MATSim XML format
Public Transit
The GTFS for the public transit is then mapped onto the network. Click here to see how to filter out routes outside the OSM area. The mapping is configured using the pt-mapping-config.xml mapping configuration file.
The links of the network have [x, y] projected coordinates specified, meanwhile the GTFS is in WGS84 and the route is not given - only the order of stops along the route are known. Therefore, in this step the transit schedules are mapped onto the MATSim multimodal network and so the public transport is merged with the MATSim network.
Output: a multimodal network with mapped public transit routes, transit vehicles (bus, tram vehicles, ...) and a mapped transit schedule (timetable) for a chosen GTFS sample day
PT mapping configuration file
Parameters involving paths (and need to be changed accordingly):
inputNetworkFile
- path to the multimodal network in MATSim XML formatinputScheduleFile
- intermediate schedule file created when processing GTFSoutputNetworkFile
- a multimodal network with mapped public transit routesoutputScheduleFile
- a mapped transit schedule (timetable)
Mapping Options
For modes such as subway or ferry, artificial links are created - they do not have a designated road in the OSM file.
The routes used by tram can be defined in the mapping configuration file pt-mapping-config.xml. If no network modes are defined, the transit route will use artificial links.
As of now the trams are also in their own network, not driving alongside cars or buses. Please see: https://github.com/matsim-org/matsim-code-examples/issues/397#issuecomment-658866756
Scaling Vehicle PCE
When running a scaled-down simulation, the PCE for buses have to be re-defined, otherwise the buses get stuck.
For example simulating 10% of population results in bus PCE = 0.3. This can be edited in file transit-vehicles.xml.gz
Vehicles.xml
Different from transit-vehicles.xml
which is for public transit (bus, tram, ...)!
See: https://github.com/matsim-org/matsim-libs/tree/master/examples/scenarios/equil-mixedTraffic
Specifies a type of car, bike, ... that the agents use
either by type of the vehicle -
modeVehicleTypesFromVehiclesData
or individually for each agent (by id) -
fromVehiclesData
If this file is used, the config.xml
file must include the parameter vehiclesSource
:
Transport Modes
Main mode (network mode) - these modes use routing algorithm on the provided MATSim network (with e. g. "qsim" algorithm)
car, (bike *), ...
Transit mode - the modes have predefined routes according to the transit schedule, which do not change during the simulation
all public transit (pt): bus, tram, subway, ferry, funicular, ...
Teleport mode - these modes do not use any routing in the MATSim network, they only take into account the start and end link of an activity a "teleport" along the beeline in a predefined time or speed factor
walk, bike, ...
* Bikes may be simulated in the main mode if the network has a well connected network for bikes (as in there always exists a way from any node x to any node y)
See mixed traffic settings in MATSim: https://matsim.atlassian.net/wiki/spaces/MATPUB/pages/84246576/Mixed+traffic
Scoring
https://github.com/matsim-org/matsim-code-examples/issues/25
Last updated