overall plan of simulation and modeling i chaptersce.u-sys.org/veranstaltungen/simulation and...

64
Simulation and Modeling I Introduction to Simulation 1 Overall Plan of Simulation and Modeling I Chapters Introduction to Simulation Discrete Simulation Analytical Modeling Modeling Paradigms Input Modeling Random Number Generation Output Analysis Continuous and Hybrid Simulation Simulation Software

Upload: buidat

Post on 14-May-2018

246 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 1

Overall Plan of Simulation and Modeling I

Chapters Introduction to Simulation Discrete Simulation Analytical Modeling Modeling Paradigms Input Modeling Random Number Generation Output Analysis Continuous and Hybrid Simulation Simulation Software

Page 2: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 2

Introduction to Simulation

Goals get context, overview, “feel” of simulation learn about the various kinds of simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 3: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 3

Some Demonstrations

AutoMod load processing and inspection in an

automated guided vehicles (AGV) system

AnyLogic Predator-Prey Model, QoS Demo, Packaging Line, Vibro-Impact

Damper

Simulation projects in summer semester Traffic Intersection City Pub

Page 4: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 4

Some Demonstrations

Controller Area Network (CAN) CAN is common in cars to connect electronic control units (ECUs)

a Simulation and Modeling II project in summer 2008

conceptional model:

Page 5: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 5

Some Demonstrations

a simulation model with 22 ECUs has been realized in AnyLogic realistic data was taken from a current electronic car architecture at the

Audi AG modeling on a quite detailed level: each bit is sampled a few times, as in

the real system graphical animation of the overall model:

Page 6: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 6

Some Demonstrations

oscilloscope view of transmission, reception and arbitration loss of one CAN controller

Page 7: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 7

Some Demonstrations

wakeup perdiods of ECUs are random as relevant performance measures, mean and maximum latencies of

messages between ECUs have been determined:

the team presented the results to developers at Audi, it was well adopted

in INI.FAU, a joint PhD-program between Audi and FAU, a researcher works on more elaborated simulation models of car communications

Page 8: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 8

Some Demonstrations

Sensor fusion in cars in a diploma thesis at Audi an AnyLogic simulation model of a car with

various sensors to detect objects has been developed, animation:

Page 9: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 9

Some Demonstrations

structure of the simulation model:

the model comprises a full implementation of the sensor fusion algorithms

Page 10: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 10

Some Demonstrations

allows to experiment with fusion architecture (vehicular context, used sensors, fusion and filtering algorithms, algorithmic parameters)

cars and clutter objects are generated randomly, sensor values are subject to Gaussian random noise

ratio of false positives (detection of non-existent objects in the scene, important for safety reasons):

Page 11: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 11

Introduction to Simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 12: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 12

A First Characterization of Simulation

A simulation is the imitation of the operation of a real world process or system over time.

The behavior of a system as it evolves over time is studied by developing a simulation model.

This model usually takes the form of a set of assumptions concerning the operation of the system. These assumptions are expressed in mathematical, logical, and symbolic relationships between the entities, or objects of interest, of the system.

Once developed and validated, a model can be used to investigate a wide variety of “what-if” questions about the real-world system.

Potential changes to the system can first be simulated in order to predict their impact on system performance.

Simulation can also be used to study systems in the design stage, before such systems are built.

Page 13: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 13

A First Characterization of Simulation (cont.)

In some instances, a model can be developed which is simple enough to be “solved” by mathematical methods. Such solutions may be found by the use of differential calculus, probability theory, algebraic methods, or other mathematical techniques.

However, many real-world systems are so complex that models of these systems are virtually impossible to solve mathematically. In these instances computer-based simulation can be used to imitate the behavior of the system over time. From the simulation, data are collected as if a real system were being observed. This simulation-generated data is used to estimate the measures of performance of the system.

(Banks et al., Discrete-Event System Simulation, 4th ed., Prentice Hall, 2004, page 3)

Page 14: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 14

A First Characterization of Simulation (cont.)

Areas of application for simulation designing and analyzing manufacturing systems determining hardware requirements or protocols for communication

networks determining hardware and software requirements for a computer system designing and operating transportation systems such as airports,

