24
1 Simulation Implementation Using high-level languages

Simulation Implementation

  • Upload
    brinda

  • View
    43

  • Download
    0

Embed Size (px)

DESCRIPTION

Simulation Implementation. Using high-level languages. Implementation of a Single- Server Queuing System. Two Main Entities SERVER: Busy= 0/1 QUEUE: Qsize= # Two Critical Events – for customers Arrival Complete Service (Depart) How do these entities interact? Initialization? - PowerPoint PPT Presentation

Citation preview

Page 1: Simulation  Implementation

1

Simulation Implementation

Using high-level languages

Page 2: Simulation  Implementation

2

Implementation of a Single- Server Queuing System

Two Main EntitiesSERVER: Busy= 0/1QUEUE: Qsize= #

Two Critical Events – for customersArrivalComplete Service (Depart)

How do these entities interact?Initialization?How are each of the variables affected?How should simulation terminate?

Page 3: Simulation  Implementation

3

Snapshot or System Image

State of the system at a given time

State variablesQueue

Future Events List (FEL)

Page 4: Simulation  Implementation

4

Generating Future Events

Bootstrapping: a method for generating an arrival stream on an “as you go” basis

As opposed to generating all events at oncea.k.a. on-the-fly

Page 5: Simulation  Implementation

5

Generating Future EventsProcess1. Generate initial arrival; when it is

removed from FEL generate new interarrival time - add to clock for arrival time- place next arrival on FEL

2. When item is placed in service, generate service time - add to clock – place completion event on FEL

Page 6: Simulation  Implementation

6

DATA StructuresFuture Events List (FEL)Queue (1 or more)What information is required for each one?What information is not required but might be convenient?When and how are insertions & deletions made?When are various units of information generated (calculated)?

Page 7: Simulation  Implementation

7

QueueStandard FIFO

Customer identificationTime entered queue

Arrival timeType of service being requested (if more than one)

Page 8: Simulation  Implementation

8

Future Events List

Array implementationEach row represents a specific eventCustomer ID (identification number)

Time of occurrenceSearch for smallest time to get the “next event”

Page 9: Simulation  Implementation

9

Future Events List

Linked List ordered by time of occurrence

Event TypeTime of OccurrenceIdentification of customer

Page 10: Simulation  Implementation

10

Generating Arrivals Initialize at a fixed time or time zeroOne for each type of arrival Subsequent arrivals are generated as arrival is removedRemove arrival- generate IAT- add to current time (clock) - put on FELAt any time, there should only be one arrival of any given type

Page 11: Simulation  Implementation

11

Generating Departures Complete Service

Generated when customer enters the service that will cause the departureNot necessarily upon arrival, not if enter queue, only when enter serviceEnter service (from queue or from arrival) - generate service time - add to current time (clock) - put on FEL

Page 12: Simulation  Implementation

12

Generating Events

Terminate EventOnly one: placed on FEL at initialization

Snapshot Event (Status Report)Initialize 1st oneRemove from FEL- add time unit - return to FEL

Page 13: Simulation  Implementation

13

What? Me Simulate?

Paper by Dr. Halverson

Page 14: Simulation  Implementation

14

Generation of Events

Initialization of FELOne arrival (of each type)SnapshotStop event

Generation of ArrivalWhen removed from FEL, generate next arrival

Page 15: Simulation  Implementation

15

MAINInitialize FEL, statistical variables, clockRemove next-event from FELWhile not stop-event

Clock = next-event.timeCase next-event of

Arrival: produce next arrival call ARRIVE

Departure: call DEPARTSnapshop: call SNAPSHOT

Remove next-event from FEL

Stop-simulation: call STATS; call OUTPUT

Page 16: Simulation  Implementation

16

ARRIVE

If server_status = busyThen call ENTER-QUEUEElse call ENTER-SERVICE

Page 17: Simulation  Implementation

17

DEPART

If queue = emptyThen server_status= freeElse call

REMOVE-FROM-QUEUE

Page 18: Simulation  Implementation

18

ENTER-SERVICE

server_status = busyGenerate departure eventUpdate service stats

Page 19: Simulation  Implementation

19

ENTER-QUEUE

Add customer to queueUpdate queue statistics

Page 20: Simulation  Implementation

20

REMOVE-FROM-QUEUE

Update queue and statisticsCall ENTER-SERVICE

Page 21: Simulation  Implementation

21

STATS

Compute final averages, totals, etc.

IAT, Service time, UtilizationQueue length, max, min, averageNumber arrivals, departuresWait time, Time in system

Page 22: Simulation  Implementation

SNAPSHOT

Generate next Snapshot event, place in FELPrint State variablesPrint QueuePrint FEL

22

Page 23: Simulation  Implementation

23

OUTPUT

Print results

Page 24: Simulation  Implementation

PROJECT #1

Must follow the guidelines presented in class for the form of your program. Must use object oriented approachPrint out of Code due in 1 week

24