Simulation and Modeling

advertisement
Computer Laboratory Manual
Simulation and Modeling
(CS-407)
Computer Science Department
Sir Syed University of Eng. & Technology
University Road, Karachi 75300
Contents
Lab1. Basic Concepts of Simulation and Modeling and SIGMA
(An Introduction).
Lab2. Exploring the Car Wash Model. (Single queue single server)
Lab3. The Car Wash Model (Single Queue two Servers)
Lab4. Implementation of Buffered Queue Model
Lab5. To Design Airport Model. (One queue multiple servers)
Lab6. To Design a superstore model (Two queue and two servers)
Lab7. To Design a Billing System (Two queues one Server)
Lab #1
Basic concepts of Simulation and Modeling
Simulation:
A simulation is an imitation of the operation of real-world process or system over time.
Purpose of Simulation:


The behavior of a system is studied by developing a simulation model.
New polices, operating procedures, decision rules, information flows and
organizational procedures can be explored without disrupting the operation of the real
system.
Application Areas of Simulation:




Manufacturing Systems
Construction System
Transportation System
Computer System Performance e.t.c.
System:
A collection of entities (people and machines), that interacts together over time to
accomplish one or more goals.
System Environment:
A system is affected by the changes occurring outside the system. Such changes are said
to occur in the system Environment.
Discrete System:
A discrete system is one in which the state variables change only at a discrete set of points
in time.
Continuous System:
A continuous system is one in which the state-variable(s) change continuously over time.
System Model:
An abstract representation of a system, usually containing structural, logical or
mathematical relationships that describe a system in terms of state, events, entities and their
attributes, events, activities and delays.
System State:
A collection of variables that contain all the information necessary to describe the system
at any time
Entity:
Any object or component in the system that requires explicit representation in the model.
for e.g. (a server, a customer, a machine)
Attributes:
The properties of a given entity for e.g. (the priority of a waiting customer.)
Events:
The changes in the state are called events.
OR
An instantaneous occurrence that changes the state of a system
Endogenous Events:
It describes activities and events occurring with in a system. For e.g. (Completion of service
of a customer).
Activity:
A duration of time of specified length (a service time) that is known when it begins.
Delay:
A duration of time of unspecified indefinite length, which is not known until it ends.
Introduction to SIGMA
Introduction: I
Sigma Stands for Simulation Graphical Modeling and Analysis .It is a very powerful
simulation environment. Sigma is based on the concepts of event graph. Event graph
graphically shows the major event taking place in a system and their relationships.
Simulation models can be created or edited while they are running. SIGMA
simulation model develops and verifies the system in a very short interval of time.
SIGMA also provides facility to translate the models into C, English and FORTRAN
e.t.c.
Objective:




Orientation on Sigma for Windows
Exploring Sigma for Windows
Translating Models in Sigma for Windows into English, Pascal, C, and various
prototype simulation languages.
Event Graphs and plot types
GRAPHICAL SIMULATION AND MODELING
Using SIGMA for Windows
Overview








SIGMA for Windows is an approach to discrete event simulation modeling:
Simulation models can be added, altered or even deleted during a simulation run.
We can pause and replay interesting events
Includes state of art graphical tracking tools and allows pictures, graphs, plots, and
data to be pasted into spreadsheets and word-processors
Sigma models can automatically be translated into a variety of languages
including C, Pascal, FORTRAN (SIMAN and SLAM prototypes) and English
even.
Multiple SIGMA sessions can be run concurrently.
You can copy and paste objects from one modeling session to another.
Supports full simulation model life cycle: from model building and testing to
output analysis, animation, documentation, and report writing.
Discrete Event Simulations:


Systems in which changes occur at particular instants of time are called discrete
event systems. Time is advanced in discrete steps to the next interesting state
change.
There are three elements of Discrete Event System Model. They are:
 State-Variables.
 Events.
 Relationships.
State-Variables:
State-Variables of a system describe completely the state of a system at any time.
For e.g.:
QUEUE: NUMBER OF CARS IN LINE (integer valued)
SERVER: MACHINE IS IDLE/BUSY = 1/0 (integer valued)
The occurrences of activity w.r.t. time changes state-variable’s value.
Events:
The changes in the state are called events.
OR
An instantaneous occurrence that changes the state of a system.
For e.g.:
ENTER, START and LEAVE.
Events are represented by event vertices (nodes or balls) in a SIGMA graph. Event
vertex parameters, if any, are given in parentheses.
ENTER
{QUEUE=QUEUE+1}
File types





Model Files
Output Files
Source Code in C
Source Code in Pascal
Translation in English
.MOD
.OUT
.C
.PAS
.ENG
Graphs
Simple Event Graph Edge:
 Whenever event A occurs, it might cause event B to occur
A
B
Conditional Event Graph Edge with a Time Delay:
 If condition (i) is true at the instant event A occurs, then event B will
be scheduled to occur t minutes later
t
A
(i)
edge
condition
B
vertex
If the condition is not true, nothing will happen, and the edge can be ignored until the
next time event A occurs. You can think of an edge as nonexistent unless its edge
condition is true. If the condition for an edge is always true (denoted as 1==1), the
condition is left off the graph. We will call edges with conditions that are always true
unconditional edges. Zero time delays for edges are not shown on the graph.
CAR WASH Model with Edge
Condition and Delay Times
Q>0
ta
S>0
RUN
(Q)
{S=1}







ENTER
{Q = Q+1 }
START
{S=0, Q=Q-1 }
ts
LEAVE
{S=1}
(Q) is the vertex parameter, its initial value is provided by the system environment
{S=1} system is idol
{S=0} system is buzy
S>0 means is server idol?
Q>0 means are customers waiting?
ta is Delay
ts is Activity
At the start of the simulation RUN, the first car will ENTER the system.
Successive cars ENTER the system every ta minutes. If ENTERing cars find
that the server is available (S>0), they can START service. Once cars START
service, ts minutes later they can LEAVE. Whenever a car LEAVEs, if the
queue is not empty (Q>0), the server will START with the next car.
To run this model, only the starting and ending conditions for the run need to be
specified.
Verbal Event Graphs


Before designing your own event graph model, it is a good idea to develop a
verbal description of your system.
This description will include state changes associated with each vertex along with
a verbal description of each edge condition and delay time on the graph.
Verbal Event Graph of a Single
Server Queue
(Are Customers Waiting?)
{Customer ENTERS
a system}
{Initialize the
RUN}
ta
{Is Server Idle}
RUN
ENTER
START
ts
LEAVE
{Customer STARTS service}
ta=Time b/w Customer Arrivals (Possibly Random)
ts = Time to service a single customer (Possibly Random)
Download