freeways, ports, and subways evaluating designs for service organizations such as call centers,

fast-food restaurants, hospitals, and post offices reengineering of business processes determining ordering policies for an inventory system analyzing financial or economic systems evaluating military weapon systems or their logistics requirements ...

(discrete-event) simulation is one of the most widely used operations-research and management techniques, if not the most widely used

Page 15: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 15

Introduction to Simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 16: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 16

1. Example: Single-Server Queue (scenario)

The single-server queue

scenario:– customers arrive randomly– infinite waiting room (unbounded queue)– one service unit with a random service time

abstract model of many systems, e.g.:– an information desk at an airport– a station in a manufacturing cell– a router in the Internet– ...

the “hello world” of simulation and modeling

arrivalof customers

customers departfrom system

waiting room (queue) service unitinter-arrival times, e.g.:

0.4, 1.2, 0.5, 1.7, 0.2, ...service times, e.g.:

2.0, 0.7, 0.2, 1.1, 3.7, ...

Page 17: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 17

1. Example: Single-Server Queue (measures)

Typical questions how much time do customers spend in the system? how many customers are in the system (waiting room and server)? how busy is the service unit? how many customers are served per hour? ...

Corresponding measures Mean delay D : average of the times customers spend in the system Mean queue length N : average value of N(t), the number of customers

in the system, for t → Utilization U: average percentage of time with N(t) > 0 Throughput X: average number of completed services per time unit these measures are defined for steady-state, i.e., for t → non-stationary, i.e., transient measures may also be considered,

e.g., average value of N(t) for fixed t

Page 18: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 18

Ai : inter-arrival time of i'th customer = ti - ti-1Si : service time of i'th customerDi : time in system of i'th customer (in queue + service unit)Wi : waiting time of i'th customer = Di - Si

1. Example: Single-Server Queue (a possible realization)

N(t)

t0

12

3

c1 t2 t3 c2 t4 t5 c3t1

A2 A3 A4 A5

S1 S2 S3

D1 D2D3

events:interarrival times:service times:

times in system:

N(t): number of customers in system (queue + service unit) at time t

ti : arrival of i'th customer

ci : departure of i'th customer (completed service)

A1

0

W3

Page 19: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 19

1. Example: Single-Server Queue (remarks) Discrete simulation

events occur at discrete points in time variables change instantaneously

Important aspects Input modeling

– characterization of randomness by input parameters– based on data fitting with measurements

Computer representation– modeling paradigm (textual/visual, event-/process-/object-oriented, ...)– random number generation– event list processing

Output analysis– sound statistical analysis of random output data to obtain measures

of interest Optimization: systematic search in the input parameter space for

optimal values of the measures, also relevant but not covered in this class

Page 20: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 20

1. Example: Single-Server Queue (input modeling)

random arrival and service patternsmay be characterized by probability distributions

values around x with a higher value f(x) are more likely,a more precise explanation can be found in the probability theorychapter (exercise class)

e.g., software tool: ExpertFit

histogram of measuredservice times(622 in this example)

density f(x) of fittedprobability distribution function(inverted Weibull in this example)

Page 21: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 21

1. Example: Single-Server Queue (model paradigm)

e.g., modeling as communicating statecharts:

here 2 statecharts: client and sender transitions with triggering events and action customers are messages generated at the client and sent to the server a versatile modeling paradigm for discrete event simulation, we put a

focus on it in this class, we will however also look at others

client server

generate

exp(1/10)/port.send()

port port

exp(1/9)(q.size()>0)/q.removeFirst()

idle

busy

q

Page 22: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 22

1. Example: Single-Server Queue (event list processing)

the execution of the model is internally mapped on event list processing data structures

– event list: discrete events with time of occurrence, ordered by time– simulation clock: variable giving current value of simulated time– system state variables, statistical counters

algorithm:

0. initialization of data structures at time 0;

Repeat1. get next event from event list and advance

simulation clock to its time of occurrence;

2. update system state, event list and counters;

3. generate future events (using random number

generator) and add them to event list;

until stopping criterion satisfied;

4. Compute measures of interest (from counters);

initialization routine

timing routine

event routine (one per event type)

report generator

library routines

Page 23: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 23

1. Example: Single-Server Queue (event list processing)

