Step 1: Building a simple MATSim model - Hussein-Mahfouz/matsim-drt GitHub Wiki

I will make these notes as I go long, mainly for my own reference in the future

Create Repo

Install Maven

there are two options - as shown here: https://phoenixnap.com/kb/install-maven-on-ubuntu

  1. using apt
  2. installing manually (follow the instructions in the link)

Create Maven Project in VSCODE

  1. Ensure you have "Extension Pack for Java"
  2. Ctrl + Shift + p           -> Maven: New Project
  3. Add Group.Id and Artifact.id
    1. Group id was com.hussein.mahfouz

Structure of repo

You can run python through maven. Better to have python in seperate root folder for dependancy management etc

Edit pom.xml

Add dependancies under <dependencies> section.

Compile

\# Navigate to the project directory
cd /path/to/your/project

\# Clean the project
mvn clean

\# Compile the project
mvn compile

Prepare Transport Supply

  • PT2MATSim wiki: https://github.com/matsim-org/pt2matsim/wiki
  • Create a wrapper class for each class you want to use from pt2matsim (Osm2MultimodalNetwork, Gtfs2TransitSchedule, CreateDefaultPTMapperConfig)
  • The default pt2matsim OSMConverter config only considers main modes (car, pt). If you want to include other modes in your simulation (e.g. car_passenger), then you need to add them as done here
  • These modes should also be in the modesToKeepOnCleanup, see here
  • After running Gtfs2TransitSchedule, check the vehicles_unmapped file. It has capacity of different vehicle types. These are obtained from google. see here. If you need to change any manually, you can do so by editing the xml file. For example, I am not sure if Coach Service should map onto rail and hve 400 seats

Prepare Transport Demand

Sample the population:

Run Simulation (1st Iteration)

  • you can run simulation with current input data (plans + network + pt mapped)
  • try to run a matsim simulaiton without mode choice (rerouting only). This will test that network is ok
  • Use simuntu via to check PT supply

Prepare Config

  • Generate a matsim config file. See here

  • Remove the code below and then set simulate PT = TRUE

  • Edit the following modules (all relative paths to the config)

    1. transit
    2. network
    3. plans
  • activityParams

    • For each activity add a parameter set. See here. Some values can be kept as "undefined" (the default)
    • These are only relevant to scoring. They are not used when relying on DCM, but MATSim expects them to exist in the config
  • Replanning strategy

    1. On MATSim libs repository, you can see configs of different scenarios (with different replanning strategies)
    2. Copy reroute strategy from here: https://github.com/matsim-org/matsim-libs/blob/72b849e755d4c6c3131be5c4b31be62ce1b5d7eb/examples/scenarios/siouxfalls-2014/config_default.xml#L111
    3. Only use reroute for now
  • Edit output directory

  • CRS:

    • Do not rely on MATSim for crs conversion. All inputs should be in the same projected crs
    • Edit <module name="global"><param name="coordinateSystem" value="Atlantis"></param></module> and change it to your CRS. This is not necessary
  • Facilities: <param name="facilitiesSource" value="none" /> - see: https://github.com/Hussein-Mahfouz/matsim-drt/issues/8

  • transitRouter

    • directWalkFactor should be set to a high number (e.g. 5) - explanation: walking should be decided by mode choice, not by the router

Run Simulation (1st test)

To Run:

  1. check RunSimulation
⚠️ **GitHub.com Fallback** ⚠️