The "tutorial" section contains "reduced" information about how to find your way into matsim.
This "user's guide" section contains additional information, concentrating on features and details that are not explained in the tutorials. Clearly, there may be overlap.
The following list shows the key features of MATSim:
Fast Dynamic and Agent-Based Traffic Simulation
In many cases, MATSim only takes a couple of minutes for a single simulation of a complete day of traffic. This includes the completely time-dynamic simulation of motorized individual traffic as well as the handling of agents using other modes of transport.
Supports Large Scenarios
MATSim is able to simulate scenarios with several millions agents or network with hundreds of thousands of streeets. All you need is a current, fast desktop computer with plenty of memory. Additionally, MATSim allows you to only simulate a certain percentage of the traffic, speeding up the simulation even more while reducing memory consumption, and still generate useful results.
Sophisticated Interactive Visualizer
Forget aggregated results! MATSim provides a fast Visualizer that can display the location of each agent in the simulation and what it is currently doing. It can even connect to a running simulation, allowing interactively querying agents' states, visualizing agents' routes or perform live analyses of the network state.
Versatile Analyses and Simulation Output
During the simulation, MATSim collects several key values from the simulation and outputs them to give you a quick overview of the current state of the simulation. Among other results, it can compare the simulated traffic to real world data from counting stations, displaying the results interactively in Google Earth. Additionally, MATSim provides detailed output from the traffic microsimulation, which can easily be parsed by other applications to create your own special analyses.
Modular Approach
MATSim allows for easy replacement or addition of functionality. This allows you to add your own algorithms for agent-behavior and plug them into MATSim, or use your own transport simulation while using MATSim's replanning features.
Open Source
MATSim is distributed under the Gnu Public License (GPL), which means that MATSim can be downloaded and used free of charge. Additionally, you get the complete Source Code which you may modify within certain constraints (see the license for more details). Written in Java, MATSim runs on all major operating systems, including Linux, Windows and Mac OS X.
Active Development and Versatile Usage of MATSim
Researchers from several locations are currently working on MATSim. Core development takes place at the Berlin Institute of Technology (TU Berlin), the Swiss Federal Institute of Technology (ETH) in Zurich, as well as in a start-up founded by two former PhD students. Additional development (as far as we are aware of) currently takes place in South Africa, Germany (Munich, Karlsruhe) as well as other places around the world. This distribution of development ensures that MATSim not only works for one scenario/context, but can be adapted to many different scenarios.
MATSim runs on any machine that has the Java Platform, Standard Edition (SE) 6 or newer installed (commonly referred to as "Java 6" or newer).
Smaller scenarios (e.g. the examples included in the tutorials, 5%- or 10%-samples of large scenarios) can be run on common desktop or laptop computers.
To simulate large scenarios (several hundreds of thousands of agents, networks with ten-thousands of links and nodes), high end computers with a large amount of memory (RAM) may be required to keep the agents' data in memory. The description of agents' plans and the simulation output can take several Gigabytes of hard disk space. To store the data for several scenarios and / or output of simulation runs, large amounts of disk space may thus be needed. MATSim can read and write compressed files to reduce the amount of required disk space, but this aspect still shouldn't be underestimated. MATSim can make use of multiple CPUs or CPU cores that share common memory ("shared memory machine") during the replanning-phase.
Running large scenarios for a high number of iterations can take several hours, up to a few days. Thus it may be advisable to have a dedicated machine running MATSim if you plan to simulate many different scenarios.
The high numbers for free disk space result from the fact that the simulation writes quite a lot of data to the disk during a run. For analysis, usually only the last version of the data is required, and data from earlier iterations can be deleted, freeing space up again.
Currently, we simulate most of our scenarios on machines with 8 or 16 GB RAM, having 2 dual-core processors. The amount of memory allows us to run 2 scenarios at the same time on the machines. A RAID array is used as storage backend, offering about 4 TB of hard disk space. This huge disk space is able to store the results of hundreds of simulations and will suit us for the next few years. Computers and RAID are regular components used in data centers, usually available at moderate prices.
OTFVis is a visualizer for MATSim. It can be used to replay snapshots of simulations, or run a simulation and interact with it. The visualizer makes use of hardware acceleration (Open GL) and is thus also suitable for visualizing large scenarios. For the hardware acceleration to work, (i) the OpenGL graphic card driver installed on you machine must be at least of version 2.0 and (ii) native libraries are required, which must be correctly set up.
Either you use check and update mechanims / software already installed (e.g. NVIDIA software, ATI update manager, etc...) or download and install OpenGL Extension Viewer. After starting this little tool, it show all necessary information abour your graphic card including OpenGL version. Please be sure that at least OpenGL version 2.0 is installed. Otherwise try to find approriate driver updates of your graphic card (the read circles in the Figure below shows the important featrues / information).
The main class for the visualizer is org.matsim.run.OTFVis. If it is invoked without any arguments, a short description is displayed how the visualizer can be used. The different ways to start OTFVis will be described in more details below.
The visualizer may require a lot of memory, it is thus advised to start it with the corresponding Java options:
java -Xmx500m -cp MATSim.jar org.matsim.run.OTFVis arguments
This sets the memory limit for Java to 500 MB.
In addition, OTFVis requires native libraries to provide the required hardware acceleration. Native libraries contain source code that can only run on some specific machines and operating systems. We provide the native libraries for the most common operating systems in libs/jogl-1.1.1. You may also check for the newest versions of the native libraries at the Java OpenGL website. There are several ways to include the native library when starting OTFVis:
java -Djava.library.path=libs/jogl-1.1.1/jogl-1.1.1-linux-amd64/lib/ -cp MATSim.jar org.matsim.run.OTFVis arguments
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CORRECT_PATH}/libs/jogl-1.1.1/jogl-1.1.1-macosx-universal/lib # linux
export DYLD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CORRECT_PATH}/libs/jogl-1.1.1/jogl-1.1.1-macosx-universal/lib # mac os x
Use the following arguments:
-convert event-file network-file mvi-file [snapshot-period]
to record a snapshot of all vehicles' positions every snapshot-period seconds, based on the events and network given in the corresponding files.
Example call:
java -cp MATSim.jar org.matsim.run.OTFVis -convert output/50.events.txt.gz input/network.xml.gz output/50.visualization.mvi 300
This will create a snapshot of every 5th minute and store it in the file output/50.visualization.mvi.
Just pass the file as first argument. Example call:
java -cp MATSim.jar org.matsim.run.OTFVis output/0.visualization.mvi
For reasons of backward compatibility, OTFVis can display vehicles files traditionally generated by TRANSIMS. As the vehicle file does not include any network information, the network must be passed as well. Example call:
java -cp MATSim.jar org.matsim.run.OTFVis output/0.T.veh input/network.xml.gz
OTFVis can display just a network. This is useful when building a scenario, and a network converted from other data must be inspected. Example call:
java -cp MATSim.jar org.matsim.run.OTFVis input/network.xml.gz
(Note: Currently only available in Nightly Builds since revision r5821)
OTFVis can directly start a simulation and visualize it in real time. As in that case, all data (esp. the population) is loaded into memory, interactive queries about agents and link states can be issued from the visualizer. To start OTFVis in this interactive, live mode, just pass it the config-file you would otherwise pass to the Controler:
java -cp MATSim.jar org.matsim.run.OTFVis input/config.xml
Please note that this will require even more resources (memory, cpu-speed) than only running the simulation with the Controler.
As shown by the Nightly Builds tutorial OTFVis and other classes can be run by using the command line or a shell script respectively. As the Unix based way is already described by the tutorial, this is about the windows user.
The windows command line call looks similiar to the Unix based one. Finally, you should end with something like that
java -Xmx1500m -Djava.library.path=libs/jogl-1.1.1/jogl-1.1.1-windows-i586/lib -cp MATSim_r6508.jar org.matsim.run.OTFVis %*
which can be saved as a *.bat file, e.g. otfvis.bat. Please note that the example is based on the assumption that otfvis.bat is saved in the same folder as the matsim.jar and the libs folder. The placeholder %* will be substitued by the parameters you've specified when calling otfvis.bat from the command line, e.g.
otfvis.bat -convert event-file network-file mvi-file
To call the OTFVis from any folder, put the otfvis.bat into your PATH environment.
If your are more familiar with the point and click behaviour of win systems, you can create a shortcut pointing to your otfvis.bat.
Move the shortcut to your SendTo folder and rename it to something like OTFVis.lnk. Depending on the system you use, the SendTo folder should be located in your home directory. Now you can start the OTFVis by rightclicking at any file within your system, e.g. rightclick a mvi-file, from the context menu select SendTo -> OTFVis.
Starting a new scenario (our term for the application of MATSim to a region/area) can appear quite cumbersome at the first glace, as a lot of data preparation may be required. In any case required for a new scenario are:
Given these two data items, you can already start building your own scenario. The "Learning MATSim in 3 days"-Tutorial gives you an introduction on how to build your own scenario.
See here for javadoc, and here for code.
In many cases, using pre-configured software is not possible because there are just too many possibilities of how input could look like. Although matsim is not there yet, these should be api-only use cases, i.e. they should only use the "stable" api. Therefore, the following are under the api-users section of the documentation:
The following sections contains various information for building a scenario that presumably goes beyond what is in the tutorial.
This is material that was in the tutorial "Learning MATSim in 3 days". We moved it to here, but did not check the content.
A. Horni: Shortly, there will be a working paper describing the usage of MATSim for Switzerland., 02.05.2011
There are many different ways to start a new MATSim scenario. This is just one of them. Ideally, they would be documented somewhere. At this point, there is just this pointer to an (incomplete) Vancouver scenario.
All relevant info (not a lot) is now in src/playground/duncan .
No efforts have been made to include public transit.
Check out the opus source tree from www.urbansim.org . (The source tree is the tree containing directories such as opus_core or opus_gui.)
In this source tree, there should be a directory opus_matsim .
There is documentation in opus_matsim/docs .
For some operations, MATSim must know about the coordinate system your data is in. For example, If you want to generate kml-Output for Counts-Validation, MATSim has to convert the coordinates in your network to WGS84, the coordinate system used by Google Earth.
You can specify the coordinate system in the config-file:
<module name="global"> <param name="coordinateSystem" value="CH1903LV1903" /> </module>
The value specified for the coordinateSystem parameter can be:
Atlantis stands for an artificial coordinate system which maps our examples without relation to the real world somewhere in to the Atlantic ocean.transformations map).As the distance calculation in WGS84-coordinates (or any spherical coordinates) is rather complex (a simple Pythagoras is not enough), we advise people to use a Cartesian coordinate systems, preferable where one unit corresponds to one meter. Using such a coordinate system is a pre-requisit if one wants to use the optimized A*Landmarks-Router in MATSim.
These are modules that can be used via the syntax
<module name="strategy" >
<param name="ModuleProbability_1" value="0.1" />
<param name="Module_1" value="ChangeLegMode" />
<param name="ModuleProbability_2" value="0.1" />
<param name="Module_2" value="TimeAllocationMutator" />
</module>Replanning modules are numbered. Also, each module is given a weight which determines the probability by which the course of action represented by the module is taken. In this example, each person stands a chance of 1/2 that their transport mode is changed, and a chance of 1/2 that their time allocation is changed. (The weights are renormalized so that they add up to one.)
The replanning modules that are understood by MATSim are defined in the class StrategyManagerConfigLoader. In addition, you can program your own replanning modules; see tutorial.programming in matsim/src/main/java for examples.
It is not clear which combinations of these modules can be used together. Depending on required features, special variants sometimes need to be used. The following table tries to give an overview:
| Choice dimension | Default Strategy | Transit | Transit & Parking |
| departure time choice | TimeAllocationMutator | TransitTimeAllocationMutator | ? |
| route choice | ReRoute | ReRoute | ? |
| mode choice (all legs get same mode) |
ChangeLegMode | TransitChangeLegMode | ? |
| mode choice (each leg can have a different mode) |
ChangeSingleLegMode | TransitChangeSingleLegMode | ? |
| mode choice (subtour-based) |
SubtourModeChoice | TransitSubtourModeChoice | ? |
| location choice | LocationChoice | ? | ? |
Legend:
Maintainer: Marcel Rieser
All routes of a plan are recomputed.
The module is called by inserting the following lines into the "strategy" module:
<module name="strategy" >
<param name="ModuleProbability_XXX" value="0.1" />
<param name="Module_XXX" value="ReRoute" />
...
</module>The corresponding configuration module unfortunately has a different name:
<module name="planscalcroute" > <param name="beelineDistanceFactor" value="1.3" /> <param name="bikeSpeed" value="4.166666666666667" /> <param name="ptSpeedFactor" value="2.0" /> <param name="undefinedModeSpeed" value="13.88888888888889" /> <param name="walkSpeed" value="0.8333333333333333" /> </module>
This works pretty reliably for car.
It also works for other modes, as "pseudo"-mode, in the following way:
It is possible to route such legs on the network, by using a different router.
It is not possible to "physically" execute a leg in the mobsim if it has not been routed before. That is, the capability of the router needs to be >= the capability of the mobsim. (Makes sense, if one thinks about it.)
Simple module that shifts activity end times randomly. ("Good" time shifts will be selected through the matsim plans selection mechanism.)
The maximum extent of the shifts can be configured; see the config section of the log file. It is, as of now (may'10), not possible to add a comment to that parameter.
The usage of the module is configured in the "strategy" section.
Maintainer: Michael Zilske
This replanning module randomly picks one of the plans of a person and changes its mode of transport. By default, the supported modes are driving a car and using public transport. Only one mode of transport per plan is supported. For using different modes for sub-tours on a single day see the "SubtourModeChoice" module.
The replanning module is configured like this, where the value parameter lists the modes of transport from which the module randomly chooses:
<module name="changeLegMode"> <param name="modes" value="car,pt" /> </module>
Add the module to the replanning strategy like this:
<param name="Module_X" value="ChangeLegMode" /> <param name="ModuleProbability_X" value="0.1" />
Replace the 'X' with the number you assign to this module. For some more details on the syntax of this section, see here.
By default, the simulation will handle legs with modes different from "car" by using a delayed teleportation. If another behavior is requested (e.g. detailed simulation of public transport), this needs to be manually configured for the simulation.
M. Rieser, D. Grether, K. Nagel; Adding mode choice to a multi-agent transport simulation; TRB'09
A. Horni, IVT (horni_at_IVT.baug.ethz.ch)
www.matsim.org/javadoc/org/matsim/locationchoice/package-summary.html
www.matsim.org/javadoc/org/matsim/locationchoice/package-summary.html#locationchoice_parameters
Ready
MATSim provides destination choice based on three different basic concepts. First, random search can be applied. Second, local search implemented in the time geography framework is available [1]. Third, the most recent module ist best response and includes random error terms to make MATSim fully compatible with discrete choice theory [2]. The authors recommend to use this recent module in general. Random search should be utilized for algorithmic comparative investigations only.
The time geography module provides the possibility to take into account spatial competition in the activity location infrastructure (see Figure 3). It is planned-after a thorough calibration-to integrate spatial competition in the best response version.
Estimation of a MATSim destination choice utility function for Switzerland is in development [3].
The strategy module in the config file needs to be extended as follows:
<module name="strategy">
...
<param name="ModuleProbability_X" value="0.0 < double <=1.0" />
<param name="Module_X" value="LocationChoice" />
...
</module>
Due to slow convergence, this approach is only useful for very small scenarios.
The MATSim local search destination choice module is based on Hägerstrand's time geography. That is, in every replanning step locations are chosen within the region restrained by travel time budgets as defined by the time allocation module (see Figure 1 and Figure 2). Within this region the choice is performed based on the MATSim utility function.
In more detail, the following procedure is iteratively applied. An approximate choice set of locations is built to begin with, where the constructing of this set is initially based on an initial global travel speed assumption (recursionTravelSpeed). After tentatively choosing one location from this approximate set, the actual accessibility in terms of travel time is checked. If the location is not accessible it is rejected, the initial travel time is adapted according to the recursionTravelSpeedChange parameter in the configuration file and a next trial is started. After a certain number of failed trials to find an accessible location (maxRecursions), the choice is made from the universal choice set.
The parameters recursionTravelSpeed, recursionTravelSpeedChange and maxRecursions are explained in Section Parameters
The parameters scaleEpsShopping and scaleEpsLeisure correspond to fShopping and fLeisure in [2]. probChoiceSetSize is Φ. epsilonDistribution, tt_approximationLevel, maxDistanceEpsilon, and probChoiceExponent are explained in in Section Parameters.
The parameters scaleEpsShopping and scaleEpsLeisure can be calibrated, based on e.g., travel distance distributions as described in [2].
Similar to route and time choice being influenced by the competition in transport infrastructure it can be expected that competition in activities infrastructure has an effect on destination choice. Consequently, the utility of performing an activity is dependend on the actual load of the activities infrastructure at least for some activities such as e.g., grocery shopping (e.g.; searching for a parking space or waiting time at cash points etc.). In MATSim spatial competition is taken into account, which has shown to reduce the number of implausibly overcrowded locations (see Figure 3 below).
The score for perfoming an activity is calculated as follows:
score = (1- fp) * score_without_penalty
fp = Max(0.5, fcrf)
fcrf = restraintFcnFactor * [(facility load) / (facility capacity)] ^ restraintFcnExp
The parameters restraintFcnFactor and restraintFcnExp are explained in the section Parameters
[1] Horni, A., D.M. Scott, M. Balmer and K.W. Axhausen (2009) Location choice modeling for shopping and leisure activities with MATSim: Combining micro-simulation and time geography, Transportation Research Record, 2135, 87-95.
[2] Horni, A., K. Nagel and K.W. Axhausen (2011) High-Resolution Destination Choice in Agent-Based Demand Models, Arbeitsberichte Verkehrs- und Raumplanung, 682, IVT, ETH Zürich, Zürich.
[3] Horni, A., D. Charypar and K.W. Axhausen (2011) Empirically approaching destination choice set formation, paper presented at the 90th Annual Meeting of the Transportation Research Board, Washington, D.C., January 2011.



For questions, please contact:
Konrad Meister
IVT, ETH Zurich
email: meister (at) ivt.baug.ethz.ch
The planomat is a stochastic best-reply replanning module for the activity durations and the departure times, as well as the mode choice on subtour level. On the one hand, this module replaces a simple random mutation module for departure times (the Time allocation mutator) with a genetic algorithm (GA) for daily plan optimization. This leads to a convergence of the MATSim learning framework within several dozens of iterations, independent of the departure times and activity durations in the initial demand (Meister et al., 2006). The choice of a GA makes it possible to include more plan variables into the optimization procedure. Currently it is possible to modify the mode of each subtour of the activity plan is varied besides the time information (unpublished, experiments documented in Meister, 2008). The mode choice set for each subtour may include modes whose travel times/costs can be estimated from events (typically "car") or directly from a routing algorithm, when events are not available, or the transport mode is not dynamic (typically "pt", "bike", "walk").
The optimal timing of the daily activity plan depends mainly on the travel times which the agents expects for a given leg. Just like in the router, and for reasons of simplicity, a travel time approximation based on global knowledge is assumed. The travel time will be estimated for the route that is given in the activity plan, which remains unchanged. For the “virtual” assessment of other modes of a given leg, the free-speed route for the respective mode is determined. The actual travel time on this route may still be time-dependent, as for the mode "car" in the application presented here.

The planomat replanning module was used in a large-scale study of agent-based travel demand optimization (Balmer et al., 2010).
In order to use the planomat as a replanning module, activate it in the strategy section of the config xml file:
<module name="strategy"> ... <param name="ModuleProbability_n" value="0.1" /> <param name="Module_n" value="Planomat" /> ... </module>
n with the consecutive number of replanning/selection modules in the strategy section.Without further settings, only time information (departure times, activity durations) will be modified and optimized. This is the default behavior, leg mode information will not be touched. In order to switch on mode choice optimization on the subtour-level, indicate the mode choice set in a separate config section with the name planomat:
<module name="planomat">...<param name="possibleModes" value="car,pt" />...</module>
The behavior of the planomat module can be controlled with several other configuration parameters. For example, set the maximum number of GA generations to a lower value of 10 than the default value of 100:
<module name="planomat"> ... <param name="jgapMaxGenerations" value="10" /> ... </module>
For additional config parameters, their respective default values and the possible value ranges, please refer to the code at org.matsim.core.config.groups.PlanomatConfigGroup.class.
see hyperlinks in description.
Maintainer: Michael Zilske
In contrast to "ChangeLegMode", which changes all legs of a plan to a different mode, this module changes the modes of sub-tours separately.
For example, somebody might take the car to work, walk to lunch and back, and take the car back home.
"chainBasedModes" means modes where a vehicle (car, bicycle, ...) is parked and in consequence needs to be picked up again.
<module name="subtourModeChoice" > <param name="chainBasedModes" value="car, bike" /> <param name="modes" value="car, bike, pt, walk" /> </module>
The module is called by inserting the following lines into the "strategy" module:
<module name="strategy" >
<param name="ModuleProbability_XXX" value="0.1" />
<param name="Module_XXX" value="SubtourModeChoice" />
...
</module>
For modes other than car, travel time and travel distance are computed according to some heuristics, which are configured in the router.
The default MATSim releases contain all the functionality typically used to model agent behavior and simulate traffic. But sometimes, this just is not enough. The MATSim Extensions provide additional functionality for specific tasks, and can be used along MATSim. MATSim Extensions gives an overview of the currently available extensions. Please note that these extensions are usually provided and maintained by single persons from the community, and thus long-term support may vary from the default MATSim release.
All extensions come as a compressed zip-file. You can either download the last stable release of an extension to be used together with the stable release of MATSim, or you can download a so-called "nightly build"—an automatically created, but untested and probably unstable version of the extension.
Once you've downloaded an extension and MATSim, unzip the extension and place the extension's directory inside the MATSim directory, next to the libs directory. The file/directory structure should look similar to the following example:
matsim/ + MATSim.jar + libs/ | + <lots of .jar files> + extension1/ | + extension1.jar +extension2/ | + extension2.jar | + libs/ <-- not all extensions contain additional libs | | + <one or more .jar files>
Then, start your simulation with the extension.jar-file on the classpath along the MATSim jar-file, e.g:
java -Xmx512m -cp MATSim.jar:extension1/extension1.jar:extension2/extension2.jar org.matsim.run.Controler myConfig.xml
On Windows, use ; instead of : to separate the different jar-files.
Unzip the downloaded extension and place the extension's directory in your eclipse project. Then, add the extension's jar-file to the Java Build Path in Eclipse's Project Settings.
Extensions are developed and documented by their maintainers. You find links to the documentation of specific extensions in the description of the extensions. See the list of available extensions for their description and documentation.
Modules are loosely defined by their corresponding entry in the config file.
They are also sorted in the same sequence (which is done by the machine, not by content).
Note that individual config options are often explained inside the config section of the log file.
Config file modules that just define files/directories are, as a tendency, not explained here.
Maintainers are mentioned as far as possible, but they are not responsible for answering arbitrary service requests.
Marcel Rieser, senozon AG (rieser_at_senozon.com)
www.matsim.org/javadoc/org/matsim/core/controler/package-summary.html
www.matsim.org/javadoc/org/matsim/core/controler/package-summary.html#controler_parameters
Central module to run matsim. Specifies, for example, the number of iterations.
See here for some instructions how to use an external executable as mobsim.
A. Horni, IVT (horni_at_IVT.baug.ethz.ch)
www.matsim.org/javadoc/org/matsim/counts/package-summary.html
www.matsim.org/javadoc/org/matsim/counts/package-summary.html#counts_parameters
MATSim can compare the simulated traffic volumes to traffic counts from the real world. Counts is the module that allows to
There is a feature to re-scale the counts before comparison (for example if you are running the simulations with a 10% sample).
Prepare a file containing the real-world traffic counts. The file, e.g. named counts.xml, must follow the xml-format defined in counts_v1.xsd. An example of such a file can be found in MATSim at examples/equil/counts100.xml.
The file contains the following information:
loc_id. In addition, an optional cs_id can be stored that may, for example, refer to the original id of the counting station (for tracking back the origin of the data).val") for an hour of the day (attribute "h", numbered from 1 to 24; 1 = 00:00-00:59, 2 = 01:00-01:59, etc). It is not necessary that traffic counts are available for all 24 hours of a day.Add the following lines to your configuration file:
<module name="counts"> <param name="inputCountsFile" value="/path/to/counts.xml" /> <param name="outputformat" value="txt,html,kml" /> </module>
The comparison is automatically generated every 10th iteration. Generated output is located in the output-directory of the iteration (usually something like output/ITERS/it.10/).
The counts-module offers the following config-parameters:
<param name="outputformat" value="txt,html,kml" />txt, html and kml. Multiple formats can be specified separated by commas. txt writes simple text-tables containing the values to a file. It is most useful to create custom graphs, e.g. in Excel. html creates a directory containing several html files, allowing to browse the results interactively. kml creates a file to be displayed in Google Earth. This last option only works if the correct coordinate system is set.<param name="countsScaleFactor" value="1.0" /><param name="distanceFilterCenterNode" value="2386" />
<param name="distanceFiler" value="30000.0" />distanceFilter", the unit being the same unit as the length of links (i.e. usually meters).
Evacuation code used by IVT; please note that IVT and VSP use different evacuation codes.
Maintained by C. Dobler.
I (kn) don't know how this works
(Note that VSP and IVT use different evacuation packages.)
G. Lämmel, TU Berlin
http://www.matsim.org/javadoc/org/matsim/evacuation/package-summary.html
http://www.matsim.org/javadoc/org/matsim/evacuation/package-summary.html#evacuation_parameters
I (kn) can't say how this works. There is, at this point, neither documentation nor funding.
Maintainer: Andreas Horni
One may, or may not, use a separate file that contains "facilities" – essentially some kind of land use information.
The prototype for this is fairly old. But the final design is somewhat different, and has not been fully executed. So I (kn) do not know if this can currently be used as a non-developer.
"Maintainer": Marcel Rieser
"Global" information. Arguably should be merged with "controler" section.
Maintainer: Christoph Dobler
An option to read a households file into matsim.
I (kn) don't know the exact status.
Maintainer: Rashid Waraich
JDEQSim (Java Deterministic Event Driven Queue Based Simulation) has the following properties and features:
Insert a new module called 'JDEQSim' into the config XML file. All parameters are optional and have default values (shown below), never the less it could be helpful to know their meaning and physical units.
<module name="JDEQSim"> <param name="endTime" value="00:00:00" /> <param name="flowCapacityFactor" value="1.0" /> <param name="storageCapacityFactor" value="1.0" /> <param name="minimumInFlowCapacity" value="1800" /> <param name="carSize" value="7.5" /> <param name="gapTravelSpeed" value="15.0" /> <param name="squeezeTime" value="1800" /> </module>
The 'endTime' defines the time of the last event of the simulation. If it is set to '00:00:00', no end time is defined and the simulation will stop, when the last event of the simulation has been processed. The (scaling) parameters 'flowCapacityFactor' and 'storageCapacityFactor' can be used as with mobSim and have no unit. The 'minimumInFlowCapacity' defines for all roads the minimum number of cars, which could enter the road per hour, for the congestion less case. The 'carSize' parameter allows to set the size of a car in meters. The 'gapTravelSpeed' parameter defines the speed of gaps in [m/s]. Finally the 'squeezeTime' is used for deadlock prevention and defines, how long a car should wait at maximum for entering the next road before deadlock prevention is turned on (unit: seconds).
The 'minimumInFlowCapacity' is a parameter, which was not published in the C++ DEQSim, but only used interally and was hardcoded to the value 1800 vehicles per hour. This value was estimated from literature assuming that independently from the speed limit of a road the minimum interval between two vehicles is 2 seconds (inverse of 1800 vehicles per hour). This factor does not need to be changed, when the 'flowCapacityFactor' is changed, as the scaling is automatically done internally. The reason for publishing this factor is to make it possible for users to adapt this factor, if they want to use a different minium inflow capacity based on their model estimations.
Requirements for the Plans XML File
Difference between MobSim and JDEQSim
This implementation is based on the micro-simulation described in the following paper:
Charypar, D., K. Nagel and K.W. Axhausen (2007) An event-driven queue-based microsimulation of traffic flow, Transportation Research Record, 2003, 35-40.Order here.
Some Java specific implementation aspects and performance tests of JDEQSim and parallelEventHandling are described in the following paper:
Waraich, R., D. Charypar, M. Balmer and K.W. Axhausen (2009) Performance improvements for large scale traffic simulation in MATSim, paper presented at the 9th Swiss Transport Research Conference, Ascona, September 2009. Download from here.
Maintenance: G. Lämmel, VSP
MATSim provides the opportunity to model time dependent aspects of the network explicitly. For each link in the network basic parameters (i.e. freespeed, number of lanes and flow capacity) can be varied over the time. So it is possible to model accidents or the like. One particular area for this technique is the modeling of evacuation scenarios.
In the case of an evacuation simulation the network has time dependent attributes. For instance, large-scale inundations or conflagrations do not cover all the endangered area at once.
In MATSim this time varying aspects are modeled as network change events. A network change event modifies parameters of links in the network at predefined time steps. The network change events have to be provided in a XML file to MATSim.
A sample network change event XML file could look like:
<?xml version="1.0" encoding="UTF-8"?>
<networkChangeEvents xmlns="http://www.matsim.org/files/dtd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.matsim.org/files/dtd http://www.matsim.org/files/dtd/networkChangeEvents.xsd"> <networkChangeEvent startTime="03:06:00">
<link refId="12487"/>
<link refId="12489"/>
<link refId="12491"/>
<freespeed type="absolute" value="0.0"/>
</networkChangeEvent></networkChangeEvents>
This change event would set the freespeed of the links 12487, 12489, 12491 to 0 m/s at 03:06 am (all values have to be provided in SI units). These values are valid until the next network change event (if there is any) changes the freespeed of link 12487, 12489, 12491 again. In this example the freespeed would be set to an absolute value. It is also possible to take the old freespeed value and multiply it by a factor. For dividing the old freespeed value by 2, the corresponding line of the network change event XML file would look like:
<freespeed type="scaleFactor" value="0.5"/>
Besides changing the freespeed, one could also change the number of lanes:
<lane type="absolute" value="2.0"/>
Or the flow capacity:
<flowCapacity type="absolute" value="0.0"/>
To make use of the network change events one has to define it in the MATSim config file. Therefore the following two lines have to be added in the network section of the config file:<param name="timeVariantNetwork" value="true" />
<param name="inputChangeEventsFile" value="path_to_ change_events_file" />
Now one has just to start the controller with this config file and the network change events will be applied automatically.
Maintainer: Marcel Rieser
This module contains the definitions for the utility function.
Some help for it should be in the tutorials.
There is also some description in the "scoring function" section of the documentation.
Responsible: C. Dobler, IVT
Analysis of performance and structure of (non parallel) QueueSim shows:
The parallel QueueSim is based on the existing QueueSim and can be used by just adding a new parameter to a scenario configuration file (see below).
First performance measurements show promising results.
Working paper will be published in Q2 2010.

The config option presumably is:
<module name="qsim"> ... <param name="numberOfThreads" value="5"/> </module>
Any number of threads larger than one triggers the use of the parallel version. (??)
If you do not put a "qsim" section into the config file, the system will use the default "simulation" (look there).
"qsim" is what we use for new features such as public transit or signalsystems. "New features" implies "unstable". Use only if you have to.
Also see www.matsim.org/javadoc/org/matsim/ptproject/qsim/package-summary.html
The (exit) flow capacity of a link is:
capacity_value_of_link / capacity_period_of network * flow_capacity_factor
where
The storage capacity of a link is:
(length_of_link * number_of_lanes_of_link / effective_cell_size) * storage_capacity_factor
where
This is most useful if you have something else than cars, for example pedestrians. Let us assume an effective lane with of 0.4m and an effective cell size also of 0.4m. This would lead to a maximum density of 0.4*0.4=0.16persons/m^2, not totally unrealistic.
If, now, a link has an area of 200m^2 and a length of 50m, then it would obtain
number_of_lanes = area / length / effective_lane_width = 200 / 50 / 0.4 = 10
Note that, in the end, the lane width is not used by the dynamics; all the meaning is subsumed in the number of lanes. The storage capacity comes out as
storage_capacity = number_of_lanes * length / effective_cell_size
in the above example
= 10 * 50 / 0.4 = 1250 .
This is, naturally, the same as dividing the 200m^2 of the link by the 0.16persons/m^2.
The effective lane width might be used by the visualization (unclear if this is the case).
Maintainer: Michael Zilske
The roadpricing module provides functionality to simulate different road-pricing scenarios in MATSim.
Documentation can be found at:
Publications using this module:
Maintainer: Dominik Grether
The signal systems module provides functionality to simulate traffic lights with MATSim. It is recommended to use a nightly build that is younger than 04-19-2011, i.e. revision 15081.
The starting point of the documentation is
Note that there are links to continuative documentation at the bottom of the package-summary.html www page.
Nightly builds younger than 04-21-2011 contain a tutorial that shows you how to set up a traffic light scenario. The network and traffic light configuration of the turorial is shown in the slides attached to this page. The network and code can be found in the folder tutorial/unsupported/example90TrafficLights in the nightly build. The code examples are divided into several classes:
Publications using this module:
This was essentially the production of the queue simulation until Nov/2010. The "qsim" was then forked out for further development. Unfortunately, this fork was done somewhat too late, so "simulation" is not exactly the stable version that was used over many years, but something that is already somewhat modified, and was not used very much after that. (Please let us know if you have problems.)
Note that you will get a "simulation" section in the log file even if you have selected a different mobsim (such as qsim or jdqsim).
There used to be an option to start an external mobsim. This still seems to be there but the syntax is a bit awkward:
<module name="controler" > ... <param name="mobsim" value="null" /> </module> <module name="simulation" > <param name="externalExe" value="<path-to-executable>" /> </module>
I.e. you need to specify that you are not using the (queue)Simulation, but then set a parameter inside the (queue)Simulation config block.
A public transport system is simulated and integrated on a fine scale with both the traffic simulation and the behavior of the artificial population.
Agents who use transit determine a route to their destination based on the transit schedule. Transit vehicles are moved on the road network in accordance with the traffic flow model, i.e. they may get stuck in congestion and fail to keep their schedule. Agents getting on and off transit vehicles cause realistic delays.
A transport mode decision model is implemented which allows agents to switch their choice of driving a car or using transit based on the relative utility of the two modes. The disutility of travel time, which this model takes into account, is based on actual travel times taken from the simulation.
See the tutorial. This requires quite some additional input.
M. Rieser, K. Nagel; Combined agent-based simulation of private car traffic and transit; IATBR 2009
Maintainer: Marcel Rieser ("core")
"router" and "travelTimeCalculator" are separate in matsim, so that they can be configured separately. They refer to each other, though.
Maintainer: Michael Zilske (within limits of DFG/MUC project; possibly pt project)
This section defines switches that are used at VSP or when collaborating with VSP. There are experimental and may we withdrawn without notice.
I (kn) am in the process of defining some defaults that everybody at VSP should be using. These can be switched on by:
<module name="vspExperimental" > <param name="vspDefaultsCheckingLevel" value="abort" /> ... </module>
This will make the code abort when these defaults are violated.
The number of vsp defaults will grow over time. This may have the effect that some config file that used to be working for you in the past may not work any more after an svn update. I will try to communicate such changes, but will sometimes fail to do so. In any case, if you encounter an abort because of a vsp defaults violation, please
If you think that you cannot live with these settings, please talk to me.
Since those settings involve all aspects of matsim, they may often be irrelevant to you. Please set them anyways.
Maintainer: Christoph Dobler
There is no "withinday" section in the config file, so there shouldn't be an entry here. It is here for historical reasons. Instead look here (note that this is in the "developer" section of the documentation, i.e. if you are not in the sourceforge playground, you will not get code that is stable from one matsim build to the next).
Dismantler: Michael Zilske
This was an attempt to integrate GIS functionality into matsim.
Has been superceeded by calls to geotools. Please use geotools functionality. Look under the demand generation tutorials for getting some ideas.
World also provides datastructures to assign facilities to links, and links to zones, etc. This functionality is mostly used in initial demand modelling, but is not very straight-forwardly implemented. Should be replaced in the future with some kind of "mappig manager" to manage the mappings between different MATSim objects, like facilities, links, etc.
This section contains information that pertains to the so-called "Charypar-Nagel scoring function".
The simplified version assumes that all activities operate near their typical duration. In that case (see here), one can approximate the marginal utility of activity duration (i.e. the marginal utility if the sum of all activities is extended by that amount of time) by beta_perf .
Now let us consider the typical changes (of the Vickrey scenario). Note that in the Vickrey scenario, the meaning of the marginal utility of arriving earlier means the marginal contribution assuming that the travel time remains the same. We will assume that activities are ended by the endtime attribute, not by the duration attribute.
Travel takes longer (by amount deltaTtime)
In that situation, the activity that follows the trip is cut short by deltaTtime. We thus have the following (linearized) modifications of the utility:
Overall: The (linearized) utility change caused by longer travel is
( - beta_perf + beta_travel ) * deltaTtime
Traveller increases arriving early (by amount deltaEtime)
In that situation, the traveller will "do nothing" between the arrival and the opening time of the activity. That is, the amount of time that the traveller is doing nothing is now increased by deltaTtime. Consistent with the meaning of the Vickrey parameter "marginal utility of arriving early", we assume that the travel time is the same compared to the later arrival. This means that the preceeding activity was cut shorter by deltaTtime. We thus have the following (linearized) modifications of the utility:
There are no other contributions, since the time between the arrival and the opening time prodices neither positive nor negative utility contributions. Overall: The (linearized) utility change caused by arriving early is
( - beta_perf ) * deltaEtime
Traveller increases arriving late (by amount deltaLtime)
In this situation, we have the following (linearized) modifications of the utility:
Overall: The (linearized) utility change caused by increasing the amount of arriving late is
beta_late * deltaLtime
Overall
Overall, calibration of the Charypar-Nagel scoring function is best done as follows:
Without schedule delay
If you intend to run MATSim without time adaptation (TimeAllocationMutator), these things are not that critical. In that situation, you just need to make sure that - beta_perf + beta_trav matches your marginal utility of travel time differences. An easy way in our view is:
Note that even without time adaptation, beta_late may still have an influence if you have set the latest arrival times for some activities.
"Full version" would imply that we could calibrate the MATSim parameters also for situations where the actual activity durations are far from their "typical" values. This could happen for two reaons:
Both of these interpretations make sense (in my view) and should be investigated for MATSim. Presumably, there is already general research; it would then be necessary to bring that research and the MATSim formulation together.
The so-called "Charypar-Nagel scoring function" is used in many MATSim studies. It is called that way because there is an ancient paper where this scoring function was introduced.
It uses a logarithmic utility of time for activities: U = beta * t_x * ln(x/t_0) . I sometimes call t_x the "typical duration".
The first derivative of U is beta at the typical duration:
dU/dx = beta * t_x / x
dU/dx(x=t_x) = beta
Interpretation: marginal utility of duration at "typical duration" is indep of activity type. (*)
The second derivative of U at the typical duration is
d^2U/dx^2 = - beta * t_x / x^2
d^2U/dx^2(x=t_x) = - beta / t_x
An important consequence of this is that there is no separate free parameter to calibrate the curvature (= 2nd derivative) at the typical duration: beta needs to be the same across all activities, and t_x is given by (*).
A second consequence is that t_0 is largely irrelevant. It shifts the function up and down, i.e. it determines how much you lose if you drop an activity completely.
In the original paper (and in most of MATSim), t_0 is set to t_x * exp(-10h/t_x) . This has the (intended) consequence that all activities have the same utility contribution at their typical duration:
U = beta * t_x * ln( x / t_x / exp(-10h/t_x) ) = beta * t_x * [ ln( x/t_x ) + 10h/t_x ]
which is, at x=t_x: = beta * t_x * [ 0 + 10h/t_x ] = beta * 10h . With our usual beta = 6Eu/h, this results in 60Eu per activity.
The slope at U=0, i.e. at x=t_0, is
(beta * t_x / t_x) * exp( 10h/t_x) = beta * exp( 10h/t_x )
which decreases with increasing t_x. This means that activities with larger typical duration are easier to drop completely.
In the end, this makes sense: Since the additional score of any activity is the same, the score per time is smallest for activities with long typical durations. Therefore, it makes sense to drop them first.
But practically, this is probably not desired behavior, since it would first drop the home activity from a daily plan.
Overall, therefore: In my opinion, the current utility function does not work for activity dropping.
An alternative, never tested since activity dropping was never tested with this utl fct, would to to recognize that U'(t_0) = beta * t_x / t_0 , i.e. increasing slope with decreasing t_0. That is, high priority activities should have t_0 such that t_x/t_0 is large (large slope = hard to drop). Activities of the same priority should have t_0 such that t_x/t_0 is the same between those activities. Overall, something like
weight \propto t_x/t_0
or
t_0 \propto t_x/weight
where large weight implies a large importance of the activity.
This was, as said, never tried, since activity dropping was never systematically tried. It also does not fix the problem, discussed later, that different activities might have different resistance against making them shorter; since this is U'', this is -beta/t_x with the above utl fct: activities are shortened proportional to their typical duration.
To make matters worse, there is currently the convention that negative values of U are set to zero. This is done since we need useable values for negative durations (since they may happen at the "stitching together" of the last to the first activity of a day), and if we give those a "very negative" score, then the utl at t=0 cannot be even smaller than this.
This has, however, the unfortunate consequence that the "drift direction" of the adaptive algorithm, once an activity duration has gone below t_0, goes to zero duration.
Outlook: What would we want for our next generation utl function? Some wishes from my perspective:
In my view, a polynomial of second degree would be worth trying. As usual, there are several ways to set this up. One way is to expand around the typical duration:
U(t_x + eps) = U(t_x) + eps * U'(t_x) + eps^2 * U''(t_x)/2
or
U(x) = U(t_x) + (x-t_x) * U'(t_x) + (x-t_x)^2 * U''(t_x)/2
with t_x = typical duration, U'(t_x) = beta = marg utl at typ dur, U''(t_x) = curvature at typ dur ("priority"), and U(t_x) = "base value of act" (which could be something like beta*t_x ).
Another way (having the parabola going through (0,0)) would be
U(x) = - a x ( x - c ) = - a x^2 + a c x
U'(x) = - 2 a x + a c
prio = U'(x=0) = a c , i.e. c = prio/a .
beta = U'(x=t_x) = - 2 a t_x + prio, i.e. a = (prio - beta)/2t_x
There is other work (e.g. by Joh) that should be looked at.
A discussion of policy measures that can be investigated with matsim is under matsim.org/policy-measures . It is not in the user section but in the developer section of the documentation since, at this point, many of those measures need additional coding. Clearly, something like adding or removing lanes or links can be investigated without any coding.
In many cases, MATSim uses a terminology that is different from the mainstream terminology. In most cases, the reason is that the concepts are only similar, but not identic, and we wanted to avoid the confusion of using the same term for aspects that are similar but not identical. The following attempts some commented approximate "translations" from more standard teminology to MATSim terminology.
Comments: During MATSim iterations, agent accumulate plans. This can be interpreted as building a choice set over time. A problem is that the process that generates the choice set at this point is not systematic.
Possible future developments: Once it has been made explicit that "plans generation" means "choice set generation", the terminology may be made standard.
Comments: As said above, the set of MATSim plans can be seen as this agent's choice set. MATSim generates new plans "on-the-fly", i.e. while the simulation is running. We sometimes call this "innovation", since agents create new plans (= add entries to the choice set), rather than choosing between existing plans.
It seems as if replanning is only used in Matsim for "generating a new plan alternative" but not for "selecting an existing alternative". It took me some time and some misunderstandings with Yu to figure this out. It appears more plausible to me to phrase it as "replanning = {choice, choice set generation/update}". Gunnar
The above needs to be discussed; in my understanding replanning indeed includes choice. Kai
Scores in matsim are computed as score_new = (1-alpha) * score_old + alpha * score_sim, where score_sim is the score that is obtained from the execution of the plans (= network loading).
Matsim scoring function = beta_brain * \sum_i beta_i * attribute_i
Typical formulation = \mu * \sum_i ...
For estimation, \mu and the \beta_i are not independently identifiable. For simulation, they are hence somewhat arbitrary. Since this is arbitrary anyway, beta_brain should be at least set to one and not to two. The re-labeling into "mu" would not only be more consistent with common language, it would also avoid the "brain"-notion, which I find irritating. Gunnar
I agree. "beta_brain" and "2" are there for historical reasons, and api changes are always difficult. Kai
Comments:
Possible future developments: None of this is ideal, since, after the introduction of a policy, it is not clear which behavioral switches are due to the policy, and which are due to sampling. In theory, one should have unbiased samples before and after the introduction of the policy, but at this point this is not implemented and it is also computationally considerably more expensive than what is done now.
Comments: The standard terminology has the "network loading" on the "supply side". In my (KN's) view, the "simulation of the physical system" is not the supply side, but what in economics is called "technology". This can for example be seen in the fact that "lane changing" is part of the mobsim, but this is, in my view, not a "supply side" aspect.
Possible future developments: May switch to "network loading" if there is agreement that this is a better name.
Comments: "stationary" means that the probability distribution does not shift any more. However, as long as "innovation" is still switched in on MATSim (new routes, new times, ...), the result is not truly stationary. Thus we avoid the word. If innovation is switched off, the result is indeed a statinary process, but limited to the set of plans that every agent has at that point in time.
Possible future developments: not clear. Minimally, publications should be precise.
Configuration:
<module name="strategy" > <!-- iteration after which module will be disabled. most useful for ``innovative'' strategies (new routes, new times, ...) --> <param name="ModuleDisableAfterIteration_1" value="null" /> <param name="ModuleDisableAfterIteration_2" value="950" /> <!-- probability that a strategy is applied to a given person. despite its name, this really is a ``weight'' --> <param name="ModuleProbability_1" value="0.9" /> <param name="ModuleProbability_2" value="0.1" /> <!-- name of strategy (if not full class name, resolved in StrategyManagerConfigLoader) --> <param name="Module_1" value="ChangeExpBeta" /> <param name="Module_2" value="ReRoute" /> <!-- maximum number of plans per agent. ``0'' means ``infinity''. Currently (2010), ``5'' is a good number --> <param name="maxAgentPlanMemorySize" value="4" /> </module>
The above means:
At least when using random utility models (such as multinomial logit aka ExpBeta...), the score has the same function as the deterministic utility.