Writing Technical Paper.. A-Z

By Dr. Nawaporn Wisitpongphan
When do we use
Simulation?
When do we use
Experiment?
Simulation
 Simulation – very broad term – methods and applications
to imitate or mimic real systems, usually via computer
 Can be applied in many fields and industries
 Very popular and powerful method
 Banks, et al:
 "A simulation is the imitation of the operation of a real-world
process or system over time". It "involves the generation of an
artificial history of a system, and the observation of that
artificial history to draw inferences … "
 Law & Kelton:
 "In a simulation we use a computer to evaluate a model (of a
system) numerically, and data are gathered in order to
estimate the desired true characteristics of the model"
Simulation
 More specifically (but still superficially)

We develop a model of some real-world system that (we
hope) represents the essential characteristics of that system


We use a program (usually) to test / analyze that model


Does not need to exactly represent the system – just the relevant parts
Carefully choosing input and output
We use the results of the program to make some deductions
about the real-world system
Why (or when) do we use simulation?
 Consider arbitrary large system X
 Could be a computer system, a highway, a factory, a
space probe, etc.
 We'd like to evaluate X under different conditions
 Option 1: Build system X and generate the conditions,
then examine the results

This is not always feasible for many reasons:




X may be difficult to build
X may be expensive to build
We may not want to build X unless it is "worthwhile"
The conditions that we are testing may be difficult or expensive to
generate for the real system
5
Why (or when) do we use simulation?
 Option 2: Model system X, simulate the conditions
and use the simulation results to decide
 Model both possibilities for increasing production and
simulate them both

We then choose the solution that is most economically
feasible
 Model the damage and the stress that re-entry imparts
on the shuttle


Determine via a simulation if the damage will threaten the
shuttle or not
Note the importance of being correct here
6
Why (or when) do we use simulation?
 Clearly, this is itself not a trivial task
 Simulations are often large, complex and difficult to
develop
 Just developing the correct system model can be a
daunting task

There are many variables that must be taken into account
 However, if a new plant costs hundreds of millions or
even billions of dollars, spending on the order of
thousands (or even hundreds of thousands) of dollars
on a simulation could be a bargain
 Note that with the Shuttle example, most of the work for
this must be done in advance

Don't have time to design & implement this during the
duration of7 a flight
Why (or when) do we use simulation?
 For example:

A company needs to increase its production and needs to
decide whether it should build a new plant or it should try to
increase production in the plants it already has



Which option is more cost-effective for the company?
Clearly, building the new plant would be very expensive and
would not be desirable to do unless it is the more costeffective solution
But how can we know this unless we have built the new plant?
 Another (ongoing) example:



NASA wants to know if damage on the Space Shuttle will
threaten it upon re-entry
If they wait until re-entry to make a judgment, it is already too
late
In this case8 it is not feasible to do the real-world test
When is simulation NOT a good idea?
 Don't use a simulation when the problem can be solved
in a "simpler" or more exact way


Some things that we think may have to be simulated can be
solved analytically
Ex: Given N rolls of a fair pair of dice, what are the relative
expected frequencies of each of the possible values {2, 3, 4, …
12} ?


We could certainly simulate this, "rolling" the dice N times and
counting
However, based on the probability of each possible result, we can
derive a more exact answer analytically
9
When is simulation NOT a good idea?
 Don't use a simulation if it is easier or cheaper to
experiment directly on a real system

Ex: A 24 hour supermarket manager wants to know how to
best handle the cash register during the "midnight shift":




Have one cashier at all times
Have two cashiers at all times
Have one cashier at all times, and a second cashier available (but only
working as cashier if the line gets too long)
Each of these can be done during operating hours


An extra employee can be used to keep track of queue data (and
would not be too expensive)
Differences are (likely) not that drastic so that customers will be
alienated
10
When is simulation NOT a good idea?
 Don't use a simulation if the system is too complex to
model correctly / accurately


This is often not obvious
Can depend on cost and alternatives as well


