Professional Documents
Culture Documents
2010 Chan FSM Eorms0336
2010 Chan FSM Eorms0336
net/publication/319556799
CITATIONS READS
6 7,283
2 authors, including:
Victor W. K. Chan
Tsinghua University
152 PUBLICATIONS 1,318 CITATIONS
SEE PROFILE
All content following this page was uploaded by Victor W. K. Chan on 28 September 2019.
Wiley Encyclopedia of Operations Research and Management Science, edited by James J. Cochran
Copyright © 2010 John Wiley & Sons, Inc.
1
2 FOUNDATIONS OF SIMULATION MODELING
also several other ways of classifying simula- allows modelers to focus on the events, their
tion models including, static versus dynamic, relationships, and durations. To put it in a
deterministic versus stochastic, analytic ver- simple way, creating a discrete-event sim-
sus numeric, and physical versus computer- ulation model is to identify these elements
based. For example, a simulation model is and put them together in a correct manner.
dynamic if time (simulation clock) is present This will be demonstrated by examples in the
and static otherwise. Monte-Carlo simula- following.
tion is one type of static simulation models. Several concepts in discrete-event simu-
Discrete-event and continuous simulations lation modeling are of importance:
are usually dynamic simulation models [1]. randomness, dynamics (time evolutions),
Besides discrete, continuous, and Monte- future-event list (or pending events list or
Carlo simulations, a relatively new simulat- event calendar), and resident and transient
ion paradigm—agent-based simulation—has entities.
received increasing attention in various Randomness is the uncertainty in the
fields over the past two decades. Basically, occurrences of events and durations. Time
agent-based simulation, being a bottom-up evolutions are the footprints of the system
approach, is capable of modeling systems state with respect to time (both occurred
with intelligent, heterogeneous, and auto- events and their times). Randomness and
nomous entities. An agent-based simulation time evolutions together differentiate a disc-
model can be discrete, continuous, or both rete-event simulation model from a standard
depending on the type of its state variables. computer program that is deterministic
One of the main purposes of agent-based and static (i.e., no time involved). Almost
simulation is to simulate know or unknown all simulation packages provide simple
macroscopic behavior emerging from micro- mechanisms to implement randomness
scopic interactions. (i.e., by specifying distributions for event
The rest of the article is organized as durations and relationships) and handle
follows. The section titled ‘‘Discrete-Event time evolutions (i.e., by providing access to
Simulation Models’’ discusses three discrete- the current and future simulated times).
event simulation modeling approaches. The A future-event list keeps track of the
section titled ‘‘Continuous Simulation Mod- events scheduled to occur in the simulated
els’’ outlines continuous simulation models. future. This list is updated whenever a new
The section titled ‘‘Agent-Based Models’’ event is scheduled to occur in the simulated
highlights several key concepts in agent- future. This list is automatically generated
based simulation. The section titled ‘‘Monte- and updated in most simulation packages.
Carlo Models’’ briefly introduces Monte- Users sometimes can also access and modify
Carlo simulation. The final section offers a this list.
conclusion. Resident entities are objects that reside in
the model for a long period of time compared
to the simulation run length, for example, a
DISCRETE-EVENT SIMULATION MODELS facility, a server, or a queue. Transient enti-
ties on the other hand appear in the model
One special property of a discrete-event sys- for a short period of time, for example, a job,
tem is that its state changes only at dis- a customer, or a message. The population
crete instants of time. These instants of time of resident entities is usually much smaller
represent the occurrences of certain events than that of transient entities. In a typical
that change the state of the system and are queuing model, the number of servers is usu-
referred to event occurrence times (or sim- ally less than a hundred while the number
ply, event times). The system state remains of jobs/customers can be tens of thousands
constant in between event times because or millions. The large population of transient
during which no events occur. This special entities poses a computational burden if each
property facilitates the modeling and anal- of them is stored in memory and requires
ysis of discrete-event simulation because it a certain amount of computation. A more
FOUNDATIONS OF SIMULATION MODELING 3
efficient modeling approach is to keep track in the simulation results. This is demon-
of the aggregated information of the tran- strated in the following example.
sient entities, such as the total number of A discrete-event simulation model can be
jobs in queue or the total waiting time of created using different world views, which
jobs in the system, rather than the indi- were first discussed in Kiviat [4] and Lack-
vidual information, such as the individual ner [5]. Three popular world views: event
waiting time of each job. Because this aggre- scheduling, process interaction, and activity
gated information is usually associated with scanning, are introduced in the following.
some resident entities, e.g., the queue size, Before that, let us first outline a typical algo-
this approach is called the resident-entity rithm for executing a discrete-event simula-
approach. The drawback of this approach tion model. This algorithm is essentially an
is that the individual characteristics of the event-scheduling algorithm. Most software
transient entities are lost. Nevertheless, this packages employ a similar execution algo-
approach has been shown to significantly rithm. If one prefers not to use existing sim-
improve simulation speed and memory usage ulation packages, he/she can also implement
[2, 3]. Indeed, it is sometimes possible to the algorithm by using a general-purpose pro-
avoid memorizing individual characteristics gramming language, such as C/C++.
and still be able to obtain the same accuracy
a job leaves, if there is more work waiting, returns an interarrival time generated from a
then service can start on the next job’’ [6]. given distribution (i.e., a = Fa−1 (u), where u is
Almost all information necessary to build a uniform random number between 0 and 1),
this single-server model is embedded in above s returns a service time duration generated
paragraph. To see this, we highlight the key from a given distribution (i.e., s = Fs−1 (u)).
words in three different formats: bold face, We now ready to extend this model
underline, and italics. The words in bold face to our final multiple-server system with
represent the events: ‘‘enter,’’ ‘‘start,’’ ‘‘leave,’’ queue capacity and impatient customers.
and the initial event ‘‘begin,’’ which only exe- Two important discrete-event simulation
cutes once. The underlined words denote the modeling techniques are used: Boolean
random time durations. Here, ‘‘random inter- expressions and look-ahead capability. To
vals of arrivals’’ are the interarrival times of model the queue capacity, we note that
the arriving entities, and ‘‘service time delay’’ when a customer arrives, the queue size will
is the service time duration of each service. increase by one if the current queue size is
The italicized words signify event-scheduling less than K (i.e., the customer is admitted),
conditions. To build the actual model, circle and remains unchanged otherwise (i.e.,
the events and add arcs starting from the the customer is rejected). This logic can be
corresponding preceding event and ending at implemented by using the following Boolean
the corresponding succeeding event in each expression:
sentence (see Fig. 1). These arcs represent
the event relationships. The delay time on Q = Q + (Q < K), (1)
each arc is specified by the underlined words
if present, or zero otherwise. The condition where (Q < K) = 1 if the condition is true and
on each arc is given by the italicized words on zero otherwise.
that sentence if present, or unconditional oth- To model impatient customers without
erwise. The resulting simulation model (the storing the waiting times of all customers
right panel of Fig. 1) is an event-scheduling- (i.e., without resorting to the transient entity
based simulation model, which is represented approach), we use the look-ahead capabil-
by a simulation modeling language called ity to obtain information in the simulated
event relationship graphs, or simply event future. For ease of exposition, we will use
graphs [7]. Two state variables (Q and R) and a two-server queuing system (i.e., c = 2) to
two random variables (a and s) are needed: illustrate the idea (it can be extended to more
Q returns or sets the current number of than two servers). The idea is as follows.
customers in the queue, R returns or sets When a customer arrives (say customer i), if
the current number of available servers, a he knows the maximum duration he needs
(Q)
a
New jobs enter the system at random intervals of arrivals.
(R)
Begin Enter Start s Leave
When a job enters, if the resource is available the job can start service. Q=0 Q=Q+1 Q=Q–1 R=R+1
R=1 R=R–1
Once a job starts, it will leave after a service time delay.
Whenever a job leaves, if there is more work waiting, then service can start on the next job.
to wait in queue, he can determine to stay he needs to wait is less than his impatient
or leave right away. The key modeling ques- time p(i.e., (T1 < Tc + p) == 1). The second
tion here is how to know such maximum wait equation will increase the queue size by one
duration. We use two auxiliary variables, T1 if the customer stays (i.e., Q = Q + 1).
and T2 , which record the first and second The state changes under the Stay event
earliest available times of the two servers. are
T1 and T2 are updated whenever a customer
arrives and decides to stay (recall that the s = Fs−1 (u)
state of a discrete-event simulation model w = (T1 − Tc )+
changes only at discrete instants). We add a T1 = min{Tc + w + s, T2 }
Stay event after the Enter event to update
T2 = max{Tc + w + s, T2 }.
T1 and T2 (see Fig. 2). The new values of
T1 and T2 will include the service duration
of customer i even though his service have The first equation simply generates and
not started yet. Calculating the finish time of stores the service time duration of a customer
every customer even before the beginning of in s. The second equation computes the actual
their services resolves the key modeling ques- waiting time of the customer. It is equal to
tion and provides future information for the 0 if the arriving customer finds an avail-
next arriving customer to decide whether to able server (i.e., T1 − Tc < 0). Otherwise, it
stay or depart. The waiting time of each cus- is equal to the amount of time before one
tomer is also calculated at the same moment. of the servers is available (i.e., T1 − Tc ). The
The Start and Finish events can be sched- notation ‘‘(.)+ ’’ represents the positive part of
uled to occur after, respectively, the waiting the waiting time (i.e., max{T1 − Tc , 0}). The
time and waiting time plus service time (see third and the last equations update the two
Fig. 2). earliest available times of the servers due to
In particular, let D be the decision variable this new arriving customer.
of whether to stay or not (stay if D == 1 and In Fig. 2, the impatient customers in
leave if D == 0). Let Tc be current simulation fact never joined the queue. If their con-
time, which can be obtained by using some tributions to the queue size are important,
system function in most simulation packages a new event can be added to include them
(e.g., CLK in Sigma [6] and TNOW in Arena into the queue. This event is scheduled
[8]). Let p be the impatient time period of by the Enter event with a condition of
a customer generated from a given distri- D == 0, a delay of p, and a state change
bution, that is, p ∼ Fp (p). The state changes of Q = Q − 1. The second equation of
that take place when an Enter event occurs the state changes in the Enter event
are as follows: will be modified to Q = Q + 1 × (Q < K).
The random impatient time p will also need
to be generated first and stored because it
D = (Q < K)&(T1 < Tc + p), is used in both the calculation of D and the
Q = Q + D. time delay of the new event.
One remark observed from this model is
The first equation says that a customer regarding the trade-off between speed and
will stay (i.e., D == 1) if the queue size is memory. Sometimes, a small amount of aux-
less than K(i.e., (Q < K) == 1) and the time iliary memory (variables) can greatly reduce
a
w+s
(D)
Begin Enter Stay w Start Leave
the speed or complexity of the simulation the data for each module (such as interar-
model, such as this one. rival time and service time distributions, and
defining the server) by double clicking the
Process Interaction modules. See Kelton et al. [8] for details of
using Arena.
Another popular simulation modeling para- Two issues of the process-interaction
digm is the process-interaction approach. approach should be mentioned: deadlock
Loosely speaking, for simple systems the and virtual entities. Deadlock could occur
process interaction approach is WYSIWYG when two entities are trying to seize the
(What You See Is What You Get) in the sense same resources in a wrong sequence. For
that what you create in the model is what example, consider two entities (A1 and A2)
you observe in the real simple system (see and two machines (M1 and M2). Let us
Fig. 3 and explanation in next paragraph). suppose that A1 is holding M1 and is trying
(However, this intuitive view diminishes to seize M2 to start a process. At the same
when the complexity of the system increases). time, E2 is holding M2 and needs M1 to start
This intuitive view is attractive to beginners another process. In this situation, unless
because it deals directly with the actual some mechanism is introduced to break the
objects of a real system. Together with their conflict, both entities and machines will
animation capability, process-interaction- be waiting forever. Therefore, acquisition
based simulation packages are by far the of resources should be carefully planned
most common in industry. when building a process-interaction model.
To illustrate the intuitive view of One good rule in practice is to seize all
process-interaction models, we model the required resources at one time. In the case
single-server queueing system by using three where several resources must be seized
process-interaction modules to mimic the sequentially (e.g., Process 1 requires only
three processes of the real system: (i) the Machine 1 and then immediately Process
process of customer arrivals, (ii) the process 2 requires both Machines 1 and 2), then
of queuing customers for service, and (iii) the release the previously seized resources first
process of customer departures. We then con- and then seize all needed resources at one
nect the three modules sequentially so that time (e.g., release Machine 1 first and then
the entities (customers) can flow through seize both Machines 1 and 2).
the three modules as they do in the real Virtual entities are needed when one
system. Figure 3 shows the implementation needs to model some abstract mechanisms
of this model using the simulation package or logics that have no physical counterparts
Arena 11 [8]. The mapping between the in the real system. This is because almost
three modules and the three real processes everything in a process-interaction model
are also shown in the figure. (including activities, logics, controls, and
To create the model in Arena, just drag the assigning values to variables) must be driven
modules from a built-in template of Arena, by flowing entities. For instance, to simulate
paste them into the model workspace, con- a traffic intersection, the right-of-way can
nect them based on the job flow, and specify be modeled as a ‘‘virtual resource’’ and
Simulation
Enter Start Leave
Model 96 85
7
Dispose Duplicated
Entities If Not
Found 66
Figure 4. Process-interaction model of a capacitated queue with multiple servers and impatient
customers.
traffics from any directions will need to seize virtual entity can be disposed. If found,
this virtual resource in order to pass the the virtual entity will enter the ‘‘Remove
intersection. Impatient Customer from Queue’’ module
Another example of ‘‘virtual entities’’ and trigger the departure of the customer
appears in the multiple-server queuing from the queue. Both the virtual entity
system with impatient customers. In a and impatient customer (if found) are then
process-interaction model, an entity in queue disposed.
is a passive object in the sense that it cannot From a computational point of view, the
proactively trigger activities by itself when process of searching a customer from a queue
certain condition is met. Some mechanism could be inefficient when the queue size is
must be created to trigger the correspond- large. Moreover, the search is done for every
ing activity. For example, to trigger the customer regardless of whether the customer
departure of an impatient customer whose has left or not. A more efficient approach
impatient time has expired, a virtual entity such as Fig. 2 is therefore recommended for
is needed. We use the Arena model shown in large-scale congested systems.
Fig. 4 to explain this issue. Other situations where virtual entities are
An arriving customer, if accepted by the needed include the modeling of resource pre-
diamond ‘‘Not Full?’’ module based on the ventive maintenance and failures, or random
current queue size, is assigned an ID in events that could change the state of the
the ‘‘Assign ID’’ module. This customer is system. Indeed, virtual entities, when appro-
then duplicated before joining the queue priately and professionally handled, can be a
(the ‘‘Start’’ module). This duplicate is a powerful modeling technique.
virtual entity and will stay in the ‘‘Impatient
Activity Scanning
Duration’’ module for a random impatient
duration. When the impatient period expires, An activity-scanning simulation model works
this virtual entity first identifies itself in by scanning activities of the model and fires
the ‘‘Retrieve ID’’ module (because there (i.e., activates) the ones that meet certain
could be other virtual entities representing given conditions. One of the main benefits
other customers). It then enters the ‘‘Search of the activity-scanning approach is its ana-
Customer from Queue’’ module to see if the lytical property, which facilitates the con-
customer that it represents is still waiting struction of mathematical models and the-
in the queue. If not found, the customer oretical analysis. The main representative
either is being served or has left, and this approach of activity scanning is Petri-net
8 FOUNDATIONS OF SIMULATION MODELING
models [9]. A Petri net is a bipartite graph 1. Identify all activities, including zero
(i.e., a graph with two types of elements and time activities (one transition for each
no two elements of the same type connect activity) of the system,
to each other). The two types of elements 2. Identify the conditions for each activity
are circles (called places) and bars (called (one place for each condition),
transitions). Besides these two types of ele- 3. Connect the places and transitions to
ments, users can also add tokens to the graph make the net alive according to the
to make the Petri net run. Tokens, which model logic, and
are solid dots, are used to represent objects
4. Add tokens to represent the initial state
(e.g., jobs or machines) and model logics (e.g.,
of the system.
failure events). Each transition represents a
certain activity of the model. All the input
Fig. 5 presents the four-step implementation
places to a transition denote the conditions
of the Petri-net simulation model of the
required for the transition to fire. All the out-
single-server queuing system without capac-
put places from a transition are the results
ity and no impatient customers. There are
of the firing of the transition. In a standard
two activities in this simple system: arrivals
Petri net, a transition is enabled when there
of customers and services for customers,
is at least one token in each input place.
which are modeled by the two transitions, E
After a time delay associated with the tran-
and S (which respectively stand for ‘‘Enter’’
sition (which can be random, deterministic,
and ‘‘Start’’). The single token in Place A
or zero), the transition fires and one token denotes the arrival stream of customers (i.e.,
is removed from each input place. Imme- the process of arrivals). Every a random
diately, one token is added to each output time units, Transition E fires; it then places
place. The number of tokens entering and one token to Place Q, denoting an arrival
leaving from a transition may or may not of a customer to the queue, and also puts
equal. If the number of tokens in any place is one token back to Place A, initiating the
always below a certain number at any time, arrival of the next customer. The token in
the Petri net is called bounded, otherwise, Place R represents the single machine which
unbounded. At any time of the simulation, is available right now (adding more tokens
a snapshot of the token distribution (their here extends the model to a multiple-server
locations) gives the current state of the sim- system). Transition S has two input places,
ulation. This token distribution is called a signifying the two conditions for a service to
marking. start (i.e., an available server and a waiting
The aforementioned firing rule is called customer). When these two conditions are
remove-on-fire, in that the tokens are rem- satisfied, Transition S is enabled; and after
oved when the transition fires. Another firing s random time units, it fires, denoting the
rule is remove-on-enable, which removes the completion of a service. One token is then
tokens when the transition is enabled. It can placed in Place R, which allows the server to
be shown that these two rules are equivalent. work on the next customer if there is any.
To build a Petri-net simulation model, the One token is also deposited to Place L, which
following four-step procedure can be used: represents a processed customer.
R R R
A Q L Q L A Q L
A
a s a s a s a s
E S E S E S E S
Step 1 Step 2 Step 3 Step 4
operating rooms, and from personnel such be enforced to discourage bad behavior and
as doctors and nurses to patients and promote good ones. Emergent behavior here
other service providers. All these units can means arising coherent patterns of macro-
be considered as autonomous agents. For scopic behavior resulting from microscopic
example, warehouses react to demands by actions and interactions. This leads to the
providing inventory based on a certain rule, agent-based simulation approach, which has
ambulances operate in accordance with some been developed rapidly over the past two
dispatch policies and physical mechanical decades. It has been widely used in vari-
rules, and patients try to intelligently select ous fields including military, biology, social
doctors. In many cases, agents, while operat- science, economics, business, and so on. The
ing based on their own strategies, cooperate theoretical basis of agent-based simulation
or compete with each other in accordance lies mainly in cellular automata [15–17],
with certain mutual rules or agreements. complex system modeling, artificial life, and
It is natural to model agents as objects swarm intelligence [18,19].
in a computer program and simulate their The algorithm for executing an agent-
interactions to see what interaction rules based simulation model varies greatly across
lead to what consequences (i.e., emergent different agent-based platforms. A general
behavior). Mechanisms or policies can then scheme is outlined below.
We now use the Conway’s Game of Life 3. Otherwise, the cell will die either of
model to illustrate the modeling of agents, loneliness or crowdedness in the next
their interactions, and the resulting emerg- time step.
ing behavior. Imagine that there is a two-
dimensional grid of size n × n, where n is the Implementing this model in a standard
number of rows (or columns) in the grid. Each agent-based simulation package (such as
entry of the grid lives a cell. The cells cannot Repast [20] or NetLogo [21]) and running
move. Each cell has only two states: alive and it for about one hundred iterations yields
a distribution of relatively stable patterns
dead. Each cell changes its state based on
of live cells as shown in the right panel of
the following three simple rules that describe
Fig. 6. Note that the middle panel of Fig. 6 is
its interactions with its eight neighbors (up,
the initial distribution of live cells.
down, left, right, and four diagonal cells). See
In fact, this example is so simple that it
the left panel of Fig. 6 for a visual description
can be considered as a cellular automaton.
of the rules.
A cellular automaton model considers a set
of cells residing in a two-dimensional lattice.
Moreover, this model only includes discrete
1. A live cell with exactly two or three live
state variables and therefore can also be mod-
neighbors will remain alive in the next
eled by using the discrete-event simulation
time step.
approach.
2. A dead cell with exactly three live To demonstrate the flexibility of this model
neighbors will come to life in the next in arriving different emergent behaviors, we
time step. generalize the original Game of Life model
12 FOUNDATIONS OF SIMULATION MODELING
Time t Time t + 1
Rule 1: Stay alive
Rule 2:
Come to life
Die of loneliness
Rule 3:
Die of crowdedness
by simply changing the number of live neigh- agents and their environment. Agents can
bors in Rules 1 and 2 to X, Y, and Z as defined also have internal memories and perceptions
below. To better visualize the emergent pat- to respond to outside and adjust their inside.
terns, we also color the cells based on the Agent-based simulation also allows different
number of live neighbors (see the legend of kinds of spatial environments, such as ring,
Fig. 7). lattice, random, or maps (such as GIS maps).
The variation of Conway’s game of life Agents can move freely in its environment.
model is as follows: This makes it applicable for modeling and
visualizing complex behavior in physical
1. A live cell with the number of live neigh- systems, such as simulations of traffic,
bors between X and Y, inclusively, will evacuations, biological systems, mechanical
remain alive in the next time step, systems, and so on.
One issue in agent-based simulation is the
2. A dead cell with exactly Z live neighbors
order in which the agents’ states are updated
will come to life in the next time step,
in each time step. If one agent is updated
3. Otherwise, the cell will die either of before its neighbors are updated, then its
loneliness or crowdedness in the next state at the current time step can affect the
time step, states of its neighbors at this time step, oth-
erwise, its state at the current time step will
where 0 ≤ X, Y, Z ≤ 8 and X ≤ Y. affect its neighbors in the next time step.
This variation has a total of 288 possi- One common practice is to randomize the
ble combinations of rules, (X, Y, Z). Some updating order.
of them are trivial but some produce clear The computational requirement of the
emergent patterns as shown in Fig. 7. These agent-based simulation execution algorithm
patterns also evolve in time. One can also use is high because it has to loop through all
a sequence of multiple rules to obtain differ- agents in each time step. Methods have been
ent combinations of patterns. The patterns proposed to avoid looping all agents, for
shown in Fig. 7 are obtained by using this example, only updating those agents whose
sequence of rules: (0, 7, 8)—(0, 7, 3)—(0, 7, state changes matter. Another approach is to
6)—(0, 7, 5)—(0, 7, 4)—(0, 5, 4)—(3, 5, 4), employ the discrete-event simulation algo-
where the first rule is to initialize the states rithm to advance the clock based on events
of all cells to dead. and only update the continuous variables in
Although cellular automata are already every time step. Different hardware (such
Turing complete, agent-based simulation as parallel CPUs or graphics processing
allows agents to have a greater degree of units—GPU) have also been used to improve
flexibilities and functionalities (such as the efficiency of agent-based simulation
learning and adaptation) and can accommo- models. It has been shown that execution
date more complicated interaction rules both speed can be improved by thousands of times
between agents and agents, and between when using GPU [22].
FOUNDATIONS OF SIMULATION MODELING 13
Legend
# of alive
neighbors 0 1 2 3 4 5 6 7 8
Color:
19. Macal CM, North MJ. Tutorial on agent-based 21. Wilensky U, NetLogo. http://ccl.northwestern.
modeling and simulation part 2: how to model edu/netlogo/. Center for Connected Learning
with agents. Proceedings of the 2006 Win- and Computer-Based Modeling, Northwestern
ter Simulation Conference. Monterey (CA), University, Evanston (IL). 1999.
Piscataway (NJ): Institute of Electrical and 22. Lysenko M, D’Souza RM. A framework for
Electronics Engineers; 2006. megascale agent based model simulations on
20. North MJ, Collier NT, Vos JR. Experiences graphics processing units. J Artif Soc Soc Sim-
creating three implementations of the repast ulat 2008;11(4):10.
agent modeling toolkit. ACM Trans Model 23. Hammersley JM, Handscomb DC. Monte
Comput Simulat 2006;16(1):1–25. Carlo methods. London: Methuen; 1964.