Introduction to Computer Simulation
Simulation Simulation means reproducing with a given accuracy how a system works in given conditions. A system may be: Input - a business process; - a manufacturing plant -anhospital; - a military mission; - etc. SYSTEM Ouput
Simulation Asimulation model aims at evaluating a performance indicator of a given system configuration or policy. It does not optimize i (i.e. does not determine the best configuration or policy) although it can play a role in a larger optimization algorithm.
Stochastic Simulation The conditions i in which h the system works can be deterministically known or may be characterized in a probabilistc fashion.
Discrete Event Simulation The state of some systems change only a discrete time instants. State changes when a new part arrives or a part service is completed
Example: simulating a new production process Comparison of alternative designs and policies before starting building the physical plant.
Some other applications Transportationsystems Plan large passenger air terminal Road traffic simulation Supply chain management Simulation of movement of crude and refined oil around the world Defence Logistics operations Simulation of battles
Simulation Simulation means reproducing how a system works in given conditions. In order to study the above mentioned system, another system (called simulator) isused. A quite common simulator is based on software (computert simulation). ) Other simulators include plastics.
Why simulate Simulation can be used to study the behavior of a system which does not exist yet; compare alternative designs of a new system compare alternative policies of an existing i system study the response of an existing system subject to unusual or extreme conditions (e.g., what if the market grows by 150% next year? )?)
Drawbacks of computer simulation In computer simulation, each part of the system is represented by a procedure/subroutine which reproduces its input/output behavior. Realistic simulations may require long computer programs of some complexity. There are special purpose simulation languages to ease this task but it is rarely simple. In addition, running a computer simulation can be very time consuming.
Approaches alternative to simulation Direct experimentation Mathematical modelling
Simulation vs direct experimentation Real experiments may be more expensive that computer simulation. Once the computer program has been written, we can simulate weeks, months or even years in seconds of computer time. When reproducing the effect of extreme conditions, it may be safer using simulation. Simulation allows to evaluate the effects of changes in legislation.
Simulation vs mathematical modelling Most mathematical models are not able to cope with dynamic and transient effects and operate instead on average values. Some mathematical models (e.g., queuing models) permit only certain probability distributions. Simulation does NOT indicate what is the best system design or policy. It simply reproduces the response a specific system or policy.
G/G/ c queue c serventi
M/M/c - Steady state expected system time where: W Intensità di traffico c 1 p0 λ ρ 1 = + 2 λ c! μ (1 ρ ) c μ p 0 j 1 c 1 c 1 λ ( λ/ μ) = j = 0 j! μ + c!(1 ρ) Determine the minimum number c of servers such that W is less than or equal to 10 minutes: easy
How to perform a simulation study
An example I should improve my operations in some way. Customers often complain. Service is quite poor especially around midday and during late evening IT manager: Where are system s bottlenecks? Should I buy additional resources? What is the optimal system configuration?
A simulation study: main steps Problem structuring Design of experiments Model building Data collection and parameter estimation (Implementation) Verification Validation Simulattion Run(s) Output analysis Implementation
A simulation study: main steps Firstly, I should try to determine my current bottleneck(s). Then I should simulate alternative system s configurations Problem structuring Design of experiments Model building Data collection and parameter estimation (Implementation) Verification Validation Simulattion Run(s) Output analysis Implementation
A simulation study: main steps What is the arrival rate of each class of customers requests? Are these arrival rates varying during the day/week/month/year/in / the long run? Problem structuring Design of experiments Model building Data collection and parameter estimation (Implementation) Verification Validation Simulattion Run(s) Output analysis Implementation I should estimate these parameters. Maybe interarrival times are independent I should test this hypothesis
A simulation study: main steps I think it is reasonable tomodel my system as a network of queues Problem structuring Design of experiments Model building Data collection and parameter estimation (Implementation) Verification Validation Simulattion Run(s) Output analysis Implementation I should use the principle of parsimony start with a very simple model, test it, then add some more details (if necessary)
A simulation study: main steps Should Iuseaspreadsheet/and h add-in/a / VIMS (Visual Interactive Modelling System)? Problem structuring Design of experiments Model building Data collection and parameter estimation (Implementation) Verification Validation Simulattion Run(s) Output analysis Implementation Or should I write a code in a general purpose (C/C++/ ) or tailored (SIMAN) programming language? I hope this is not the case!!!!!
A simulation study: main steps Let me see if my simulation model reproduces my current system behaviour Problem structuring Design of experiments Model building Data collection and parameter estimation (Implementation) Verification Validation Simulattion Run(s) Output analysis Implementation
A simulation study: main steps Let s run my simulation model. Since my system is stochastic, maybe I need to perform several runs for each alternative system configuration or policy in order have accurate performance estimates Problem structuring Design of experiments Model building Data collection and parameter estimation (Implementation) Verification Validation Simulattion Run(s) Output analysis Implementation
A simulation study: main steps Now I have to estimate my KPIs. Oh my god, I have to process a huge amount of data Problem structuring Design of experiments Model building Data collection and parameter estimation (Implementation) Verification Validation Simulattion Run(s) Output analysis Implementation
Simulazione ad eventi discreti
Definizioni Sistema ad eventi discreti (= tempo-discreti) Sistema il cui stato varia soltanto in istanti di tempo discreti (non in modo continuo) al verificarsi di determinati eventi. Es: I sistemi modellabili come code o reti di code Simulazione ad eventi discreti (Discrete Event Simulation, SED) Simulazione di un sistema ad eventi discreti
Pseudocodice dello schema di avanzamento del tempo Gli eventi sono gli accadimenti che possono produrre un cambiamento di stato del sistema: C lista eventi futuri Il k-mo evento A k è possiede diversi attributi tra cui: il tempo di realizzazione t k la tipologia (arrivo di un cliente, fine del servizio di un cliente, ). Insieme degli eventi conseguenti ad A k :E k + Insieme degli eventi resi impossibili da A k : E - k
Pseudocodice dello schema di avanzamento del tempo Lo stato del sistema dopo l arrivo della richiesta k-ma: x k Legge di transizione di stato (peculiare del sistema): s k = φ(s k-1, A k )
Esempio: coda G/G/1 Eventi esogeni: arrivi clienti agli istanti 0, 2, 4, 7, 8 Durate del servizio:5,1,3,3,1,rispettivamente
Esempio: coda G/G/1 t = 0: arrivo cliente 1. Stato servente = occupato; lunghezza coda = 1; t = 2: arrivo cliente 2. Stato servente = occupato; lunghezza coda = 2; T1 = 2; t = 4: arrivo cliente 3. Statot servente = occupato; lunghezza coda =3; T1 = 2; T2 = 2; t = 5: partenza cliente 1. Stato servente = occupato; lunghezza coda = 2; T1 =2;T2=2;T3=1;W1=5; t = 6: partenza cliente 2. Stato servente = occupato; lunghezzacoda=1;t1 =2;T2=3;T3=1;W1=5;W2=4; t = 7: arrivo cliente 4. Stato servente = occupato; lunghezza coda = 2; T1 = 3; T2 = 3; T3 = 1; W1 = 5; W2 = 4; t = 8: arrivo cliente 5. Stato servente = occupato; lunghezza coda = 3; T1 = 3; T2 = 4; T3 = 1; W1 = 5; W2 = 4; t = 9: partenza cliente 3. Stato servente = occupato; lunghezza coda = 2; T1 = 3; T2 = 4; T3 = 2; W1 = 5; W2 = 4; W3 = 5; t = 12: partenza cliente 4. Stato servente = occupato; lunghezza coda = 1; T1=3;T2=7;T3=2;W1=5;W2=4;W3=5;W4=5; t = 13: partenza cliente 5. Stato servente = occupato; lunghezza coda = 0; T1 = 4; T2 = 7; T3 = 2; W1 = 5; W2 = 4; W3 = 5; W4 = 5; W5 = 5.
Esempio: coda G/G/1
Compito sostitutivo della lezione di venerdì SSJ: Stochastic Simulation in Java http://www.iro.umontreal.ca/~simardr/ssj/indexe.html Comprendere la struttura del codice che consente di simulare una coda M/M/1 Siate preparati a discuterne nella lezione di lunedì 15 novembre.