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.
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:
java -Djava.library.path=libs/jogl-1.1.0/jogl-1.1.0-linux-amd64/ -cp MATSim.jar org.matsim.run.OTFVis arguments
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 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.