Event list processing (step by step):

"next-event time advance" (also possible: "fixed-increment advance")

the simulation clock is advanced from event to event

periods of inactivity are skipped over

that is why simulation is usually faster than observing the real world: simulation time vs. simulated time (i.e., run time vs. model time)

0

t

c1 t2 t3 c2 t4 t5 c3t1

Page 24: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 24

1. Example: Single-Server Queue (output analysis)

Typical measures Mean delay D: average time a customers spends in the system Utilization U: average percentage of time the server is busy Throughput X: average number of completed services per time unit

Statistical estimation unless enough observations estimation can differ significantly from true value

one needs information about the quality of estimations

confidence intervals

Remark not straightforward, output data is correlated

Tool demonstration: single-server queue simulation with AnyLogic

Page 25: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 25

1. Example: Single-Server Queue (output analysis)

Example results For exponentially distributed interarrival and service times with means

equal to 10 and 9 time units:– mean delay D = 90 time units– utilization U = 0.9– throughput X = 0.1

D vs. U:(steep increase as U → 1)

Results from discretesimulation. The queue may also be solved analytically(see M/M/1 queue in chapter Analytical Modeling)

0.2 0.4 0.6 0.80

5

10

15

U

D

Page 26: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 26

Introduction to Simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 27: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 27

2. Example: Predator-Prey (continuous simulation)

Biological model (from Law/Kelton, pp. 87-89) 2 populations:

– predator (e.g., sharks, lynxs,…)– prey (e.g., mackerels, hares, ...)

prey is passive, predators depend on prey as their source of food modeled as real-valued variables (actually integers):

– x(t) prey population at time t– y(t) predator population at time t

prey growth rate in absence of predators: x(t) · g1(g1 = birth rate – death rate)

prey death rate according to predators: x(t) · y(t) · d1 predator growth rate: y(t) · x(t) · g2 predator death rate in absence of prey: y(t) · d2 where parameters g1, d1, g2, d2 > 0

Page 28: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 28

2. Example: Predator-Prey (continuous simulation)

System of differential equations

ordinary differential equations (ODEs)

Numerical solution by, e.g., Runge-Kutta integration

(actually, analytical solution is known)

Continuous simulation system variables change continuously with respect to time

x'(t) = x (t) · g1 - x (t) · y(t) · d1y'(t) = y(t) · x (t) · g2 - y(t) · d2

Page 29: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 29

2. Example: Predator-Prey (continuous simulation)

Example results obtained with Mathematica g1 = d2 = 1, g2 = 0. 5, d1 = 0.025, initial conditions: x(0) = y(0) = 100

both populations:periodic behavior

both populations asparameterized curve

x(t) y(t) x

y

Page 30: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 30

2. Example: Predator-Prey (continuous simulation)

Predator-prey model in AnyLogic a slightly different formulation of the model:

correspondence of variables and parametes:

Hares'(t) = Hares(t)·HareNatality - Hares(t)·Lynx(t)/AreaLynx'(t) = Lynx(t)·LynxNatality - Lynx(t)·LynxMortality(Hares(t)/Area)

AnyLogic model: Law/Kelton model:

Hares(t) x(t)

Lynx(t) y(t)

HareNatality g1

Area 1/d1

LynxNatality (constant) x(t) · g2 (functional)

LynxMortality( Hares(t)/Area) (functional) d2 (constant)

Page 31: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 31

2. Example: Predator-Prey (continuous simulation)

modeling paradigm of system dynamics, a modeling style to graphically represent differential equations

commonly used for economic, urban, social, ecological systems, see chapter on Continuous and Hybrid Simulation)

Page 32: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 32

Introduction to Simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 33: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 33

3. Example: Bouncing Ball (hybrid simulation)

Bouncing ball a ball is initially thrown down and bounces back at the ground, it loses a

certain percentage of its velocity with each bounce, let – y(t) be the height at time t– v(t) be the velocity at time t (upwards is positive)– g be the gravity– p be the percentage of velocity loss

the rise and fall is described by the ODEs: v'(t) = g, y'(t) = v(t) the ball bounces under condition: y(t) = 0 this condition is hard to check when numerical solution is used,

