# An Initial Implementation of Multiagent Simulation of Travel Behavior for a Medium-Sized City in China

Authors: Chengxiang Zhuge; Chunfu Shao; Jian Gao; Meng Meng; Weiyang Xu
Journal: Mathematical Problems in Engineering
 (2014)

---

## Abstract

Since the traditional four-step model is so simple that it cannot solve complex modern transportation problems, microsimulation is gradually applied for transportation planning and some researches indicate that it is more compatible and realistic. In this paper, a framework of agent-based simulation of travel behavior is proposed, which is realized by MATSim, a simulation tool developed for large-scale agent-based simulation. MATSim is currently developed and some of its models are under training, so a detailed introduction of simulation structure and preparation of input data will be presented. In practice, the preparation process differs from one to another in different simulation projects because the available data for simulation is various. Thus, a simulation of travel behavior under a condition of limited available survey data will be studied based on MATSim; furthermore, a medium-sized city in China will be taken as an example to check whether agent-based simulation of travel behavior can be successfully applied in China.


---

## Body

## 1. Introduction

Traffic forecasting, no matter if short-term or long-term, macroscopic or microscopic, static or dynamic, is an attractive issue in transportation planning. Four-step process, which is a famous traditional forecasting method, cannot be realistic and complex enough to solve modern transportation planning problems emerging in recent years with rapid urban development. Its shortcoming is especially expressed in two aspects [1].(i) Static Traffic Assignment. The four-step process regards the steam flows as static (time independent), which makes it difficult or impossible to model any kind of time-dependent effects and like peak traffic spreading; congestion spillback.(ii) Aggregate Individuals’ Behavior. Transportation demand is naturally derived from performing activities at different locations which is the result of a series of decisions made by individuals. The four-step process’s aggregation feature cannot solve transportation problems from the root.In order to overcome the shortcoming above, combining the Dynamic Traffic Assignment (DTA) and Activity-Based Model (ABM) is an efficient solution. In the past decades, with the survey data for transport planning getting more detailed and complex, as well as the fact that the performance of computer hardware has been rapidly growing, a multiagent simulation, which integers the features of DTA’s dynamic and ABM’s individual, comes into being. By using multiagent simulation technology, each traveler is regarded as an individual agent who can make decisions according to his/her own goals, attributes, preference, resources, and so forth. Thus, different agents will make different decisions even though they stay in the same environment.In addition, the features of the dynamic of DTA and the individual of ABM are as follows.(i) ABM’s Individual. Each agent will make independent decisions and store its decisions in a “plan” which mainly includes its activity time and location.(ii) DTA’s Dynamic. After creating agents’ initial plan, a dynamic iteration of agents’ route choice and time distribution will be carried out, which allows tracking persons dynamically in time; the goal of iteration is to find a dynamic balance, which is similar to Nash Equilibrium.The agent-based microsimulation modeling technique for transportation planning is rapidly developed and is frequently applied to practice in recent years. This paper will use the MATSim as the multiagent simulation tool to simulate the travellers’ behavior. MATSim which was developed by TU Berlin, ETH Zürich, and CNRS Lyon, provides a toolbox to implement large-scale agent-based transport simulations [2]. A more detailed introduction can be found in Section 3.This paper will start with the literature review concerning the latest advancement of traffic assignment, such as DTA, ABM, and MATSim (Section2). Then it will present the outline of the general simulation structure (Section 3) and a detailed description of the modules in MATSim. Next, we will take Baoding, one of the medium-sized cities in China, as an example, and the way to prepare the input data and to establish the scenarios is introduced (Section 4). Then the simulated results are compared with count data to validate the proposed simulation method (Section 5). Finally, it ends up with a conclusion (Section 6).


## 2. Literature Review

