simulation of operations the discrete event approach to computer modelling

32
Simulation of Operations The Discrete Event Approach to Computer Modelling

Upload: silvia-lloyd

Post on 21-Jan-2016

233 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Simulation of Operations The Discrete Event Approach to Computer Modelling

Simulation of Operations

The Discrete Event Approach to Computer Modelling

Page 2: Simulation of Operations The Discrete Event Approach to Computer Modelling

Conceptual Model

• The first step in modelling.– Avoid the temptation of modelling directly in a

simulation tool.– Identify the minimum set of entities– Determine an appropriate level of detail– map the relationships between them

Page 3: Simulation of Operations The Discrete Event Approach to Computer Modelling

All models are simplifications• Models are abstractions: they

don’t represent all the associations and attributes of the real.

• A conceptual Model identifies which associations are to be retained.

• If important associations or attributes are left out then the resulting computer model is likely to be flawed or invalid.

Page 4: Simulation of Operations The Discrete Event Approach to Computer Modelling

ACDs are conceptual models

DUMMY

DUMMY

WORLD CALL BUFFERInitiate Internal

Initiate External

BASE STATION

AVAILABLEFREQ’S

CALL

CALL

CALL

Internal call

External call

FREQUENCIES (6)

Page 5: Simulation of Operations The Discrete Event Approach to Computer Modelling

Coding a Simulation

• Define the entities’ names and attributes• Specify their interactions using Boolean and

conditional logic– IF x AND y OR x AND z THEN ….

• Specify a visual representation• Specify the input data• Specify the output statistics• Test and debug

The result of this is an executable program; a simulation.

Page 6: Simulation of Operations The Discrete Event Approach to Computer Modelling

Components of a Simulation • System State• Simulation Clock• Event List• Statistical Counters• Initialisation routine• Time advance mechanism• System description routines• Report generator• Random sampling functions• Graphics sub-model and display handling

Page 7: Simulation of Operations The Discrete Event Approach to Computer Modelling

Basic Structure

Main program

SystemDescription

Utilities

Page 8: Simulation of Operations The Discrete Event Approach to Computer Modelling

Simulation program structure

Page 9: Simulation of Operations The Discrete Event Approach to Computer Modelling

World Views

• Different conceptual models of how to describe a problem for simulation– Event Based– Activity Based– Process Interaction

• Each has a corresponding Executive

Page 10: Simulation of Operations The Discrete Event Approach to Computer Modelling

Event Based View

• Each system description routine corresponds to either:– An event at the start of an activity, or– An event at the end of an activity

• Events at the end of an activity can be scheduled (are only dependent on the passage of time)

• Start of activity events require testing of state to ‘see’ if they can take place.

Page 11: Simulation of Operations The Discrete Event Approach to Computer Modelling

Event Routines

t

S

Consequential

Scheduled

Scheduled

Page 12: Simulation of Operations The Discrete Event Approach to Computer Modelling

YoYo Moulder Routines

• Start Cycle – CONSEQUENTIAL• Conditions

– The machine is empty– There is moulding compound available– There is space in the output buffer to receive

output when the cycle completes• Assumption: Moulding compound is always

available

Page 13: Simulation of Operations The Discrete Event Approach to Computer Modelling

The next slide is a bit complex….

It illustrates the high level control structure used in See-Why (an event-based simulation tool-kit)

Please bear with me …

Page 14: Simulation of Operations The Discrete Event Approach to Computer Modelling

LEVEL 1

DATASCHEDL(event,duration,entity)

THE EVENT LISTSets, Entities & Variables

ONWARD(event, pointer)CLOCK

LEVEL 2 LEVEL 3

Utility Routines

DEFINE

DEFENT, DEFSET

DSFORM

DSPCHG, CHDESC,

INITIAL

HTEXT, PLTLNE, CLAREA

Event Routines

EPCTTR IHEDOF,

SPCTTR BEHEAD, ADDLAST

EMOULD NORMAL

SMOULD NEGEXP

EASSMB

SASSMB etc. (hundreds)

Executive Program

OWNCY

User Defined Routines

REPEAT

Page 15: Simulation of Operations The Discrete Event Approach to Computer Modelling

Start of Mould Cycle

C ***********************************************************SUBROUTINE SMOULD

C ***********************************************************C Check that the moulder is empty and the output buffer is ‘free’.

IF (ISIZEOF(IMOBUF) .EQ. 0 AND ISIZEOF(IMOULD) .EQ. 0)C If so, move an entity into the machine

JENT=IHEDOF(IWORLD)BEHEAD(IWORLD)CHDESC(JENT)=”SIDES”ADDLAST(JENT,IMOULD)

C and schedule the end eventSCHEDL(JMOULD,2,1.1)

ENDIFEND

C END SMOULD***********************************************

See-Why is a Fortran based Simulation Toolkit

Page 16: Simulation of Operations The Discrete Event Approach to Computer Modelling

End of Mould Cycle

C ************************************************C SCHEDULED EVENT FOR END OF MOULDING

SUBROUTINE EMOULDC ************************************************

JENT=IHEDOF(IMOULD)BEHEAD(IMOULD)ADDLAST(JENT,IMOBUF)END

C END SMOULD***********************************************

Page 17: Simulation of Operations The Discrete Event Approach to Computer Modelling

Executive

• Identify time of next event• Advance clock• Execute scheduled event routines ‘due’• Execute consequential events that follow from

these (these are specified in the main program)

No Scanning (searching), fast, harder to program

Page 18: Simulation of Operations The Discrete Event Approach to Computer Modelling

