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.