it can be replaced by: y(t) ≤ 0 ∧ v(t) < 0 when the ball bounces, the velocity is inverted and decreased:

v(t+dt) = - (1-p) ⋅ v(t-dt)

Page 34: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 34

3. Example: Bouncing Ball (hybrid simulation)

Hybrid simulation in this example we see continuously changing variables (v and y) and

discrete events when the ball bounces a mix of continuous and discrete simulation is known as hybrid

simulation potential interactions between discrete and continuous parts:

– discrete event changes differential equations– discrete event changes continuous state variable discontinuously– continuous variable achieves threshold and causes discrete event

to occur hybrid simulation appears often in control: a discrete controller for some

dynamic continuous process

Page 35: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 35

3. Example: Bouncing Ball (hybrid simulation)

Representation with statecharts hybrid simulation models can nicely be represented as hybrid statecharts:

– equations are associated with states – state transitions can alter continuous behaviour– more details in chapter Continuous and Hybrid Simulation

representation of the bouncing ball:

v'(t) = g, y'(t) = v(t)

y(t) ≤ 0 ∧ v(t) < 0 / v(t+dt) = - (1-p) ⋅ v(t-dt)

Page 36: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 36

3. Example: Bouncing Ball (hybrid simulation)

AnyLogic model model paradigm of hybrid statecharts is used graphical animation:

Page 37: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 37

Introduction to Simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 38: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 38

4. Example: Unloading Oil Tankers

Unloading Oil Tankers (from Law/Kelton, p. 89) oil tankers arrive at unloading dock, build a queue unloading into a storage tank at a constant rate storage tank supplies oil to refinery at constant rate dock opened from 6 a.m. to midnight filling of storage must be within certain limits

Hybrid simulation with randomness in this type of hybrid simulation, as an additional feature discrete events

can also occur after random times, as we have seen in discrete simulation

poses greater challenges for its solution and will be discussed in chapterContinuous and Hybrid Simulation

AnyLogic model on the next page the animation of an AnyLogic model of such an

unloading oil tankers scenario is shown

Page 39: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 39

4. Example: Unloading Oil Tankers

Page 40: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 40

Introduction to Simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 41: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 41

5. Example: Jobshop (discrete simulation case study)

Problem description (from Law/Kelton, pp. 684-695) a company is going to build a new manufacturing facility consisting of a

receiving/shipping station and five work stations jobs arrive to the receiving/shipping station and travel to the work

stations on their routing and then leave the system at the receiving/shipping station

jobs are moved from one station to another by one or more forklift trucks

goals: determine the number of machines needed at each work station and the number of forklift trucks

Work station 1 Receiving/shipping Work station 5

Work station 2 Work station 3 Work station 4

In Out

Forklift truck6

Page 42: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 42

5. Example: Jobshop (discrete simulation case study)

More details about the system for the distances between the six stations see Law/Kelton forklift trucks move at constant speed of 5 feet per second jobs of type 1, 2 and 3; routing table:

if a job is brought to a station and all machines are busy or blocked, thejob joins a single queue at that station

service discipline is first-in-first-out (FIFO) as soon as the forklift becomes available, it processes the job with the

shortest distance to it

job type work station in routing 1 3, 1, 2, 5 2 4, 1, 3 3 2, 5, 1, 4, 3

Page 43: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 43

5. Example: Jobshop (discrete simulation case study)

Some model assumptions the times between arrivals of new jobs at the receiving/shipping station

can be described by independent exponentially distributed randomvariables

jobs arrive with a rate of 15 per hour the probability density function f(x) of such inter-arrival times x looks as

follows:

x

f(x)

Page 44: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 44

5. Example: Jobshop (discrete simulation case study)

Some model assumptions (cont.) jobs arriving at the receiving/shipping station are of

type 1 with probability (wp) 0.3, of type 2 wp 0.5, and of type 3 wp 0.2 the time to perform an operation at a particular machine is a Gamma

random variable with a shape parameter of 2 and a mean depending onjob type and machine

x

f(x)

probability density functionfor performing operations

job type

mean service time for successive operations (hours)

1 0.25, 0.15, 0.1, 0.3 2 0.15, 0.2, 0.3 3 0.15, 0.1, 0.35, 0.2, 0.2