However, a bad model may not be helpful and could actually be
harmful
Ex: With the Space Shuttle, lives were at risk – if the model predicts
incorrectly the results are catastrophic
11
Steps in a Simulation Project
Systems
 System – facility or process, actual or planned
 Examples abound …














Manufacturing facility
Bank operation
Airport operations (passengers, security, planes, crews, baggage)
Transportation/logistics/distribution operation
Hospital facilities (emergency room, operating room, admissions)
Computer network
Freeway system
Business process (insurance office)
Criminal justice system
Chemical plant
Fast-food restaurant
Supermarket
Theme park
Emergency-response system
Work With the System?
 Study the system – measure, improve, design, control
 Maybe just play with the actual system

Advantage — unquestionably looking at the right thing
 But it’s often impossible to do so in reality with the
actual system


System doesn’t exist
Would be disruptive, expensive, or dangerous
Systems, Models, and Simulation
(cont’d.)
 Ways to study a system


Simulation is “method of last
resort?” Maybe …
But with simulation there’s no
need (or less need) to “look
where the light is”
Models
 Model – set of assumptions/approximations about how the
system works
 Study the model instead of the real system … usually much
easier, faster, cheaper, safer
 Can try wide-ranging ideas with the model

Make your mistakes on the computer where they don’t count, rather
than for real where they do count
 Often, just building the model is instructive – regardless of
results
 Model validity (any kind of model … not just simulation)



Care in building to mimic reality faithfully
Level of detail
Get same conclusions from the model as you would from system
Types of Models
 Physical (iconic) models
 Tabletop material-handling models
 Flight simulators
 Logical (mathematical) models
 Approximations and assumptions about a system’s
operation
 Often represented via computer program in appropriate
software
 Exercise the program to try things, get results, learn
about model behavior
Studying Logical Models
 If model is simple enough, use traditional
mathematical analysis … get exact results, lots of
insight into model
 Queueing theory
 Differential equations
 Linear programming
 But complex systems can seldom be validly
represented by a simple analytic model
 Danger of over-simplifying assumptions … model
validity?
 Working on the wrong problem
 Often, a complex system requires a complex model,
and analytical methods don’t apply … what to do?
Computer Simulation
 Broadly interpreted, computer simulation refers to
methods for studying a wide variety of models of
systems
 Numerically evaluate on a computer
 Use software to imitate the system’s operations and
characteristics, often over time
 Can be used to study simple models but should not
use it if an analytical solution is available
 Real power of simulation is in studying complex
models
Advantages of Simulation
 Flexibility to model things as they are (even if messy
and complicated)
 Allows uncertainty, nonstationarity in modeling
 Advances in simulation software
 Far easier to use (GUIs)
 No longer as restrictive in modeling constructs
(hierarchical, down to C)
 Statistical design & analysis capabilities
Different Kinds of Simulation
 Static vs. Dynamic
 Does time have a role in the model?
Examples of static simulations are Monte Carlo models.
A dynamic simulation model represents a system as it evolves over
time, such as a conveyor system in a factory.
 Continuous-change vs. Discrete-change
 Can the “state” change continuously (exp.velocity of a plane moving
through the air) or only at discrete points in time (exmp.number of
customers in a bank changes instantaneously)?
 Deterministic vs. Stochastic
 Is everything for sure or is there uncertainty?
 Most operational models:
 Dynamic, Discrete-change, Stochastic
Using Computers to Simulate
 General-purpose languages (FORTRAN, C, Pascal)
 Tedious, low-level, error-prone
 But, almost complete flexibility
 Support packages
 Subroutines for list processing, bookkeeping, time
advance
 Widely distributed, widely modified
 Spreadsheets
 Usually static models
 Financial scenarios, distribution sampling
 Simulation languages
 GPSS, SIMSCRIPT, SLAM, SIMAN
Some Definitions
 System
 "A group of objects that are joined together in some
regular interaction or interdependence toward the
accomplishment of some purpose" (Banks et al)
 The state of a system is the variables (and their values) at
one instance in time
23
Some Definitions
 Discrete vs. Continuous Systems
 Discrete System