Traffic assignment plays an important role in the study of transportation problems [3–6]. The literature review below will focus on the latest advancement of traffic assignment, which will include DTA, ABM, and MATSim.DTA is commonly used to search the best route for users in a scenario where no users can get better off by selecting another route, and the scenario is called Nash Equilibrium statement. A host of research regarding DTA has been conducted. Florian et al. described a simulation-based, iterative dynamic equilibrium traffic assignment model [7]. Bellei et al. presented a new formulation of within-day DTA, where dynamic user equilibrium is expressed as a fixed-point problem in terms of arc flow temporal profiles [8]. Muñoz and Laval studied the system optimum DTA in a network consisting of a hypothetical surface street grid and a congested freeway section [9]. Szeto et al. proposed a cell-based multiclass DTA problem that considers the random evolution of traffic states [10]. Juran et al. developed a DTA model that can evaluate the effects of moving bottlenecks on network performance in terms of both travel times and traveling paths [11]. Antoniou et al. presented an online calibration approach that jointly estimates demand and supply parameters of DTA systems and it was empirically validated through an extensive application [12]. Gentile et al. proposed a new model for the within-day DTA on road networks where the simulation of queue spillovers is explicitly addressed, and a user equilibrium is expressed as a fixed-point problem in terms of arc flow temporal profiles [13].ABM is modeled on an individual level and successfully implemented by many models and it was employed to address variety of transportation problems [14, 15]. Davidson et al. summarized the recent successful experience in the development and application of ABM for metropolitan planning organizations in the US [16]. Hatzopoulou and Miller extended the capability of an ABM for the Greater Toronto Area to model and map traffic emissions and atmospheric dispersion [17]. Dong et al. employed the activity-based theory to model a new measure of accessibility called activity-based accessibility [18]. Recker et al. presented an estimation procedure for an ABM to estimate the relative importance of factors related to spatial and temporal interrelationships among the out-of-home activities that motivate a household’s need or desire to travel [19]. Kang and Recker applied an ABM to evaluate the potential impacts of plug-in hybrid electric vehicles on energy and emissions [20]. Pendyala et al. developed a comprehensive multimodal activity-based system to predict the travel demand in Florida and the outcome of research was Florida Activity Mobility Simulator (FAMOS) [21]. Yagi and Mohammadian developed a comprehensive activity-based modeling system in the context of developing countries, providing accurate estimates which are expected to serve as better inputs for evaluation of different transportation policy scenarios [22].There is a wide application of DTA and ABM which can be proved by the review above, but combining both theories is seldom implemented [23, 24]. MATSim, which incorporates both DTA and ABM, is an efficient tool to implement a large-scale agent-based simulation for travel behavior and traffic flow and their interactions. So far, research on MATSim has been conducted widely by many scholars, and the scope of the research mainly focuses on three aspects. (1) Basic theory for designing and implementing MATSim. At the beginning, the emphasis was placed on establishing framework of MATSim and incorporating basic models to make it run [25–27]. (2) Optimization of MATSim. At the second stage, the modes of MATSim, such as location choice [28] and mode choice [29], were enhanced and some of them were replaced with advanced ones. (3) Application of MATSim. MATSim is applied into varieties of aspects, like travel behavior [30, 31], parking behavior [32], and freight transport [33].In conclusion, MATSim has been developed for many years and attracted a variety of researchers to apply it or optimize it, but there is still some reaming interesting work. In this paper, an external work to enrich the MATSim application will be carried out and it differs from other studies in the following aspects.(i) MATSim will be used to simulate one of the medium-sized cities in China. A Chinese medium-sized city will be quite different from cities in foreign counties in urban development, activity type, travel behavior, and so on. In addition, a large-scale simulation of travel behavior was seldom implemented in a real city; many of the studies used numerical examples to validate simulation models of travel behavior.(ii) Since different cities have different available traffic survey data, they differ in quality, spatial resolution, purpose, and so forth. An approach of how to prepare the input data with limited available information and low spatial resolution is studied in this paper.


## 3. Simulation Structure

### 3.1. A Brief Introduction of the Simulation Structure

Based on MATSim, the simulation structure of travel behavior is designed and shown in Figure1. It mainly includes three parts: input, evolutionary algorithm (EA), and Output. Firstly, the input data (including initial demand and network) will be fed into the mobility simulation (see Section 3.2) and all agents’ plans will be executed simultaneously, and then the execution results (simulated data) will tell the other modules what happened during the simulated day; secondly, every executed plan will be scored based on the simulated data on the basis of the scoring function (see Section 3.3); thirdly, according to the scoring, the replanning (including Reroute and Time Allocation Mutator, see Section 3.4) is carried out to provide the feedback which allows for the evolution of plans. Finally, after reaching the customized times of iteration, the simulation results, such as optimization statistics and analysis, intermediate plan, and relaxed plan, will be put out.Figure 1
Schematic overview of MATSim’s simulation structure.For EA is the core part of the simulation, it will be first discussed in detail in the following sections.


### 3.2. Execution (Mobsim)

The mobility simulation (Mobsim) refers to the simulation of the physical transportation system. It creates events for every agent’s action in the simulation, like entering/leaving road and departing/arriving at activity places. Then the events will be used for the scoring module. In the history of MATSim, several MobSims such as QueueSimulation, QSim, DEQSim, and JDEQSim have been developed. Some of them are still in use; others are obsolete and no longer supported today. This paper will choose Qsim which is the most commonly used Mobsim. Qsim is an external queue simulation, in which every link is regarded as a first-in first-out (FIFO) queue with three restrictions [1].(i)
Every agent has to stay on the simulated link for a certain time.
(ii)
Link storage capacity is imported to limit the number of agents on the simulated link.
(iii)
Flow capacity is imported to limit the number of agents that can leave the simulated link in a given period of time.Even though the queue simulation is indeed simple, the simulated output data is enough for transportation planning.


### 3.3.  Scoring

In order to compare different plans, a scoring function is proposed to evaluate each plan’s performance. In MATSim, the utility-based approach is used. The detailed function is as follows [1].(i) The Total Score of a Plan. It is calculated based on the following equation:
(1)
U
total
=
∑
i
=
1
n
U
perf
,
i
+
∑
i
=
1
n
U
late
,
i
+
∑
i
=
1
n
U
travel
,
i
,
where U
total is a total score of a given plan; n is the number of activities; U
perf
,
i is the utility for performing activity i; U
late
,
i is the utility for arriving late to activity i; and U
travel
,
i is the utility for travelling to activity i.(ii) The Utility for Performing Activity. A logarithmic form is used for the utility, as follows:
(2)
U
perf
,
i
(
t
perf
,
i
)
=
max
[
0
,
β
perf
·
t
i
*
(
ln
(
β
perf
t
i
*
)
+
ς
p
·
t
i
*
)
]
,
where t
perf
,
i is the actual performed duration of the activity i; β
perf is the marginal utility of an activity at its typical duration; t
i
* is the “typical” duration of an activity i; ς is a scaling constant, and p is a priority indicator.(iii) The Utility for Arriving Late to Activity. Consider
(3)
U
late
,
i
=
β
late
·
t
late
,
i
,
where β
late
≤
0 is the marginal utility for being late; t
late
,
i is the number of hours being late to activity i.(iv) The Utility for Travelling to Activity. Consider
(4)
U
travel
,
i
=
β
travel
·
t
taverl
,
i
,
where β
travel
≤
0 is the marginal utility for travelling; t
travel
,
i is the number of hours for travelling to activity i.More detailed information about the scoring function can be found in the references of Balmer, 2007 [1], and Charypar and Nagel, 2005 [34].