Page 45: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 45

5. Example: Jobshop (discrete simulation case study) AutoMod model (screenshot):

Page 46: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 46

5. Example: Jobshop (discrete simulation case study) AutoMod model (screenshot – detail):

Page 47: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 47

5. Example: Jobshop (discrete simulation case study)

Simulations recall our goal:

to determine the number of machines and forklifts required for operation simulations of different system designs with:

– the simulation run corresponds to 920 hours of the system’soperation (115 eight-hour days)

– the first 120 hours (= 15 days) were cut off, since they areconsidered to be a warmup-period with somehow untypical data

– the results were averaged over 10 independent replications of thesimulation

– measures of interest are • throughput of an 8-hour day: on average 120 jobs arrived per day• average time of a job in the system: mean total service time averaged over all jobs is 0.765 hours

• queue lengths and utilizations of stations and forklifts

Page 48: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 48

5. Example: Jobshop (discrete simulation case study)

System design I based on rough queueing-theoretic calculations the number of machines at

work stations 1, ..., 5 is chosen to be 4, 1, 4, 2, 2 and one forklift is used Simulation results

measure 1 2 3 4 5 proportion machines busy or blocked

0.93 1.0 1.0 1.0 0.99

average number in queue

3.7 524.5 519.6 569.2 32.5

station

average daily throughput 94.94

average time in system 109.20

average total time in queues 107.97

average total wait for transport 0.42

proportion forklift moving loaded 0.77

proportion forklift moving empty 0.22

Page 49: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 49

5. Example: Jobshop (discrete simulation case study)

Interpretation of the simulation results– utilizations (busy or blocked) of the machines and the forklift

≈ 100 %– long queues– the throughput of 94.5 far below the mean number of arrivals to the

system (120)– average time in system of 109.2 hours far more than required

service time (0.765 hours)– main time is lost in queues– e.g, number in queue 2 in one of the replications is increasing:

Page 50: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 50

5. Example: Jobshop (discrete simulation case study)

System design II number of machines and forklifts is increased number of machines: 4, 2, 5, 3, 2, forklifts: 2 simulation results:

measure 1 2 3 4 5 proportion machines busy or blocked

0.87 0.51 0.84 0.64 0.90

average number in queue

3.8 0.24 2.18 0.47 6.65

station

average daily throughput 120.29

average time in system 1.76

average total time in queues 0.86

average total wait for transport 0.08

proportion forklifts moving loaded 0.44

proportion forklifts moving empty 0.27

Page 51: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 51

5. Example: Jobshop (discrete simulation case study)

Interpretation of simulation results:– utilizations of machines and forklifts < 100 %– throughput of 120.29 not significantly different from 120– average time in system of 1.76 hours acceptable compared with

required service time of 0.765 hours– looking at the number in queue 2 in one of the replications the

system looks reasonable:

more comparisons and statistical details can be found in Law/Kelton

Page 52: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 52

Introduction to Simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 53: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 53

Systems, Models, and Simulation

Classification of systems system: collection of interacting entities toward accomplishment of some

logical end

state: collection of variables necessary to describe system at particular time

discrete system: variables change instantaneously at separated points in time (occurring of the events)

continuous system: variables change continuously with respect to time

few systems are wholly discrete or continuous, however mostly one type of change predominates for most systems

hybrid system: a mixed continuous and discrete system

Page 54: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 54

Systems, Models, and Simulation (cont.)

Ways to study a systemSystem

Experimentwith the

actual system

Experimentwith a modelof the system

Physicalmodel

Mathematicalmodel

Analytical solutions(i.e., closed form)

Simulation (continuous, discrete-event)

expensive,system may not exist

not typicalin this context

desirable if possible,models easily get too complex method of last resort?

Page 55: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 55

Systems, Models, and Simulation (cont.)

Classification of models model: a representation of the system for the purpose of studying the

system static/dynamic

– in a static model time plays no role(e.g., Monte-Carlo simulation for certain integrations)

– a dynamic model represents a system evolving over time deterministic/stochastic

– a deterministic model has no random component, although theoutput of the model is deterministic it may be impossible to obtain itanalytically (e.g., a complicated system of differential equations)

