BIF3203 - Part I Intro to Simulation (November 2012)

Embed Size (px)

Citation preview

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    1/49

    N. Maingi - November 2012N. Maingi - November 2012

    BIF3203Computer SimulationPart I: Introduction to Simulation

    Nicodemus Maingi

    [email protected] II First Floor Staffroom, 3B

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    2/49

    N. Maingi - November 2012

    Systems, Models and Simulationn What is simulation?n The imitation of the operation of a real-world process

    or system over time

    n Most widely used tool (along with LP) for decision-makingn Usually on a computer with appropriate softwaren An analysis tool to answer WHAT IF questions

    n Applied to complex systems that are impossible tosolve mathematically.

    n The focus of this course is one form of simulationmodeling the discrete event simulation.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    3/49

    N. Maingi - November 2012

    Simulation in decision-makingn Business decisions

    n Warehouse capacitiesn Production levelsn Staff hiringn Evaluating Investment decision or opportunities

    n Engineering decisionsn No. of processors in a computer systemn Design improvements e.g. automobile suspension

    systems

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    4/49

    N. Maingi - November 2012

    Systems and system

    environmentsnA set of interacting components or entities

    working together towards a common goal/

    aim/objectivenAlso a collection of entities e.g. people or

    machines, that work together towards somelogical end or purpose.

    n In practice, system depends on theobjective.n The collection of entities or components for a

    system may be a subset of another system.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    5/49

    N. Maingi - November 2012

    Systemsn Examples

    nA manufacturing plant with its machines,conveyor belts, production schedules,output etc.

    nA telecommunication system with itsmessages, network servers etc

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    6/49

    N. Maingi - November 2012

    Systems (2)n Examples of systems:

    n Solar system sun and planets interacting underinfluence of gravity

    n Disease epidemicn Telephone network etc

    n For each system, there are many questionsthat could be asked, for example:

    n When is the next solar eclipse?n When will half the population be infected by the

    disease?n What is the average waiting time for

    connection?

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    7/49

    N. Maingi - November 2012

    Components of a systemBasic system terminology

    n Entity: is an object of interest within a systemnAn object is the system that requires explicit

    representation in the model

    n Examplesn Patientsn Doctors and nursesn Rooms, Labs, Hospital bedsn Cashier, customer etc.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    8/49

    N. Maingi - November 2012

    Components of a system (2)nAttribute: refers to a common characteristic

    or property of an entity, but with a specific

    values that differs from other entities.n Example 1: Patient

    n Name of patientn Agen Gendern Temperaturen Blood Pressuren

    Type of illness

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    9/49

    N. Maingi - November 2012

    Components of a system (3)n Example 2: Bank Customer

    n Customer account numbernAccount numbernAccount balancen Branch

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    10/49

    N. Maingi - November 2012

    Components of a system (4)nActivity: represents a time period of

    specified time

    nA duration of specified length (e.g. a servicetime or arrival time), which is known when itbegins (although it may be defined in termsof a statistical distribution).

    nExample: Health Centren Surgeryn Checking patients temperature, blood pressuren X-ray

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    11/49

    N. Maingi - November 2012

    Components of a system (5)nVariable: a piece of information that reflects

    some characteristic of a system

    n Example: Health centren Number of patients in the queuen Number of idle doctors at some point in timen Current time

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    12/49

    N. Maingi - November 2012

    Components of a system (6)n State: a collection of variables that contain all

    the information necessary to describe the

    system at any time.n Example: Health Centre

    n {Number of patients in the system,Status of doctors (busy/Idle),

    Number of idle doctors,

    Status of lab equipment (busy/Idle/Not Functioning),etc}

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    13/49

    N. Maingi - November 2012

    Components of a system (7)n Event: An instantaneous occurrence that changes the

    state of a system.n The term endogenousis used to describe activities

    and events occurring within a systemn The term exogenousis used to describe activities and

    events outside the system but within its environmentthat affect the system.

    n In the bank study, the arrival of a customer is anexogenous event, and the completion of service of acustomer is an endogenous event.

    n Example: Health Centren Arrival of a new patientn Completion of service (e.g. doctors examination)n

    Failure of medical equipment

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    14/49

    N. Maingi - November 2012

    Types of systemsn Systems can be classified as discrete or

    continuous

    n Discrete system: refers to one in which thestate variables change only at a discrete setpoint in time.

    n Example: a bank: the no. of customers in thebank changes when a new customer arrivesor when a customer leaves

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    15/49

    N. Maingi - November 2012

    Discrete system

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    16/49

    N. Maingi - November 2012

    Types of systems (2)n Continuous system: is one whose state

    variables change continuously with respect to

    time.n Example:

    n the level of water in a dam. During and for sometime after a rain storm, water flows into the dam.

    n Water is drawn from the dam for flow control andto make electricity.

    n Evaporation also decreases the water level.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    17/49

    N. Maingi - November 2012

    Continuous system

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    18/49

    N. Maingi - November 2012

    Model

    n Refers to an abstract and simplified representation ofa system

    n It is an abstract and simplified representation of anobject, a system, or an idea in some form other thanthat of the entity itself.

    n It specifiesn Important componentsn The way in which components interact

    n It is not an exact re-creation of the original system ittries to model

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    19/49

    N. Maingi - November 2012

    Modeling

    n Modeling is the process of producing a model.nA model is similar to but simpler than the

    system it represents.nA model could be aimed at enabling a catalyst

    predict the effects of changes to the system.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    20/49

    N. Maingi - November 2012

    Model classifications

    n Models are classified in order to put likewith like.

    They may be classified as;1. Form: in which form the model is

    represented.

    n Models can be classified as being Verbal,Diagrammatic, Mathematical or Physical.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    21/49

    N. Maingi - November 2012

    Model classifications (2)

    n Conceptual (verbal, descriptive) only verbaldescriptions are made

    Examples:n A description of directions to my office: Go toAnniversary Towers in town, take a lift to the 21stfloor, turn left after getting out of the lift, walkpast the sign reading Strathmore Consulting Ltd.,count 5 doors on your right my office is the 6th

    door marked with my initials N.M.n This is a spatial model of my office location

    relative to a certain starting point.n It describes the mental model of the route to my

    office in verbal terms.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    22/49

    N. Maingi - November 2012

    Model classifications (3)

    n A verbal portrait of a person: He is tall with grey hairand brown eyes, his cheeks are smooth and light, hisnose is huge and pimpled. His left ear is larger than

    the right one and one of his front teeth is missing.

    n This is a static verbal model of a persons face.n Etc

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    23/49

    N. Maingi - November 2012

    Model classifications (4)

    n Conceptual (diagrammatic) in some cases a gooddrawing may save you lots of agonizing verbaldescriptions.

    Examples:n A drawing or an image is also a model.n It can offer much more information than the verbal

    description.n In some cases a diagram can exclude some of the

    uncertainties that may come from the verbal description.

    n For example, the verbal model mentioned the left ear but didnot specify whether it is the person's left ear or the person'sleft ear as seen by the observer. This ambiguity disappearswhen the image is offered.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    24/49

    N. Maingi - November 2012

    Model classifications (5)

    n Physical - a reconstruction of the real object at asmaller scale.

    Examples:n Matchbox toy carsn An airplane model in a wind tunnel

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    25/49

    N. Maingi - November 2012

    Model classifications (6)

    n Formal (mathematical) - that is when equations and formulasreproduce the behavior of physical objects.

    n A mathematical model uses symbolic notation and mathematicalequations to represent a system.

    n A mathematical model is a description of the properties andinteractions in the system, i.e. equations relating different quantitiesor variables, e.g. Newtons law: Force = Mass * acceleration (F = ma)

    n A simulation model is a particular type of mathematical model of asystem also linear programming models.

    n Examples:n Q = m C (t1 - t2) - a model of heat emitted by a body of mass m,

    when cooling from temperature t1 to temperature t2. C is the heatcapacity parameter.

    n Y = Yo* 2t/da model of an exponentially growing population. Yo - initialpopulation, d - doubling time.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    26/49

    N. Maingi - November 2012

    Model classifications (7)

    2. Time: how time is treated in the modeln Dynamic vs. Static.

    nA Static model gives a snapshot of the reality.n In Dynamic models, time changes and so do the variables in

    the model.

    nAstaticsimulation model, sometimes called a Monte Carlosimulation, represents a system at a particular stationarypoint in time.

    n Dynamicsimulation models represent systems as theychange over time. The simulation of a bank from 9:00 A.M.to 4:00 P.M. is an example of a dynamic simulation.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    27/49

    N. Maingi - November 2012

    Model classifications (8)

    n Examples:n A map is a static model. So is a photo.n A cartoon is a dynamic model.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    28/49

    N. Maingi - November 2012

    Model classifications (9)

    n Continuous vs. Discrete. : aretime incrementedstep-wise in a dynamic model or is it assumed tochange constantly, in infinitesimally small increments.

    n A discrete system is where the state of the systemchanges at discrete time intervals while a continuoussystem changes smoothly.

    n Examples:n You may watch a toy car roll down a wedge. It will be a

    physical model with continuous time.

    n A movie is a discrete model. Motion is achieved by viewingseparate images, taken at certain intervals.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    29/49

    N. Maingi - November 2012

    Model classifications (10)

    n Stochastic vs. Deterministic:n Deterministic models: the state of the system at the next time

    step is entirely defined by the state of the system at thecurrent time step and the transfer functions used.

    n Simulation models that contain no random variables areclassified as deterministic.

    n Deterministic models have a known set of inputs which willresult in a unique set of outputs.

    n Deterministic arrivals would occur at a dentist's office if allpatients arrived at the scheduled appointment time.

    n A deterministic model is where input and output variables arefixed values (i.e. the models have a unique output for eachinput).

    n No random variables.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    30/49

    N. Maingi - November 2012

    Model classifications (11)

    n Deterministic models can be solved analytically.n Examples are Linear programming models or inventory

    control models which can be solved graphically or by using

    classical techniques e.g. simplex method.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    31/49

    N. Maingi - November 2012

    Model classifications (12)

    n Stochastic models: there may be several future statescorresponding to the same current state.

    n Each of these future states may occur with a certain probability - Astochasticsimulation model has one or more random variables as

    inputs.n Random inputs lead to random outputs - Since the outputs are

    random, they can be considered only as estimates of the truecharacteristics of a model.

    n The simulation of a bank would usually involve random inter-arrivaltimes and random service times.

    n Thus, in a stochastic simulation, the output measures - the averagenumber of people waiting, the average waiting time of a customer -must be treated as statistical estimates of the true characteristics ofthe system.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    32/49

    N. Maingi - November 2012

    Model classifications (13)

    n A stochastic model is where at least one of the inputsor outputs variables is probabilistic (i.e. modelscontain random variables e.g. inter-arrival times of

    customers)n Examples: queuing models, inventory models and so

    on.

    n Majority of stochastic models cannot be solvedanalytically and a numerical technique (simulation) isoften used.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    33/49

    N. Maingi - November 2012

    Model classifications (14)

    3. Method: how the model is formulated and studied.Analytic vs. Computer models.

    n Mathematical models easily become too complex tobe studied analytically.

    n The models solved by simulation method are calledsimulation models.

    n Simulation generally refers to a computerization ofthe developed model, run over time to study theimplications of the defined interactions of the partsof the system.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    34/49

    N. Maingi - November 2012

    Model classifications (15)

    n Simulation on static systems - Monte-Carlosimulation.

    n For dynamic systems the choice is between Discrete-Event simulation and continuous simulation.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    35/49

    N. Maingi - November 2012

    How to study a system.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    36/49

    N. Maingi - November 2012

    How to study a system model

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    37/49

    N. Maingi - November 2012

    When to use simulation

    Simulation can be used for the following purposes:n When we need to study and experiment with the internal

    interactions of a complex system, or of a subsystem within a

    complex system( If the system is complex to model)n In informational, organizational, and environmental - changes can

    be simulated, and the effect of these alterations on the model'sbehavior can be observed.

    n When the knowledge gained in designing a simulation model maybe of great value toward suggesting improvement in the systemunder investigation.

    n When we want to observe quantitative performance measures

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    38/49

    N. Maingi - November 2012

    When to use simulation (2)

    n Simulation can be used to experiment with new designs orpolicies prior to implementation, so as to prepare for what mayhappen.

    nSimulation can be used to verify analytic solutions (compareanalytical & simulation solution)

    n By simulating different capabilities for a machine, requirementscan be determined.

    n Simulation models designed for training allow learning withoutthe cost and disruption of on-the-job learning.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    39/49

    N. Maingi - November 2012

    When not use simulation

    n When the problem can be solved using common sense.n Example: an automobile-tag facility serving customers who arrive

    randomly at an average rate of 100/hour and are served at a meanrate of 12/hour. To determine the minimum number of serversneeded, simulation is not necessary. Just compute 100/12 = 8.33,

    indicating that nine or more servers are needed.n If the problem can be solved analytically.

    n For example, under certain conditions, the average waiting time inthe example above can be determined from curves that weredeveloped by Hillier and Lieberman [1995].

    n If it is easier to perform direct experiments.n Example of a fast-food drive-in restaurant is given, where it was

    less expensive to have a person use a hand-held terminal and voicecommunication to determine the effect of adding another orderstation on customer waiting time.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    40/49

    N. Maingi - November 2012

    When not use simulation (2)

    n If the costs exceed the savings.n There are many steps in completing a simulation as we shall see

    later and these must be done thoroughly.

    n If a simulation study costs $20,000 and the savings might be$10,000, simulation would not be appropriate.

    n If the resources or time are not available.n If the simulation is estimated to cost $20,000 and only $10,000 is

    available at the time, the suggestion is not to venture into asimulation study.

    n Similarly, if a decision in needed is two weeks and a simulation willtake a month, the simulation study is not advised.

    n If no data is available, not even estimates, simulation is notadvised.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    41/49

    N. Maingi - November 2012

    Advantages of simulationapproaches

    n Simulation can be used to study complex systems.n Simulation can be used to answer What if type of

    questions.

    n Simulation can be used in the design of new systemsor in the modification of existing systems withoutdisturbing the system.

    n Simulation often gives a better understanding of asystem.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    42/49

    N. Maingi - November 2012

    Disadvantages of simulationapproaches

    n Simulation does not guarantee optimal solutions.n Simulation is a sampling device so exact solutions

    are not possible.n Discrete-event simulation software packages areexpensive.n Collection of data for simulation model can be difficult

    and time consuming.n Simulation models can take longer to develop than an

    analytical model.n Statistical knowledge is required to analyze the output from

    a simulation model.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    43/49

    N. Maingi - November 2012

    The Simulation Cycle

    n Due many different methods of simulation there is nouniversally valid formula in performing a simulation.

    n Some basic steps common in nearly all simulations

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    44/49

    N. Maingi - November 2012

    Steps in simulation study

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    45/49

    N. Maingi - November 2012

    Verification & Validation

    nVerification: is the process of determining ifthe operational logic of a simulation model is

    correct.n Debugging the simulation using software

    nValidation: is the process of determining if themodel accurately represents the system it

    attempts to model.n Comparison of model results with collected data

    from the real system.

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    46/49

    N. Maingi - November 2012

    Experimental design

    nAlternative scenarios to be simulatedn Type of output data analysis (steady-sate vs

    terminating simulation analysis)n Number of simulation runsn Length of each runn

    The manner of initializationnVariance of reduction

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    47/49

    N. Maingi - November 2012

    Analysis of results

    n Statistical tests for significance & rankingn Point estimationn Confidence Interval Estimation

    n Interpretation of resultsn Do more runs?

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    48/49

    N. Maingi - November 2012

    Documentation & reporting

    n Program documentationn Future modificationsn

    Create confidencen Progress reports

    n Frequent reports (e.g. monthly)n Alternative scenariosn Performance measures or criteria usedn Results of experimentsn Recommendations

  • 7/30/2019 BIF3203 - Part I Intro to Simulation (November 2012)

    49/49

    Implementation