State variables change at discrete points in time

Ex: Number of students in this class

When a registration or add is completed, number of students
increases, and when a drop is completed, number of students
decreases
 Continuous System

State variables change continuously over time

Ex: Volume of CO2 in the atmosphere




CO2 is being generated via people (breathing), industries and natural
events and is being consumed by plants
Models of continuous systems typically use differential equations to indicate rate of
change of state variables
Note that if we make the time increment and the unit of measurement small enough,
we may be able to convert a continuous system into a discrete one
Also note that systems are not necessarily exclusively discrete or exclusively
continuous
24
System Components
 Entities
 Objects of interest within a system


Typically "active" in some way
Ex: Customers, Employees, Devices, Machines, etc
 Contain attributes to store information about them

Ex: For Customer: items purchased, total bill
 May perform activities while in the system


Ex: For Customer: shopping, paying bill
In many cases it is really just the period of time required to
perform the activity
25
System Components
 Events
 Instantaneous occurrences that may change the state of a
system


Note that the event itself does not take any time
Ex: A customer arrives at a store
 Endogenous event


Events occurring within the system
Ex: Customer moves from shopping to the check-out
 Exogenous event


Events relating / connecting the system to the outside
Ex: Customer enters or leaves the store
26
System Model
 A representation of the system to be used / studied in
place of the actual system
 Allows us to study a system without actually building it
(which, as we discussed previously, could be very
expensive and time-consuming to do)
 Physical Model
 A physical representation of the system (often scaled
down) that is actually constructed

Tests are then run on the model and the results used to make
decisions about the system
27
System Model
 Mathematical Model
 Representing the system using logical and
mathematical relationships
 Simple ex: d = vot + ½ at2


This equation can be used to predict the distance traveled by
an object at time t
However, will acceleration always be the same?
 Often this model is fairly complex and defined by the
entities and events
 However, in order to be useful, the model must be
evaluated in some way

i.e. The behavior based on the model must be determined
28
System Model
 Analytical evaluation
 If the model is not too complex we can sometimes solve
it in a closed form using analytical methods
 One type of analytical evaluation is the Markov process
(or Markov chain)
 Often problems that are too complex, even if they can be
modeled analytically, are too computation intensive to
be practical
 Simulation evaluation
 More often we need to simulate the behavior of the
model
29
System Model
Deterministic Model
• Inputs to the simulation are known values


No random variables are used
Ex: Customer arrivals to a store are monitored over a period of days
and the arrival times are used as input to the simulation
Stochastic Model
• One or more random variables are used in the simulation


Results can only be interpreted as estimates (or educated guesses) of
the true behavior of the system
Quality of the simulation depends heavily on the correctness of the
random data distribution
>


Different situations may require different distributions
Ex: Customers arrive at a store with exponentially distributed interarrival
times having a mean of 5 minutes
In most cases we do not know all of the input data in advance, and at
least some random data is required
30
System Model
 Static Model
 Models a system at a single point in time, rather than
over a period of time
 Sometimes called Monte Carlo simulations


Model the output of a system by using input variables that
could not be known exactly
Solution is a distribution of possible outcomes that can be
characterized statistically
 Dynamic Model
 Models a system over time
31
Simple Monte Carlo Example
$
70.00
70
60
50
40
30
20
10
20
.0
0
$1
00
.0
0
$1
0.
00
$8
0.
00
$6
$4
0.
00
0
0.
00
Charges $
$ 20.00
$ 30.00
$ 40.00
$ 50.00
$ 60.00
$ 70.00
$ 80.00
$ 90.00
$ 100.00
$ 110.00
$ 120.00
$2
Number of Patients
(Frequency)
10
20
30
40
50
60
50
40
30
20
10
Total
360
Average
Number of Patients (Frequency)
Distribution of Charges
Charges
Credit: Copyright 2008 Health Administration Press. All rights reserved.
 Fifty percent of the
