This Java program gives you an example how to use the MATSim API to create a population of one sample person. Try and run the program, and inspect the generated population file.
Now you will want to change this program so that the start and end location of the plan are actually in your region of interest. In this tutorial, we are using OpenStreetMap data, so open the Geofabrik map application, choose a home location and a work location, copy the coordinates (you will probably have to use pen and paper) and enter the coordinates into the program. You should choose locations which are some larger distance apart so it has to travel a lot. It will be easier to find that way all alone in the network.
Create a config.xml file (you may use example2-config.xml from section 2 of this tutorial as a starting point), change the filenames of the network and the population file to match the files you just created, and run the Controler with this config.xml as a parameter.
You will see the simulation run. When it is done, open the 0.otfvis.mvi file from the ITERS/it.0 directory with OTFVis. You should see your agent drive!
The next step is to generate a population of agents based on available data. This always involves programming, because traffic demand data comes in many forms and there is no generic way of mapping it to a MATSim population. In this tutorial, we will try to assist you in generating MATSim plans from whatever data source you may have available.
Start simple: Write a program which creates home-work-home commuter plans. Use the OpenStreetMap application to pick the center coordinates (roughly) of some administrative units around your city of interest. Write them down in your program. Now write a function which creates a number of commuter plans, which you specify, from every suburban administrative unit into your city. Look at the result.
We also have an example program doing something like this, with two example locations. You can use it as a starting point. Edit it to enter coordinates of locations of your choice, and also enter some volumes. You will find hints in the comments.
You may want to randomly blur the home and work location as well as the start times of your agents (or they will all live and work at the exact same spot and leave the house at the same time, leading to funny traffic patterns). Try simply adding a random number to the x and y coordinates of your locations and the start times of your activities.
This example program reads a custom input file which contains census data with activity-travel diaries for the Zurich region. (You will have to download the attached file and place the data sample in the input directory). Look there if you want to create plans from census data and need to read your own input file. Of course, you will have to make heavy adaptations so it suits your particular input data, but it may be helpful for a start. Create a network for the Zurich region if you want to test and run it!
You can download the source files without line numbers from sourceforge (click on the file, then "download").
| input_files_demandgeneration_tutorial.zip 3.79 MB |