atilim university ie 504 system simulation

24
ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION A GENTLE INTRODUCTION TO SIMULATION MODELING Gizem ALAGOZ 1

Upload: chana

Post on 24-Feb-2016

41 views

Category:

Documents


0 download

DESCRIPTION

ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION . A GENTLE INTRODUCTION TO SIMULATION MODELING Gizem ALAGOZ. BACKGROUND & TERMINOLOGY. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

1

ATILIM UNIVERSITYIE 504 SYSTEM SIMULATION

A GENTLE INTRODUCTION TO SIMULATION MODELING

Gizem ALAGOZ

Page 2: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

2

BACKGROUND & TERMINOLOGY

We use models in an attempt to gain understanding and insights about some aspect of the real world. Attempts to model reality assume a priori the existence of some type of “ground truth,” which impartial and omniscient observers would agree upon.

Page 3: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

3

BACKGROUND & TERMINOLOGY (Cont’d)

We define a system to be a set of elements which interact or interrelate in some fashion.

The elements that make up the system are often referred to as entities.

A model is a system which we use as a surrogate for another system.

A computer simulation is a model which happens to be a computer program.

Page 4: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

4

AN OVERVIEW OF THE MODELING PROCESS

In stage 1 of the modeling process we should try to identify what is meant by the system of interest.

In stage 2, we try to rigorously describe the behaviors and interactions of all of the entities which comprise the system.

Page 5: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

5

AN OVERVIEW OF THE MODELING PROCESS (Cont’d)

Page 6: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

6

AN OVERVIEW OF THE MODELING PROCESS (Cont’d)

Feedback enters the modeling process in the form of verification and validation.

Verification constitutes a feedback loop between the computer model and the formal model. “does my computer program do what I meant it to do?”

Validation constitutes a feedback loop between the computer model and reality. “does my computer program mimic reality adequately?”

Page 7: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

7

AN OVERVIEW OF THE MODELING PROCESS (Cont’d)

Using this approach you are more likely to achieve a functioning model.

Start small Improve incrementally Test frequently Do not be afraid to backtrack or

simplify

Page 8: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

8

DISCRETE EVENT SYSTEMS There are many classifications of systems

available. The Winter Simulation Conference tends to focus on Discrete Event Systems. These are systems where the state changes occur at a discrete set of points along the time axis, rather than continuously. Discrete Event Simulation (DES) models can be built with any of several world views.

Schruben (1983) created event graph notation so that simulation modelers could focus on the model-specific logic of the system to be studied.

Page 9: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

9

DISCRETE EVENT SYSTEMS (Con’t’d)

Another type of error that modelers can make is a concept, called a Type III error by Mitroff and Featheringham (1974).

Simulation languages are an example of what computer scientists call Domain Specific Languages (DSLs). The alternative to DSLs is General-Purpose Programming Languages (GPPLs).

Page 10: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

10

REVIEW OF EVENT GRAPHS Event graphs are a pictorial representation of

event-based discrete event models. Each event in the system is represented by a

vertex in the graph. State transitions can be specified below the vertex or separately, labeled by the vertex’s label. Scheduling relationships between events are depicted using directed edges with attributes annotated on the edges to indicate the delay (if any) between the events and the conditions under which the scheduling should occur.

Page 11: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

11

REVIEW OF EVENT GRAPHS (Cont’d)

A and B are events, t is a delay (which coul be constant, random, or some function of the state), and c is a boolean function of the state.

Page 12: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

12

REVIEW OF EVENT GRAPHS (Cont’d)

Page 13: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

13

DESIGN CONSIDERATIONS To implement the model as a computer program,

we need three things: A method for each event in the event graph model

that updates the model state as specified, schedules further events as appropriate, and then terminates.

An executive loop that determines the order in which event methods should be invoked.

A schedule capability that provides the mechanism by which event methods notify the executive loop about events that are candidates for invocation.

Page 14: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

14

DESIGN CONSIDERATIONS (Cont’d)

The simulation program needs to store notices of pending events in a container of some sort. (Let P be the pending events set)

If P is implemented as a priority queue, clock is the simulation clock, and current is an event notice reference with associated method and time attributes, the following block of pseudo-code describes the structural form of the executive loop.

Page 15: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

15

IMPLEMENTATIONThe Model Interface Every SIMpleKit model must implement

the Model interface. In Java an interface mandates class elements that must be present, but does not provide any implementation for those elements. In other words, a SIMpleKit Model must have a method initialize() which takes no arguments and returns nothing.

Page 16: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

16

IMPLEMENTATION (Cont’d)The EventNotice Class The EventNotice class is a helper class

for storing and retrieving event notices. It should never be used directly by users, so all methods and constructors are declared protected, meaning they are not available outside of the SIMpleKit package hierarchy.

Event notices are immutable.

Page 17: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

17

IMPLEMENTATION (Cont’d)The Simulation Class Class Simulation provides the core

functionality of SIMpleKit. It maintains a priority queue of EventNotice’s called eventList, a reference of type Model to your model object called model, and the current simulated time in a variable called modelTime.

Page 18: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

18

THE M/M/k QUEUE IN SIMpleKit

We demonstrate usage of SIMpleKit by implementing an M/M/k queueing system.

SIMpleKit does not provide a library of distributions—techniques for random variate generation are widely available in the simulation literature.

Page 19: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

19

THE M/M/k QUEUE IN SIMpleKit (Cont’d)

Execution of the model is handled via a method called run(),

EventNotice variable to keep track of the current event,

initialize() method whose existence is guaranteed by the Model interface proceeds with an execution loop which determines the next event to be performed by polling the event list, sets the simulation clock to the time of that event, and invokes the event method.

Page 20: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

20

THE M/M/k QUEUE IN SIMpleKit (Cont’d)

Event Methods Each event has a corresponding event

method in the model class. The event graph provides a roadmap of how to write the event methods. First, perform all state transitions. Then schedule events corresponding to each departing edge if the edge conditions are true, with suitable delays.

Page 21: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

21

THE M/M/k QUEUE IN SIMpleKit (Cont’d)

The halt event invokes Simulation.halt(), which empties the event list to guarantee termination of the model as described earlier.

Page 22: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

22

THE M/M/k QUEUE IN SIMpleKit (Cont’d) The other event

methods are sufficiently straightforward that we present the implementations without further comment other than to note that ++ and -- are Java operators for increment and decrement, respectively.

Page 23: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

23

THE M/M/k QUEUE IN SIMpleKit (Cont’d)

Running the Model The model has to be started somehow.

This is accomplished by creating a Java “main” method which creates an instance of the model and passes it to the Simulation class to be run.

Page 24: ATILIM UNIVERSITY IE 504 SYSTEM SIMULATION

24

FINAL COMMENTS ABOUT SIMPLEKIT

SIMpleKit provides a simple and transparent mechanism to illustrate how discrete event models can be implemented. Event Graphs map very directly into SIMpleKit programs, and run very efficiently.

SIMpleKit has been used to implement some quite sophisticated models, including an analysis of joint problem solving in edge vs. hierarchical organizations and an implementation of Dijkstra’s algorithm for determining shortest paths in a graph.