KT6274 Lecture 5 - Project

download KT6274 Lecture 5 - Project

of 50

description

Simulation and Modelling

Transcript of KT6274 Lecture 5 - Project

  • KKKT 6274

    Modeling and Simulation of Communication and Computer NetworkProf. Dr. Mahamod [email protected]\\10.2.84.119\Public\Lecture\KKKT6274

  • LECTURE 5

    MODELING AND SIMULATION

  • The Airport System A certain airport contains a single runway on which arriving aircrafts must land. Once an aircraft is cleared to land, it will use the runway, during which time no other aircraft can be cleared to land. Once the aircraft has landed, the runway is available for use by other aircraft. The landed aircraft remains on the ground for a certain period of time before departing.

  • Model Development Life CycleFundamentally an iterative processDefine goals, objectives of studyDevelop conceptual modelDevelop specification of modelDevelop computational modelVerify modelValidate model

  • Conceptual Model: Single Server QueueCustomer (aircraft)Entities utilizing the system/resourcesServer (runway)Resource that is serially reused; serves one customer at a timeQueueBuffer holding aircraft waiting to landcustomerqueueserver

  • ObjectivesObjective: Evaluate the performance of the Airport SystemPerformance Metrics Average waiting time: Average time that an aircraft must wait when arriving at an airport before they are allowed to land.Maximum number of aircraft on the ground: Helps to dimension the required surface for the parking area.

  • Conceptual Model: Single Server QueueCustomer (aircraft)Entities utilizing the system/resourcesServer (runway)Resource that is serially reused; serves one customer at a timeQueueBuffer holding aircraft waiting to landcustomerqueueserver

  • Specification Model (Queueing Networks)CustomersWhat is the arrival process?Schedule of aircraft arrivals, e.g., log from specific dates (trace driven)Often, probability distribution defines time between successive customer arrivals (interarrival time)Assumes interarrival times independent, and identically distributed (iid)Not always true (e.g., customers may leave if lines are too long!)Customer attributes?Sometime different flavors, e.g., priorities or other propertiesServersHow much service time is needed for each customer?May use probability distribution to specify customer service time (iid)How many servers?QueueService discipline - who gets service next?First-in-first-out (FIFO), Last-in-first-out (LIFO), random May depend on a property of the customer (e.g., priority, smallest first)Preemption?Queue capacity? What if the queue overflows?

  • Specification Model (cont.)AssumptionsCustomersPoisson Arrival Process: Assume arrivals are i.i.d., following an exponential distribution for inter-arrival times with mean AAssume all customers are identical (no specific attributes)ServersExponential service time (landing time) with mean LOne server (one runway)QueueAssume first-in-first-out queue (FIFO) disciplineAssume queue has unlimited capacity

  • Computational ModelThe System correspond to M/M/1 Queue Model.Performance evaluationAnalytical: using queuing theorySimulation: using a computer programA computer simulation is a computer program that emulate the behavior of a physical system over time.How a computer simulation works?Define state variables: variables that represent a state of the system (e.g. N: number of customers in the queue)Define events: a event changes a state variable of the system (e.g. Arrival, Departure).

  • Computational ModelThe General Algorithm of a simulation programDefine state variablesDefine the eventsFor each Event doChange the corresponding state variablesCreate next events, if anyCollect statisticsProgress simulation timeSimulation time can progress by two means:Regular progress: Time Step implementationIrregular progress: Event-based implementation

  • State VariablesState:InTheAir: number of aircraft either landing or waiting to landOnTheGround: number of landed aircraftRunwayFree: Boolean, true if runway availablecustomerqueueserver

  • Time Step Implementation/* ignore aircraft departures */Float InTheAir: # aircraft landing or waiting to landFloat OnTheGround: # landed aircraftBoolean RunwayFree: True if runway availableFloat NextArrivalTime: Time the next aircraft arrivesFloat NextLanding: Time next aircraft lands (if one is landing)

    For (Now = 1 to EndTime) { /* time step size is 1.0 */if (Now >= NextArrivalTime) { /* if aircraft just arrived */InTheAir := InTheAir + 1;NextArrivalTime := NextArrivalTime + RandExp(A);if (RunwayFree) {RunwayFree := False;NextLanding := Now + RandExp(L);}}if (Now >= NextLanding) { /* if aircraft just landed */InTheAir := InTheAir - 1;OnTheGround := OnTheGround + 1;if (InTheAir > 0) NextLanding := Now + RandExp(L)else {RunWayFree := True; NextLanding := EndTime+1;}}} Advantage Simple Drawback Not efficient

  • Discrete Event SimulationDiscrete Event Simulation (DES): computer model for a system where changes in the state of the system occur at discrete points in simulation time.

    Each Event has a timestamp indicating when it occurs.

    A DES computation: a sequence of events, where each event is assigned a timestamp, which to help to order/schedule the processing of events.

  • Discrete Event Simulation ComputationEvents that have been scheduled, but have not been simulated (processed) yet are stored in a pending event listEvents are processed in time stamp order; why? Example: air traffic at an airport Events: aircraft arrival, landing, departurearrival8:00departure9:15landed8:05arrival9:30schedulessimulation timeschedules

  • Discrete Event Simulation System

  • EventsAn event must be associated with any change in the state of the systemAirport example:Event 1: Aircraft Arrival (InTheAir, RunwayFree)Event 2: Aircraft Landing (InTheAir, OnTheGround, RunwayFree)Event 3: Aircraft Departure (OnTheGround)

  • Event-Oriented World View

  • Example: Air traffic at an AirportModel aircraft arrivals and departures, arrival queuingSingle runway for incoming aircraft, ignore departure queuingL = mean time runway used for each landing aircraft (exponential distrib.)G = mean time on the ground before departing (exponential distribution)A = mean inter-arrival time of incoming aircraft (exponential distribution)StatesNow: current simulation timeInTheAir: number of aircraft landing or waiting to landOnTheGround: number of landed aircraftRunwayFree: Boolean, true if runway availableEventsArrival: denotes aircraft arriving in air space of airportLanded: denotes aircraft landingDeparture: denotes aircraft leaving

  • Arrival EventsArrival Event:InTheAir := InTheAir+1;Schedule Arrival event @ Now + RandExp(A);If (RunwayFree) {RunwayFree:=FALSE;Schedule Landed event @ Now + RandExp(L);}A: mean interarrival time of incoming aircraftNow: current simulation timeInTheAir: number of aircraft landing or waiting to landOnTheGround: number of landed aircraftRunwayFree: Boolean, true if runway available Arrival Process: New aircraft arrives at airport. If the runway is free, it will begin to land. Otherwise, the aircraft must circle, and wait to land.

  • Landed EventLanded Event:InTheAir:=InTheAir-1;OnTheGround:=OnTheGround+1;Schedule Departure event @ Now + RandExp(G);If (InTheAir>0)Schedule Landed event @ Now + RandExp(L);ElseRunwayFree := TRUE;L = mean time runway is used for each landing aircraftG = mean time required on the ground before departingNow: current simulation timeInTheAir: number of aircraft landing or waiting to landOnTheGround: number of landed aircraftRunwayFree: Boolean, true if runway availableLanding Process: An aircraft has completed its landing.

  • Departure EventDeparture Event:OnTheGround := OnTheGround - 1;Departure Process: An aircraft now on the ground departs for a new destination.Now: current simulation timeInTheAir: number of aircraft landing or waiting to landOnTheGround: number of landed aircraftRunwayFree: Boolean, true if runway available

  • Execution Example

  • Output StatisticsComputeThe maximum number of aircraft that will be on the ground at one timeAverage time an aircraft must wait before they are allowed to land

    SolutionMaximum on groundOnTheGround: indicate the number of aircraft currently on groundMaximum on the ground = Max (OnTheGround).Average Waiting timeCompute the Waiting time for each aircraft: Wi = Arrival time Landing TimeCompute the total sum of all waiting times: Wtotal= sum(Wi)Compute the total number of aircraft: NtotalCompute the average waiting time: Wavg = Wtotal/sum(Wi)

  • SummaryMethodologyImportant to have a reasonably clear conceptual and specification model before moving to implementation (computational model)Key concepts: state variables and changes in stateSimulation engine: largely independent of applicationSimulation model: state variables and code to modify stateTime stepped vs. event driven executionIn principle, either can be used to model systemDiscrete-event simulation approach more commonly used to model queuing systems

  • War gaming: test strategies; trainingFlight SimulatorTransportation systems: improved operations; urban planningComputer communicationnetwork: protocol designParallel computer systems: developing scalable softwareGamesA few more applications

  • Why Modeling and Simulation?

  • PERFORMANCE EVALUATION

  • Performance Metrics

  • The Queuing Times

  • The Performance Metric is a measurable quantity that precisely captures what we want to measure (response time, throughput, delay, etc.).Performance Metrics

  • For example, in computer systems, we might evaluateThe response time of a processor to execute a given task.The execution time of two programs in a multi-processor machine.In network systems, we might evaluateThe (maximum/average) delay experienced by a voice packet to reach the destinationThe throughput of the network The required bandwidth to avoid congestionPerformance Metrics

  • What does affect the performance?The performance of a system is dramatically affected by the Workload. The Workload: it characterizes the Quantity: e.g. number of carsNature: type of cars (cars, trucks, motocycle, etc.)

  • In the context of Web Servers, system inputs are http requests (GET or POST requests). The workload characterizes: The intensity of the requests: how many requests are received by the web server. High intensities deteriorate the performance.The nature of the requests: the request can be simple GET request or a request that require the access of a remote database. The performance will be different for different request types. What does affect the performance?

  • BenchmarksBenchmarks: used to generate loads that is intended to mimic a typical user behaviour.Wikipedia definition:In computing, a benchmark is the act of running a computer program, a set of programs, or other operations, in order to assess the relative performance of an object, normally by running a number of standard tests and trials against it. Benchmarking is usually associated with assessing performance characteristics of computer hardware:Example: the floating point operation performance of a CPU.Software benchmarks: run against compilers or database management systems.

  • CS433: Modeling and SimulationDr. Anis KoubaAl-Imam Mohammad Ibn Saud University

    02 October 2010Lecture 02: Modeling

  • Deterministic PerformanceUsing Network CalculusQueueuing SystemStochastic PerformanceUsing Queueing TheoryExample: Deterministic vs. Stochastic

    Chart2

    0.0020408163

    0.0020833333

    0.0022222222

    0.0022727273

    0.0025

    0.0026666667

    0.0028571429

    0.0030769231

    0.0033333333

    0.0036363636

    0.004

    0.0044444444

    0.005

    0.0057142857

    0.0066666667

    0.008

    0.01

    0.0133333333

    0.02

    0.04

    0.05

    0.0666666667

    0.1

    0.2

    r (%)

    W(sec)

    Waiting vs. Utilization

    Sheet1

    Wlurw

    0.0020408163105000.020.0020408163

    0.0020833333200.040.0020833333

    0.0022222222500.10.0022222222

    0.0022727273600.120.0022727273

    0.00251000.20.0025

    0.00266666671250.250.0026666667

    0.00285714291500.30.0028571429

    0.00307692311750.350.0030769231

    0.00333333332000.40.0033333333

    0.00363636362250.450.0036363636

    0.0042500.50.004

    0.00444444442750.550.0044444444

    0.0053000.60.005

    0.00571428573250.650.0057142857

    0.00666666673500.70.0066666667

    0.0083750.750.008

    0.014000.80.01

    0.01333333334250.850.0133333333

    0.024500.90.02

    0.044750.950.04

    0.054800.960.05

    0.06666666674850.970.0666666667

    0.14900.980.1

    0.24950.990.2

    0.254960.9920.25

    0.33333333334970.9940.3333333333

    0.54980.9960.5

    14990.9981

    Sheet1

    r (%)

    W(sec)

    Waiting vs. Utilization

    Sheet2

    Sheet3

  • Define goals, objectives of studyDevelop conceptual modelDevelop specification of modelDevelop computational modelVerify modelValidate modelFundamentally an iterative processModel Development Lifecycle

  • Model Development Lifecycle

  • Model Development Lifecycle

  • Model Development Lifecycle

  • Example: Airport Check-in Desk Queuing We consider flight check-in desks in an Airport. The administration of the airport wants to improve its quality of service by reducing the waiting time of travelers. For that purpose, they want to design what could be the best queuing strategy to have the minimum waiting time. The main problem is to know what is the best queuing strategy that reduces the waiting time of travelers in check-in desks.

  • Step. 1. Define the objectives of the study Main Objective: what is the best queuing strategy that reduces the waiting time of travelers in check-in desks. Find a model that enables to compute waiting time of travelersSolution 1. Queueing Theory (Analytical Model)Solution 2. Simulation (Computer Program Model)Two Possible Models

    Model 1Model 2

  • Step. 2. Develop Conceptual ModelOne QueueN=3 serversThree QueuesN=3 serversCustomers: travelers that arrive to the check-in deskServers: represents the agent (officer) that makes the flight registrationWhat are the elements of the system?

  • Step. 3. Develop Specification ModelOne Queue: Length= 60 TravelersN=3 AgentsService rate: 30 travelers/hourTravelers arrive with a rate 1 travelers/minuteModel 1Model 2What are the characteristics of the elements of the system?Three Queue: Length= 20 Travelers/QueueN=3 AgentsService rate: 30 travelers/hourTravelers arrive with a rate 1 travelers/minuteTravelers choose a queue with a probability of 1/3.

  • Step. 4. Develop Computation ModelAnalytical Model: Queueing TheoryModel 1 is better than Model 2 because it has lower delay

  • Step. 4. Develop Computation ModelSimulation Model: ArenaModel 1 is better than Model 2 because it has lower delay

  • Step. 4. Develop Computation ModelSimulation Model: Arena

  • Simulation ToolsSymbolic versus numerical; Open and closed loopSoftware packageMathematicaSimscriptScilabMathcad

  • ReferencesDr. Anis Kouba, CS433: Modeling and Simulation (http://coins.csrlab.org/imamu/akoubaa/cs433/)ref

    ******************************