– a stochastic model has some random components discrete/continuous/hybrid

– loosely speaking, analogous to discrete/continuous/hybrid systems it is a modeling decision which kind of model is chosen to represent the

system

Page 56: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 56

Systems, Models, and Simulation (cont.) Kinds of simulation

dependent on the model type (static/dynamic, deterministic/stochastic,discrete/continuous//hybrid)

in our lectures we focus on dynamic, stochastic, discrete,commonly known as discrete-event simulation (DES)

Some variants of DES: trace-driven simulation:

instead of synthetic sources, such as random number generators, traces aregathered from a real system and are fed as input to the simulation model

object-oriented, process-oriented, agent-based simulation: the related software concepts are used to code the simulation model, underlyingis however DES

parallel and distributed simulation: DES is performed in parallel or distributed

Web-based simulation:distribution of the simulation over the Internet by the use of web technologies:

– client/server models for simulation engine– user interface, use of many computers

Page 57: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 57

Introduction to Simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 58: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 58

Steps in a Simulation Study

Similar to software engineering, with specific simulation aspects, e.g.: Formulate the problem and plan the study Collect data and define the model Is the conceptual model valid? Construct a computer program and verify Make pilot runs Is the programmed model valid? Design experiments Make production runs Analyze output data Document, present, and use results

often: an iterative process !

In the summer semester you can conduct your own simulation study!

Page 59: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 59

Steps in a Simulation Study (cont.)

Iterative process for modeling and simulation:

Page 60: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 60

Steps in a Simulation Study (cont.)

Required expertise

probability and statistics: probability laws, random variables, probabilitydistributions, stochastic processes, confidence intervals, hypothesistesting

modeling paradigms: queuing systems, block models, Petri nets, UML,simulation languages, ...

use of simulation software, programming input modeling: fitting of data to probability distributions random number generators and random variate generators output analysis by statistically sound methods result presentation: choice of charts, scales, etc. ability to interact with the many system experts and managers experience!

Page 61: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 61

Introduction to Simulation

Contents Some demonstrations A First Characterization of Simulation 1. Example: Single-Server Queue (discrete simulation) 2. Example: Predator-Prey (continuous simulation) 3. Example: Bouncing Ball (hybrid simulation) 4. Example: Unloading Oil Tankers (hybrid simulation with randomness) 5. Example: Jobshop (discrete simulation case study) Systems, Models, and Simulation Steps in a Simulation Study Advantages, Disadvantages, and Pitfalls Some Links to Simulation Web sites

Page 62: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 62

Advantages, Disadvantages, and Pitfalls

Advantages of simulation simulation is often the only possible type of investigation allows to estimate an existing system´s behavior under a projected set

of operation conditions alternate proposed system designs can be compared control over experimental conditions can be maintained allows to study systems with a long time frame in compressed time, or

to study the detailed workings in expanded time

Disadvantages of simulation each run of a stochastic simulation model produces only estimates of a

model´s true characteristics simulation models are often expensive and time-consuming to develop sometimes excessive run-times the large volume of output data or the realistic animation often creates a

tendency to place more confidence in a study´s result than justified

Page 63: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 63

Advantages, Disadvantages, and Pitfalls (cont.)

Pitfalls of simulation not well-defined objectives in the beginning inappropriate level of detail (abstraction) failure of communication with management throughout the study treating it just as a programming exercise having no people with knowledge about simulation and statistics failure to account for the randomness in the model failure to collect data inappropriate simulation software simulation software with undocumented/unclear features misuse of animation making a simple replication of a particular system design and treating

the output statistics as the “true answer” using wrong measures ...

Page 64: Overall Plan of Simulation and Modeling I Chaptersce.u-sys.org/Veranstaltungen/Simulation and Modeling 1/SM_2... · Simulation and Modeling I Introduction to Simulation 1 Overall

Simulation and Modeling I Introduction to Simulation 64

Some Links to Simulation Web sites

Winter Simulation Conference (WSC) main conference, good tutorials at beginning and advanced levels,

state-of-the-art research papers www.wintersim.org

Society for Computer Simulation (SCS) main international technical society www.scs.org

Arbeitsgemeinschaft Simulation (ASIM) German speaking association www.asim-gi.org