Using OTFVis

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, native libraries are required, which must be correctly set up.

Starting the Visualizer

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.0. 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:

  • specify on the command line. Example:

    java -Djava.library.path=libs/jogl-1.1.0/jogl-1.1.0-linux-amd64/ -cp MATSim.jar org.matsim.run.OTFVis arguments
  • install the corresponding native library as a java extension. The location where the library must be installed differs from one operating system to the next one. Please check the documentation at java.sun.com for general information about Java Extensions or at Apple for Macintosh-specific installation instructions.
  • specify the native library location in Eclipse. If you use the Eclipse IDE for MATSim development, you can specify in the buildpath-settings which native library should be used. Open the Project Properties in Eclipse, and go to Java Build Path > Libraries. Select the jogl.jar in the list of libraries, and expand its display. There should be an entry "Native libary location" that you can set to the corresponding library for your operating system.

Creating snapshots (mvi-files) from Events

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.

Displaying MATSim Visualization Snapshots (mvi-files)

Just pass the file as first argument. Example call:

java -cp MATSim.jar org.matsim.run.OTFVis output/0.visualization.mvi

Displaying TRANSIMS Vehicle files

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

Start Interactive Simulation

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.