### 3.4. Replanning

The replanning module is established to search for a solution space for every agent and it mainly includes two submodules: Reroute module and Time Allocation Mutator module. Reroute module allows agents adjust their route from origin to destination; Time Allocation Mutator module enables agents to modify their own departure times and activity durations or change activity locations and activity sequence. More details about the modules above are as follows [1].


#### 3.4.1. Reroute Module

The goal of the Reroute module is to help agents find their shortest path in the network. The “shortness” is measured by travel time rather than travel distance. The most famous and most frequently used routing algorithm is Dijkstra. In MATSim, a time-dependent Dijkstra is applied. This algorithm can make the link travel time dependent by aggregating it into 15 min time bins. Link travel time is calculated based on the previous traffic flow simulation and used as the weight of the links in the network graph. With the weights plus the origin and destination of the activities, the fastest path can be calculated, which will be executed in the next mobility simulation.


#### 3.4.2. Time Allocation Mutator

Time Allocation Mutator is a very simple random mutation module but it is very useful for agents’ replanning. Being similar to Reroute module, simple modules together with a large number of iterations will obtain useful results for simulation of travel behavior.Time Allocation Mutator mainly modifies the activities’ duration time and end time (but for the first and last activity, end time is the only attribute modified). The detailed modification process is as follows: firstly, read every agent’s plan; secondly, pick a random time from the uniform distribution [−30 min, +30 min]; thirdly, add the random time to the activities’ duration time and end time; finally, write back the plan with time attribute modified. But pay attention to the random time as (1) any negative duration will be reset to zero; (2) any first activity end time before 00:00 AM and last activity end time after 24:00 PM will be reset to 00:00 AM and 24:00 PM, respectively.


### 3.5. Controller (Agent Database)

Controller makes the module of execution, scoring, and replanning run successively, and the controlled content is as follows [1].(i) Number of Plans. The number of the plans per agent will be limited to N (N
≥
2; usually N is 3–6). If an agent has N
+
1 plan (the additional plan is generated in the replanning process) the N
+
1 Plan will be stored in the agent’s memory until the new plan scores. After scoring, the controller will delete the lowest-score plan.(ii) Select Agents Performing Reroute (
r
%
). The controller selects r
% of agents to carry out the module of Reroute (see Section 3.4.1). The plans in the memory will be selected with equal probability.(iii) Select Agents Performing Time Allocation Mutator
(
s
%
). The controller selects s
% of agents to carry out the module of Time Allocation Mutator (see Section 3.4.1), however, after that, those agents will also carry out the module of Reroute. The plans in the memory will be selected with equal probability. Thus, s% of agents will carry out Time Allocation Mutator and (s% + r%) of agents will carry out Reroute.(iv) Select Random Plan (
m
%
). In order to re-evaluate the existing plans from time to time, the controller selects m
% of agents and those agents will randomly choose a plan among all plans in their memory.(v) Select Plans Based on the Scores
(
p
%
=
1
-
r
%
-
s
%
-
m
%
)
. The controller finally selects the remained plans with the following probability:
(5)
p
∝
e
β
·
S
j
,whereS
j is the score of the plan j; β is an empirical constant.Note. If the controller selects an existing plan, its new score can be calculated with
(6)
S
=
(
1
-
α
)
·
S
old
+
α
·
S
new
,
where α is the blending factor, this will avoid agent selecting plans based on not only last iteration, but also the history scores.The controller will make the loop run until the simulation system reach a relaxed state.


## 3.1. A Brief Introduction of the Simulation Structure

Based on MATSim, the simulation structure of travel behavior is designed and shown in Figure1. It mainly includes three parts: input, evolutionary algorithm (EA), and Output. Firstly, the input data (including initial demand and network) will be fed into the mobility simulation (see Section 3.2) and all agents’ plans will be executed simultaneously, and then the execution results (simulated data) will tell the other modules what happened during the simulated day; secondly, every executed plan will be scored based on the simulated data on the basis of the scoring function (see Section 3.3); thirdly, according to the scoring, the replanning (including Reroute and Time Allocation Mutator, see Section 3.4) is carried out to provide the feedback which allows for the evolution of plans. Finally, after reaching the customized times of iteration, the simulation results, such as optimization statistics and analysis, intermediate plan, and relaxed plan, will be put out.Figure 1
Schematic overview of MATSim’s simulation structure.For EA is the core part of the simulation, it will be first discussed in detail in the following sections.


## 3.2. Execution (Mobsim)

The mobility simulation (Mobsim) refers to the simulation of the physical transportation system. It creates events for every agent’s action in the simulation, like entering/leaving road and departing/arriving at activity places. Then the events will be used for the scoring module. In the history of MATSim, several MobSims such as QueueSimulation, QSim, DEQSim, and JDEQSim have been developed. Some of them are still in use; others are obsolete and no longer supported today. This paper will choose Qsim which is the most commonly used Mobsim. Qsim is an external queue simulation, in which every link is regarded as a first-in first-out (FIFO) queue with three restrictions [1].(i)
Every agent has to stay on the simulated link for a certain time.
(ii)
Link storage capacity is imported to limit the number of agents on the simulated link.
(iii)
Flow capacity is imported to limit the number of agents that can leave the simulated link in a given period of time.Even though the queue simulation is indeed simple, the simulated output data is enough for transportation planning.


## 3.3.  Scoring

