04.I - Initial Demand

The process of creating an initial demand (the "population" of the scenario) can be quite challenging, as a lot of different data sources may be used, depending on what's available. The good thing about MATSim is that you can start with a fairly simple initial demand and improve it later.

Initial Plans

A simple description of agents is as follows:

 <person id="1">
  <plan>
    <act type="home" x="20" y="-5" end_time="06:00:00"  />
    <leg mode="car"  />
    <act type="work" x="80" y="5" end_time="16:00:00"  />
    <leg mode="car"  />
    <act type="home" x="20" y="-5"  />
  </plan>
</person> 

Each person needs a unique identifier id and at least one plan. The plan contains acts and legs. The activities need at least the type, a coordinate-pair (x, y), and an end time (end_time). Legs between activities need a mode, usually set to "car", but do not need any route information at this stage.

NOTES:

  • There is also an activity duration attribute.  At this point (may'10), this is essentially deprecated (because the functional differentiation between "dur" and "end_time" did not work that well).
  • The last activity should not have an end time.

Trip-based initial demand

If you are coming from time-dependent OD matrices, do something like the following

<person id="1">
  <plan>
    <act type="dummy" x="20" y="-5" end_time="06:00:00" />
    <leg mode="car"  />
    <act type="dummy" x="80" y="5" />
  </plan>
</person> 

Note that there is now no return trip.

NOTES:

  • See the notes above under "initial plans".

Activity end times

end_time does not have to be an exact value; with certain set-ups, the simulation can modify these attributes to find better values on its own.

On the other hand, if you are coming from time-dependent OD matrices, you should  "smear out" the activity end times (= trip departure times) over the time period of the validity of the matrix, and then not use the "TimeAllocationMutator" later.

Connection to links

The simulation expects all activities to take place on links. When you run MATSim, it will automatically reference all activities with their nearest link. The plans file which MATSim puts in its output directory will contain the link ids for all activities, as well as routes for all legs.

Generating a plans file

In most situations, you will not create a plans file by hand, but write a Java program which generates it from some data source or by some algorithm.  See matsim.org/node/340.