clinic’s patients do not
pay for their services,
and it is equally likely
that they will pay or not
pay.
Probability
Simple Monte Carlo Example
0.6
0.5
0.4
0.3
0.2
0.1
0
Pay
Do Not Pay
• The payment per patient is modeled by:
Probability of payment × Charges/patient = Payment/patient
• A deterministic solution to this problem would be:
0.5 × $70/patient = $35 per patient
Credit: Copyright 2008 Health Administration Press. All rights reserved.
Simple Monte Carlo Example
Die
Trial Coin
Flip Payment Total
#
7
1
H
1
10
0
T
2
8
1
H
3
8
0
T
4
9
1
H
5
8
0
T
6
7
1
H
7
10
0
T
8
9
1
H
9
10
0
T
10
Charges
$ 70.00
$ 100.00
$ 80.00
$ 80.00
$ 90.00
$ 80.00
$ 70.00
$ 100.00
$ 90.00
$ 100.00
Patient
Payment
$ 70.00
$
$ 80.00
$
$ 90.00
$
$ 70.00
$
$ 90.00
$
Number of Trials
Payment Distribution
$-
$60.00
$110.00
Payment
Credit: Copyright 2008 Health Administration Press. All rights reserved.
Simple Monte Carlo Example
The Flaw of Averages
 On average each patient pays $35. However:
 Fifty percent of the patients pay nothing.
 A small percentage pay as much as $120.
 No individual patient pays $35.
 Monte Carlo simulation can reveal hidden
information and a clearer understanding of the risks
and rewards of a situation or decision.
Credit: Copyright 2008 Health Administration Press. All rights reserved.
Two Simulation Modeling Approaches
1. Event-Scheduling
Approach
2. Process-Interaction
Approach
Slide 36
Event-Scheduling Approach
 You might have to use this approach if you were using
general-purpose languages like C/C++ or FORTRAN.
 Concentrate on the events and how they affect the
system state.
 We have to help the simulation evolve over time by
keeping track of every event in increasing order of
time of occurrence.
 This gets to be a bookkeeping hassle.
A Simple Processing System
Machine
(Server)
Arriving
Blank Parts
•
6
5
Queue (FIFO)
Departing
Finished Parts
4
Part in Service
General intent:


•
7
Estimate expected production
Waiting time in queue, queue length, proportion of time machine is busy
Time units




Can use different units in different places … must declare
Be careful to check the units when specifying inputs
Declare base time units for internal calculations, outputs
Be reasonable (interpretation, roundoff error)
Event-Driven Simulation
 System state : the number of units in the system and the status of the
server(busy or idle).
 Event : a set of circumstances that cause an instantaneous change in
the state of the system.
 In a single-channel queueing system there are only two possible events that
can affect the state of the system.


the arrival event : the entry of a unit into the system
the departure event : the completion of service on a unit.
 Simulation clock : used to track simulated time.
System Event: Arrival
 The arrival event occurs when a unit enters the system.
 The unit may find the server either idle or busy.


Idle : the unit begins service immediately
Busy : the unit enters the queue for the server.
Arrival
Event
Unit enters
service
No
Server
busy?
Yes
Unit enters queue
for service
System Event: Departure
 If a unit has just completed service, the simulation proceeds in the
manner shown in the flow diagram of Figure 2.2.
 Note that the server has only two possible states : it is either busy or idle.
Departure
Event
Begin server
idle time
No
Another unit
waiting?
Yes
Remove the waiting unit
from the queue
Begin servicing the unit
Process-Interaction Approach
 Concentrates on an entity and the sequence of events
and activities it undergoes as it progresses through the
system.
 At any time, the system may have many entities
interacting with each other as they compete for
resources.
 You do the generic entity modeling in this approach,
but you don't have to bother with the event
bookkeeping, the computer simulation language
handles the event- scheduling deep inside.
 Saves lots of programming effort. For example, Arena
and many other simulation languages adopt this
approach. We can use Threads of Java for this purpose
DES
Arena Screenshot
Arena® screen shots reprinted with permission from Rockwell Automation.
Credit: Copyright 2008 Health Administration Press. All rights reserved.