In order to compare different plans, a scoring function is proposed to evaluate each plan’s performance. In MATSim, the utility-based approach is used. The detailed function is as follows [1].(i) The Total Score of a Plan. It is calculated based on the following equation:
(1)
U
total
=
∑
i
=
1
n
U
perf
,
i
+
∑
i
=
1
n
U
late
,
i
+
∑
i
=
1
n
U
travel
,
i
,
where U
total is a total score of a given plan; n is the number of activities; U
perf
,
i is the utility for performing activity i; U
late
,
i is the utility for arriving late to activity i; and U
travel
,
i is the utility for travelling to activity i.(ii) The Utility for Performing Activity. A logarithmic form is used for the utility, as follows:
(2)
U
perf
,
i
(
t
perf
,
i
)
=
max
[
0
,
β
perf
·
t
i
*
(
ln
(
β
perf
t
i
*
)
+
ς
p
·
t
i
*
)
]
,
where t
perf
,
i is the actual performed duration of the activity i; β
perf is the marginal utility of an activity at its typical duration; t
i
* is the “typical” duration of an activity i; ς is a scaling constant, and p is a priority indicator.(iii) The Utility for Arriving Late to Activity. Consider
(3)
U
late
,
i
=
β
late
·
t
late
,
i
,
where β
late
≤
0 is the marginal utility for being late; t
late
,
i is the number of hours being late to activity i.(iv) The Utility for Travelling to Activity. Consider
(4)
U
travel
,
i
=
β
travel
·
t
taverl
,
i
,
where β
travel
≤
0 is the marginal utility for travelling; t
travel
,
i is the number of hours for travelling to activity i.More detailed information about the scoring function can be found in the references of Balmer, 2007 [1], and Charypar and Nagel, 2005 [34].


## 3.4. Replanning

The replanning module is established to search for a solution space for every agent and it mainly includes two submodules: Reroute module and Time Allocation Mutator module. Reroute module allows agents adjust their route from origin to destination; Time Allocation Mutator module enables agents to modify their own departure times and activity durations or change activity locations and activity sequence. More details about the modules above are as follows [1].


### 3.4.1. Reroute Module

The goal of the Reroute module is to help agents find their shortest path in the network. The “shortness” is measured by travel time rather than travel distance. The most famous and most frequently used routing algorithm is Dijkstra. In MATSim, a time-dependent Dijkstra is applied. This algorithm can make the link travel time dependent by aggregating it into 15 min time bins. Link travel time is calculated based on the previous traffic flow simulation and used as the weight of the links in the network graph. With the weights plus the origin and destination of the activities, the fastest path can be calculated, which will be executed in the next mobility simulation.


### 3.4.2. Time Allocation Mutator

Time Allocation Mutator is a very simple random mutation module but it is very useful for agents’ replanning. Being similar to Reroute module, simple modules together with a large number of iterations will obtain useful results for simulation of travel behavior.Time Allocation Mutator mainly modifies the activities’ duration time and end time (but for the first and last activity, end time is the only attribute modified). The detailed modification process is as follows: firstly, read every agent’s plan; secondly, pick a random time from the uniform distribution [−30 min, +30 min]; thirdly, add the random time to the activities’ duration time and end time; finally, write back the plan with time attribute modified. But pay attention to the random time as (1) any negative duration will be reset to zero; (2) any first activity end time before 00:00 AM and last activity end time after 24:00 PM will be reset to 00:00 AM and 24:00 PM, respectively.


## 3.4.1. Reroute Module

The goal of the Reroute module is to help agents find their shortest path in the network. The “shortness” is measured by travel time rather than travel distance. The most famous and most frequently used routing algorithm is Dijkstra. In MATSim, a time-dependent Dijkstra is applied. This algorithm can make the link travel time dependent by aggregating it into 15 min time bins. Link travel time is calculated based on the previous traffic flow simulation and used as the weight of the links in the network graph. With the weights plus the origin and destination of the activities, the fastest path can be calculated, which will be executed in the next mobility simulation.


## 3.4.2. Time Allocation Mutator

Time Allocation Mutator is a very simple random mutation module but it is very useful for agents’ replanning. Being similar to Reroute module, simple modules together with a large number of iterations will obtain useful results for simulation of travel behavior.Time Allocation Mutator mainly modifies the activities’ duration time and end time (but for the first and last activity, end time is the only attribute modified). The detailed modification process is as follows: firstly, read every agent’s plan; secondly, pick a random time from the uniform distribution [−30 min, +30 min]; thirdly, add the random time to the activities’ duration time and end time; finally, write back the plan with time attribute modified. But pay attention to the random time as (1) any negative duration will be reset to zero; (2) any first activity end time before 00:00 AM and last activity end time after 24:00 PM will be reset to 00:00 AM and 24:00 PM, respectively.


## 3.5. Controller (Agent Database)

Controller makes the module of execution, scoring, and replanning run successively, and the controlled content is as follows [1].(i) Number of Plans. The number of the plans per agent will be limited to N (N
≥
2; usually N is 3–6). If an agent has N
+
1 plan (the additional plan is generated in the replanning process) the N
+
1 Plan will be stored in the agent’s memory until the new plan scores. After scoring, the controller will delete the lowest-score plan.(ii) Select Agents Performing Reroute (
r
%
). The controller selects r
% of agents to carry out the module of Reroute (see Section 3.4.1). The plans in the memory will be selected with equal probability.(iii) Select Agents Performing Time Allocation Mutator
(
s
%
). The controller selects s
% of agents to carry out the module of Time Allocation Mutator (see Section 3.4.1), however, after that, those agents will also carry out the module of Reroute. The plans in the memory will be selected with equal probability. Thus, s% of agents will carry out Time Allocation Mutator and (s% + r%) of agents will carry out Reroute.(iv) Select Random Plan (
m
%
). In order to re-evaluate the existing plans from time to time, the controller selects m
% of agents and those agents will randomly choose a plan among all plans in their memory.(v) Select Plans Based on the Scores
(
p
%
=
1
-
r
%
-
s
%
-
m
%
)
. The controller finally selects the remained plans with the following probability:
(5)
p
∝
e
β
·
S
j
,whereS
j is the score of the plan j; β is an empirical constant.Note. If the controller selects an existing plan, its new score can be calculated with
(6)
S
=
(
1
-
α
)
·
S
old
+
α
·
S
new
,
where α is the blending factor, this will avoid agent selecting plans based on not only last iteration, but also the history scores.The controller will make the loop run until the simulation system reach a relaxed state.