Main ProgramC Call the timing routine ONWARD and get the number of the next eventTOP

CALL ONWARD(EventNumber)C Jump to the piece of code associated with the event number (in this case 2-> LINE 20)

ON EventNumber GOTO 10, 20, 3010 EASSY

SASSYSMOULDSPCUT

C First execute the scheduled event and then try each consequential event.20 EMOULD

SASSYSMOULDGOTO 999

30 …

GOTO TOP

Page 19: Simulation of Operations The Discrete Event Approach to Computer Modelling

Activity View• Each routine describes an activity (including events at

start and end)• Each entity has a data structure that includes a time-

cell (when the next event for that entity takes place)• Each routine comprises

– Test head– Actions

• Test-Head: check availability of entities required for activity

• Actions: – identify time of end event; – change state of entities to committed (i.e. not available);– Update t-cell for each entity

Page 20: Simulation of Operations The Discrete Event Approach to Computer Modelling

Pseudo CodeSubroutine MoulderIF pAvailable(Moulder) AND pAvailable(Output_Space)THEN

end_ev=1.1Moulder.t_cell=Clock.now+end_evOutput_Space.t_cell=Clock.now+end_evNew sideside.t_cell=Clock.now+end_ev

ENDIF

Page 21: Simulation of Operations The Discrete Event Approach to Computer Modelling

Activity Based 2-phase executive• (1)Scan entity t-cells to find earliest time of next

event• Advance clock• Change entity state(s) to ‘available’• (2) Scan activity routines (test-heads) to see which

(if any) can be executed• Execute routine, repeat scan

Repeated scanning, slow, easier to program; activity routine ordering will affect behaviour.

3-phase approach is a development of this

Page 22: Simulation of Operations The Discrete Event Approach to Computer Modelling

Process Interaction• each process routine describes

the logic for the life cycle of a class

• Typically used to describe temporary entities

• Permanent entities are simple integers describing the number of entities of that type that are available

• (historically) this meant that they were poor at describing the logic of equipment and handling devices (now not an issue)

Page 23: Simulation of Operations The Discrete Event Approach to Computer Modelling

SIMAN Code

BEGIN;CREATE,1: EXPONENTIAL(9);QUEUE: BUFFER,10;SEIZE,Pr: Drill;DELAY: TRIANGULAR(3.2,4.2,5.2);RELEASE: Drill;COUNT: JobsDone: DISPOSE;

END;

Page 24: Simulation of Operations The Discrete Event Approach to Computer Modelling

Event Based Approach I

• Model is described as a set of events.• Scheduled events

– are only dependent on time• Consequential events

– are dependent on state, and usually need to be tested.

• examples:– SEE-WHY, SIMSCRIPT II.5

Page 25: Simulation of Operations The Discrete Event Approach to Computer Modelling

Event-Based Approach II

• efficient– the ‘fastest’ of all approaches (at run-time).

• little or no structure imposed on user.• maximum flexibility.• model development takes longest time.

Page 26: Simulation of Operations The Discrete Event Approach to Computer Modelling

Activity-Based Approach (2 phase)

• Model is described as a set of activities.• Each activity describes the conditions under which

it can be activated and the change of state that ocurrs when this happens.

TEST HEAD

ACTIONS

if x and y then:

change stateupdate t-cells

NOW SUPPLANTED BY 3 PHASE APPROACH

1. Time scan.2. Activity scan.

Page 27: Simulation of Operations The Discrete Event Approach to Computer Modelling

Activity-Based Approach

• slower than event-based approach• need for scanning of each activity’s test-

head.• Ordering of activities in the program is

important.• exhibits a degree of modularity.

Page 28: Simulation of Operations The Discrete Event Approach to Computer Modelling

Activity-Based Approach (3 phase)

• Identifies ‘bound’ and ‘conditional’ activities.• bound activities can be scheduled.• only conditional activities need to be scanned.• allows the behaviour of both permanent and

temporary entities to be represented*

* in other approaches either one or the other is the focus for modelling.

Page 29: Simulation of Operations The Discrete Event Approach to Computer Modelling

Activity-Based Approach (3 phase)

• Examples: ECSL, HOCUS• HOCUS

– Hand or Computer Universal Simulator– Based on a formal ACD-based description.

Page 30: Simulation of Operations The Discrete Event Approach to Computer Modelling

Process-Based Approach(aka ‘Process Interaction’)

• Temporary entities are the typical focus of modelling.

• describes a sequence of activities that an entity passes through durings its life.

• processes interact with one another by competing for resources – aquiring them and releasing them later.

Page 31: Simulation of Operations The Discrete Event Approach to Computer Modelling

Process-Based Approach• modularity based on parts - unlike activity-based

approaches that are based (mostly) on machines.• Unlike other approaches, time passes during the

execution of a process.• two lists used:

– pending ( future known events) scheduled.– current (due now & conditional) scanned.

• simple interaction mechanism is okay for simple interactions! But...

Examples: GPSS, SIMAN/Arena, ModSim,

Page 32: Simulation of Operations The Discrete Event Approach to Computer Modelling

Activity vs. Process• In their pure form:

– Activity-based approaches offer a convenient and modular solution to modelling systems that are defined by their physical layout. Changes to layout are straightforward.

– Process-based approaches suit systems where there is high part and route variety. The modularity is focussed on the parts ( & therefore routing) so adding and deleting these is relatively easy.

• BUT, these days most packages are hybrids, offering capabilities for both physical layout based problems and complex routing scenarios.