## 4. Input Data and Scenario

The structure of MATSim may not be complex, but preparing the input data and constructing a simulation scenario are much more sophisticated. In practice, there is a large variety of input data which can differ in quality, spatial resolution, purpose, and so forth. So it will generally take months, even years, to prepare the correct data for simulation. In order to run a simulation, the lowest requirement includes an initial plan, a road network, and a simulation configuration. The detailed process of preparing the above data will be presented as follows.


### 4.1. Scenario Description

#### 4.1.1. A Brief Introduction of Baoding

This paper will take Baoding as an example to simulate a medium-sized city in China. Baoding, which is located in Hebei Province, is made up of one main urban area and four counties (Mancheng County, Xushi County, Anxin County, and Qingyuan County). This paper will only simulate the travel behavior of inhabitants in the main urban area. The main urban area of Baoding has a population of 1.06 million.


#### 4.1.2. Activity Chains and Their Distribution

In this paper, only the resident driving private car is simulated. Based on the census 2007 of Baoding, the activity is classified into five types: home, work, shop, education, and leisure. The analysis results show that home-work-home and home-work-home-work-home are the most common patterns, and the average length of the activity chains is close to 3.


#### 4.1.3. Network Preparation

The simulation network of Baoding is prepared through OpenMapStreet and it includes 502 nodes and 1474 links. The link attributes contain length, capacity, free speed, lanes, modes, and so forth. The road network is showed by Figure2.Figure 2
Road network of Baoding.


### 4.2. Initial Demand Preparation

The modeling of the initial demand can be split up into several steps depending on the available raw data and the planner’s needs. But an initial plan should at least include the following information.(i)
Activity location which is given as a set of coordinates.
(ii)
Assigned departure times and arrival times for every activity.
(iii)
A travel leg among two activities; in this paper, the mode is set as car.Algorithm1 shows a typical initial plan. It includes attributes of the person and his initial plan. The attributes are made up of ID, age, and employment statues. The initial plan is made up of 5 activities, and they are home, work, home, work, and home in sequence, which are set as variable of act type. Take the first activity, for example; the activity location is in the facility with ID of 1593 and its coordinate is represented by variables of x and y, and, besides, the end time of the activity is represented by variable of end_time. The leg mode and dep_time are used to describe the mode the person chooses and time the people leaving the facility.Algorithm 1:An example of a typical initial plan.
<person id=“682” age=“30” employed=“yes”>
<plan selected=“yes”>
<act type=“h9” facility=“1593” x=“365401.69341762” y=“4300664.48060939” end_time=“09:39:27” />
<leg mode=“car” dep_time=“09:39:27”>
</leg>
<act type=“w3” facility=“313” x=“365843.21376734” y=“4306032.0981801” end_time=“13:52:24” />
<leg mode=“car” dep_time=“13:52:24”>
</leg>
<act type=“h1” facility=“1593” x=“365401.69341762” y=“4300664.48060939” end_time=“15:21:30” />
<leg mode=“car” dep_time=“15:21:30”>
</leg>
<act type=“w3” facility=“313” x=“365843.21376734” y=“4306032.0981801” end_time=“17:41:27” />
<leg mode=“car” dep_time=“17:41:27”>
</leg>
<act type=“h9” facility=“1593” x=“365401.69341762” y=“4300664.48060939” />
</plan>
</person>Different available data need different processes to prepare an initial data. Figure3 shows a detailed preparing process based on the available data of Baoding. The process is mainly made up of three parts.Figure 3
The process of preparing the initial data.Part 1: List All the Available Data for Simulation. Part 1 only contains one step, namely step 1. To check all the available data and make better use of them is a vital step in the simulation. Take Baoding, for example; the available data are the census 2007 of Baoding and the map of Baoding in 2007. The census sample includes 2267 persons’ daily plan, but the number of persons whose travel mode is car is 93, which is extremely small. Each daily plan includes trip origin, trip destination, starting time, ending time, activity type, and travelling leg. But unfortunately, the data of trip origin and destination are in traffic zone level, which cannot be directly applied to agent-based simulation and should be adjusted. The map of Baoding in 2007 comprises the available facilities for performing activities, such as shopping, leisure, and work.Part 2: Prepare Data for Generating Initial Plan. Part 2 is made up of step 2, step 3, and step 4.In step 2, since the survey sample is really small, the MATSim population is synthesized on the basis of census. MTSim population includes a few persons (agents) whose information only includes age, home location, and work location and all the above information is stored in MATSimPop.txt, which will be used for generating initial plan.In step 3, generate a true plan file (TPlan.xml) which contains a handful of plans whose travel mode was car based on the census 2007 of Baoding. The following information is included: person ID, trip ID, origin coordinates, destination coordinates, activity duration, and activity type. Note that the trip origin and destination are in traffic zone level, so a random assigning method was used for selecting a location for performing activities.In step 4, prepare the available facilities for performing activities, that is, getting the exact location, type, and attributes of facilities. All the information was saved in Factilities.xml. There were five facility types corresponding to five activity types. The numbers of facilities for shopping, education, leisure, work, and home are 256, 51, 478, 912, and 1321, respectively. In addition, before the facilities location is determined, the coordination transform should be discussed. WGS84-coordinates are widely used, like GPS data, OpenStreetMap data, and Google earth data. For the distance calculation in WGS84-coordinates (or any spherical coordinates) is rather complex, in MATSim, the coordinates should be converted into another coordinate reference system (CRS). This paper chooses the UTM (Universal Transverse Mercartor Grid System) as the coordinate used in MATSim. According to the UTM global zoning, Baoding is located in the zone 50N and its EPSG code is 32650.Part 3: Generating Initial Plan. After preparing the required data (MATSimPop.txt, TPlan.xml, and Factilities.xml) in Part 2, generating initial plan would be conducted.Step 5-1, copy all the information from a true plan, which is stored in TPlan.xml, to the plan of each agent who made up the MATSim population, except for the location of each activity.Step 5-2, randomly assign each activity to a facility based on nearby searching method; thus the location of each activity can be generated. The detailed searching method is described with an example as follows. Assume that an agent ends its previous activity and goes shopping next, the controller of the MATSim will define a circle around the previous activity location with a certain radius (the radius is represented asR), and the agent will randomly choose a facility for shopping. In real life, inhabitants will tend to choose a nearer school for education, choose a nearer shop/market for shopping, and so on. So the concept of the searching method seems to be realistic. The R was set to 3 km, according to Baoding’s size, population and so on. The schematic diagram is showed in Figure 4.Figure 4
Schematic diagram of randomly assigning each activity to a facility.Step 5-3, generate the start and end time of each activity on the basis of activity duration. For example, the end time of the previous activity isP
endtime, and the duration of the next performed activity is T
duration; then the Gaussian function is used to generate the next activity’s end time, and the equation is as follows:
(7)
T
endtime
=
P
endtime
+
T
duration
+
Gaussian
·
3600
,
where T
endtime is the end time of the next activity. Gaussian represents the rand number generated based on Gaussian distribution whose mean is 0 and the standard deviation is 1.When all the above steps are completed, the initial plan is finally created.


### 4.3. Count Data

Inputting count data to MATSim is a typical way to check whether the simulation of travel behavior is realistic. In this paper, six count stations’ data will be used. The count data is obtained by an artificial method. The survey time is at May 10, 2007, from 7:00 AM to 9:00 AM.


### 4.4. Simulation Configuration

In this paper, two different simulation scenarios will be built up.(i)
Scenario 1: 10% of all agents carry out Reroute.
(ii)
Scenario 2: 10% of all agents will carry out Time Allocation Mutator, but these agents will also carry out Reroute after time changes.Other simulation configurations of the above three scenarios are the same.(i)
The number of the plans stored in each agent’s memory is limited to 5.
(ii)
10% of all agents will randomly select an existing plan.
(iii)
The remaining 70% of all agents will select an existing plan based on the plan scores.
(iv)
The number of iterations will be set to 50.
(v)
The “QSim” module will be used for mobility simulation.


## 4.1. Scenario Description

### 4.1.1. A Brief Introduction of Baoding

This paper will take Baoding as an example to simulate a medium-sized city in China. Baoding, which is located in Hebei Province, is made up of one main urban area and four counties (Mancheng County, Xushi County, Anxin County, and Qingyuan County). This paper will only simulate the travel behavior of inhabitants in the main urban area. The main urban area of Baoding has a population of 1.06 million.


### 4.1.2. Activity Chains and Their Distribution

In this paper, only the resident driving private car is simulated. Based on the census 2007 of Baoding, the activity is classified into five types: home, work, shop, education, and leisure. The analysis results show that home-work-home and home-work-home-work-home are the most common patterns, and the average length of the activity chains is close to 3.


### 4.1.3. Network Preparation

The simulation network of Baoding is prepared through OpenMapStreet and it includes 502 nodes and 1474 links. The link attributes contain length, capacity, free speed, lanes, modes, and so forth. The road network is showed by Figure2.Figure 2
Road network of Baoding.


## 4.1.1. A Brief Introduction of Baoding

This paper will take Baoding as an example to simulate a medium-sized city in China. Baoding, which is located in Hebei Province, is made up of one main urban area and four counties (Mancheng County, Xushi County, Anxin County, and Qingyuan County). This paper will only simulate the travel behavior of inhabitants in the main urban area. The main urban area of Baoding has a population of 1.06 million.


## 4.1.2. Activity Chains and Their Distribution

In this paper, only the resident driving private car is simulated. Based on the census 2007 of Baoding, the activity is classified into five types: home, work, shop, education, and leisure. The analysis results show that home-work-home and home-work-home-work-home are the most common patterns, and the average length of the activity chains is close to 3.


## 4.1.3. Network Preparation

The simulation network of Baoding is prepared through OpenMapStreet and it includes 502 nodes and 1474 links. The link attributes contain length, capacity, free speed, lanes, modes, and so forth. The road network is showed by Figure2.Figure 2
Road network of Baoding.


## 4.2. Initial Demand Preparation

The modeling of the initial demand can be split up into several steps depending on the available raw data and the planner’s needs. But an initial plan should at least include the following information.(i)
Activity location which is given as a set of coordinates.
(ii)
Assigned departure times and arrival times for every activity.
(iii)
A travel leg among two activities; in this paper, the mode is set as car.Algorithm1 shows a typical initial plan. It includes attributes of the person and his initial plan. The attributes are made up of ID, age, and employment statues. The initial plan is made up of 5 activities, and they are home, work, home, work, and home in sequence, which are set as variable of act type. Take the first activity, for example; the activity location is in the facility with ID of 1593 and its coordinate is represented by variables of x and y, and, besides, the end time of the activity is represented by variable of end_time. The leg mode and dep_time are used to describe the mode the person chooses and time the people leaving the facility.Algorithm 1:An example of a typical initial plan.
<person id=“682” age=“30” employed=“yes”>
<plan selected=“yes”>
<act type=“h9” facility=“1593” x=“365401.69341762” y=“4300664.48060939” end_time=“09:39:27” />
<leg mode=“car” dep_time=“09:39:27”>
</leg>
<act type=“w3” facility=“313” x=“365843.21376734” y=“4306032.0981801” end_time=“13:52:24” />
<leg mode=“car” dep_time=“13:52:24”>
</leg>
<act type=“h1” facility=“1593” x=“365401.69341762” y=“4300664.48060939” end_time=“15:21:30” />
<leg mode=“car” dep_time=“15:21:30”>
</leg>
<act type=“w3” facility=“313” x=“365843.21376734” y=“4306032.0981801” end_time=“17:41:27” />
<leg mode=“car” dep_time=“17:41:27”>
</leg>
<act type=“h9” facility=“1593” x=“365401.69341762” y=“4300664.48060939” />
</plan>
</person>Different available data need different processes to prepare an initial data. Figure3 shows a detailed preparing process based on the available data of Baoding. The process is mainly made up of three parts.Figure 3
The process of preparing the initial data.Part 1: List All the Available Data for Simulation. Part 1 only contains one step, namely step 1. To check all the available data and make better use of them is a vital step in the simulation. Take Baoding, for example; the available data are the census 2007 of Baoding and the map of Baoding in 2007. The census sample includes 2267 persons’ daily plan, but the number of persons whose travel mode is car is 93, which is extremely small. Each daily plan includes trip origin, trip destination, starting time, ending time, activity type, and travelling leg. But unfortunately, the data of trip origin and destination are in traffic zone level, which cannot be directly applied to agent-based simulation and should be adjusted. The map of Baoding in 2007 comprises the available facilities for performing activities, such as shopping, leisure, and work.Part 2: Prepare Data for Generating Initial Plan. Part 2 is made up of step 2, step 3, and step 4.In step 2, since the survey sample is really small, the MATSim population is synthesized on the basis of census. MTSim population includes a few persons (agents) whose information only includes age, home location, and work location and all the above information is stored in MATSimPop.txt, which will be used for generating initial plan.In step 3, generate a true plan file (TPlan.xml) which contains a handful of plans whose travel mode was car based on the census 2007 of Baoding. The following information is included: person ID, trip ID, origin coordinates, destination coordinates, activity duration, and activity type. Note that the trip origin and destination are in traffic zone level, so a random assigning method was used for selecting a location for performing activities.In step 4, prepare the available facilities for performing activities, that is, getting the exact location, type, and attributes of facilities. All the information was saved in Factilities.xml. There were five facility types corresponding to five activity types. The numbers of facilities for shopping, education, leisure, work, and home are 256, 51, 478, 912, and 1321, respectively. In addition, before the facilities location is determined, the coordination transform should be discussed. WGS84-coordinates are widely used, like GPS data, OpenStreetMap data, and Google earth data. For the distance calculation in WGS84-coordinates (or any spherical coordinates) is rather complex, in MATSim, the coordinates should be converted into another coordinate reference system (CRS). This paper chooses the UTM (Universal Transverse Mercartor Grid System) as the coordinate used in MATSim. According to the UTM global zoning, Baoding is located in the zone 50N and its EPSG code is 32650.Part 3: Generating Initial Plan. After preparing the required data (MATSimPop.txt, TPlan.xml, and Factilities.xml) in Part 2, generating initial plan would be conducted.Step 5-1, copy all the information from a true plan, which is stored in TPlan.xml, to the plan of each agent who made up the MATSim population, except for the location of each activity.Step 5-2, randomly assign each activity to a facility based on nearby searching method; thus the location of each activity can be generated. The detailed searching method is described with an example as follows. Assume that an agent ends its previous activity and goes shopping next, the controller of the MATSim will define a circle around the previous activity location with a certain radius (the radius is represented asR), and the agent will randomly choose a facility for shopping. In real life, inhabitants will tend to choose a nearer school for education, choose a nearer shop/market for shopping, and so on. So the concept of the searching method seems to be realistic. The R was set to 3 km, according to Baoding’s size, population and so on. The schematic diagram is showed in Figure 4.Figure 4
Schematic diagram of randomly assigning each activity to a facility.Step 5-3, generate the start and end time of each activity on the basis of activity duration. For example, the end time of the previous activity isP
endtime, and the duration of the next performed activity is T
duration; then the Gaussian function is used to generate the next activity’s end time, and the equation is as follows:
(7)
T
endtime
=
P
endtime
+
T
duration
+
Gaussian
·
3600
,
where T
endtime is the end time of the next activity. Gaussian represents the rand number generated based on Gaussian distribution whose mean is 0 and the standard deviation is 1.When all the above steps are completed, the initial plan is finally created.


## 4.3. Count Data

Inputting count data to MATSim is a typical way to check whether the simulation of travel behavior is realistic. In this paper, six count stations’ data will be used. The count data is obtained by an artificial method. The survey time is at May 10, 2007, from 7:00 AM to 9:00 AM.


## 4.4. Simulation Configuration

In this paper, two different simulation scenarios will be built up.(i)
Scenario 1: 10% of all agents carry out Reroute.
(ii)
Scenario 2: 10% of all agents will carry out Time Allocation Mutator, but these agents will also carry out Reroute after time changes.Other simulation configurations of the above three scenarios are the same.(i)
The number of the plans stored in each agent’s memory is limited to 5.
(ii)
10% of all agents will randomly select an existing plan.
(iii)
The remaining 70% of all agents will select an existing plan based on the plan scores.
(iv)
The number of iterations will be set to 50.
(v)
The “QSim” module will be used for mobility simulation.


## 5. Results and Discussion

Simulation results of the two different scenarios will be discussed in the following aspects.(i) Comparison of the Number of Departures and Arrivals of Cars between Two Scenarios. Figures 5 and 6 show the number of departures and arrivals of cars between the two scenarios, respectively. Both figures have the same trend which has two peaks. The two peaks occur around 8:00 and 18:00, respectively. In addition, in terms of Figure 4, the first peak of Scenario 2 (Time Allocation Mutator) is lower than Scenario 1 (Reroute) and the number of cars of Scenario 2 is higher than Scenario 1 from 5:00 AM to 8:00 AM, which indicates that some agents advance their departure time to avoid high traffic volume during the peak time. Figure 5 has the same trend as Figure 4 due to the same reason.Figure 5
Comparison of the number of departures of cars between two scenarios.Figure 6
Comparison of the number of arrivals of cars between two scenarios.(ii) Comparison of the Evolution of the Average Best Score and Average Executed Score for the Two Scenarios. Figures 7 and 8 demonstrate the average executed score and average best score of two scenarios, respectively, and they also have the same trend. The score of Scenario 1, which only carries out Reroute, keeps invariant from iteration 0 and iteration 50 in both figures, while the score of Scenario 2, which carries out Time Allocation Mutator, has an increasing trend in both figures. According to the trend mentioned above, we can conclude that Reroute does not improve the agents’ performance, while Time Allocation Mutator has a significantly beneficial influence on the performance of agents. The reason why score of Scenario 1 remains the same is that agents cannot improve their performance through changing their routes.Figure 7
Comparison of the evolution of the average executed score for the two scenarios.Figure 8
Comparison of the evolution of the average best score for the two scenarios.(iii) Comparison of the Simulated Data and the Count Data of the Two Scenarios. The comparison between the simulated data and count data of the two scenarios is presented in Figure 9. Figures 9(a), 9(b), 9(c), and 9(d) demonstrate the comparison in Scenario 1 at 7:00-8:00 AM, in Scenario 2 at 7:00-8:00 AM, in Scenario 1 at 8:00-9:00 AM, and in Scenario 2 at 8:00-9:00 AM, respectively. The bias and error of the simulation results are summarized in Table 1. The mean absolute bias, mean absolute error, mean relative bias, and mean relative error are jointly used to check the simulation results. The equations to calculate the above indicators are as follows:(i)
mean absolute bias:(8)
E
=
1
n
∑
(
q
simulated
-
q
counted
)
,
(ii)
mean absolute error:(9)
|
E
|
=
1
n
∑
(
|
q
simulated
-
q
counted
|
)
,
(iii)
mean relative bias(10)
e
=
1
n
∑
(
q
simulated
-
q
counted
q
counted
)
,
(iv)
mean relative error(11)
|
e
|
=
1
n
∑
(
|
q
simulated
-
q
counted
q
counted
|
)
.Table 1
Bias and error of two scenarios.
Time period
Bias/error
Scenario 1 (Reroute)
Scenario 2 (Time Allocation Mutator)
7:00-8:00 AM
Mean absolute bias
−24
−147
Mean absolute error
158
204
Mean relative bias
−0.75%
−24.04%
Mean relative error
32.09%
37.91%
8:00-9:00 AM
Mean absolute bias
−45
−222
Mean absolute error
252
281
Mean relative bias
6.41%
−25.57%
Mean relative error
44.00%
41.29%
7:00–9:00 AM
Mean absolute bias
−35
−185
Mean absolute error
205
243
Mean relative bias
2.83%
−24.80%
Mean relative error
38.05%
39.60%Comparison between simulated data and count data.
(a)
Simulated data versus count data at 7:00-8:00 AM (Simulation with Reroute only)
(b)
Simulated data versus count data at 7:00-8:00 AM (Simulation with Time Allocation Mutator)
(c)
Simulated data versus count data at 8:00-9:00 AM (Simulation with Reroute only)
(d)
Simulated data versus count data at 8:00-9:00 AM (Simulation with Time Allocation Mutator)In terms of mean relative error, which is commonly used for validating the accuracy of simulation, the accuracy of Scenario 1 (38.05%) is close to Scenario 2 (39.60%) at 7:00–9:00 AM. In addition, from 7:00 AM to 8:00 AM, the mean relative error of Scenario 1 (32.09%) is lower than Scenario 2 (37.91%), while the mean relative error of Scenario 1 (44%) is higher than Scenario 2 (41.29%) from 8 AM to 9 AM; thus Time Allocation Mutator does not perform better than Reroute in terms of simulation accuracy.


## 6. Conclusions

This paper implements the agent-based simulation of travel behavior in a medium-sized city in China, and the main achievements of this paper are as follows:(i)
A detailed simulation structure, which includes a variety of modules, is introduced.
(ii)
Successfully realizing the simulation of travel behavior under a condition of limited survey data, besides, a framework of preparing the input data, is presented.
(iii)
Simulating the travel behavior of residents in a medium-sized city in China by MATSim was seldom done in previous studies.However, the above achievement is only a basic simulation work. In the near future, the related work below will be carried out.(i)
This paper only simulates the travel behavior of resident whose travel mode is car, so other modes will be added to the simulation scenario to check whether agent-based simulation results are still realistic.
(ii)
A large-scale agent-based simulation will be carried out in a Chinese metropolis, such as Beijing, Shanghai, on Guangzhou.
(iii)
Optimize the modules in MATSim to improve its simulation precision and computing time.



---

*Source: 980623-2014-03-13.xml*