0% found this document useful (0 votes)
44 views

Chap 3

Uploaded by

hafsatamer03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Chap 3

Uploaded by

hafsatamer03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 94

System Simulation and

VR

Chap3. General principles


Overview
Concepts in Discrete-Event
Simulation
The Event-Scheduling algorithm
Examples
List processing
Other Algorithm
Summary
Concepts in simulation
System
Acollection of entities (e.g.,
people and machines) that
interact together over time to
accomplish one or more goals.
Model
An abstract representation of a
system, usually containing
structural,logical, or
mathematical relationships
which describe a system in
terms of state, entities and their
attributes, sets, processes,
events, activities, and delays.
Concepts (cont’d)
Entity
 Any object or component in
the system which requires
explicit representation in the
model (e.g., a server, a
customer, a machine).
Concepts (cont’d)
Attributes
 The properties of a given entity
(e.g., the priority of a waiting
customer, the routing of a job
through a job shop).
Concepts (cont’d)
System state
A collection of variables that
contain all the information
necessary to describe the
system at any time.
Concepts (cont’d)
List
 A collection of (permanently or
temporarily) associated entities,
ordered in some logical fashion
(such as all customers currently
in a waiting line, ordered by first
come, first served, or by priority).
Concepts (cont’d)
Event
 An instantaneous occurrence
that changes the state of a
system (such as an arrival of a
new customer).
 Conditional or unconditional
Concepts (cont’d)
Event notice
A record of an event to occur at
the current or some future time,
along with any associated data
necessary to execute the event;
at a minimum, the record
includes the event type and the
event time.
Concepts (cont’d)
Delay
A duration of time of unspecified
indefinite length, which is not
known until it ends (e.g., a
customer's delay in a last-in,
first-out waiting line which, when
it begins, depends on future
arrivals).
Concepts (cont’d)
Clock
A variable representing
simulated time, called CLOCK in
the examples to follow.
Concepts (cont’d)
Event list
A list of event notices for future
events, ordered by time of
occurrence; also known as the
future event list (FEL).
Concepts (cont’d)
Activity
A duration of time of specified
length , which is known when it
begins
 e.g. a service time or interarrival time

 maybe defined in terms of a


statistical distribution
a unconditional wait.
Concepts (cont’d)
1. Deterministic.
Eg. always exactly 5 minutes;
2. Statistical.
Eg. as a random draw from among 2, 5, 7
with equal probabilities;
3. A function depending on system
variables and/or entity attributes
Eg. loading time for an iron ore ship as a
function of the ship's allowed cargo weight
and the loading rate in tons per hour.
Concepts (cont’d)
Delay
A duration of time of unspecified
indefinite length, which is not
known until it ends
 e.g., a customer's delay in a last-in,
first-out waiting line which, when it
begins, depends on future arrivals.
 a conditional wait
Customer n

Arrival Begin End


event service service
Delay Activity

Time Time

Arrival Begin End


event service service
Delay Activity

Time Time
Customer n+1
进程:由若干个有序事件及有序活动组成,描述了他所包括的事
件和活动间的相互逻辑关系及时序 关系
例如:顾客到达系统、排队、接受服务、服务完毕离开 --- 一个进

进程

排队活动 服务活动

到达事件 服务开始事件 服务结束事件


Example
Able and Baker
System state
 LQ(t), the number of cars waiting
to be served at time t
 LA(t), 0,or 1 to indicate Able being

idle or busy at time t


 LB(t), 0 or 1 to indicate Baker

being idle or busy at time t


Able and Baker(cont’d)
Entities
 Neither the customers(i.e., cars)
nor the servers need to be
explicitly represented, except in
terms of the state variables,
unless certain customer
averages are desired
Able and Baker(cont’d)
Events
 Arrivalevent
 Service completion by Able

 Service completion by Baker


Able and Baker(cont’d)
Activities
 Interarrival
time
 Service time by Able
 Service time by Baker

Delay
Acustomer’s wait in queue until
Able or Baker becomes free
Questions
How does each event affect system
state,entity attributes, and set
contents?
How are activities defined?
Which events trigger the beginning
(and end) of each type of delay?
What’s system state at time 0?
How to get the simulation started?
Prototype system snapshot
Overview
Concepts in Discrete-Event
Simulation
The Event-Scheduling algorithm
Examples
List processing
Other Algorithm
Summary
Customer n

Arrival Begin End


event service service
Delay Activity

Time Time

Arrival Begin End


event service service
Delay Activity

Time Time
Customer n+1
The event-scheduling
algorithm
Simulation clock
 Simulated time
FEL
 (event type, occur at time)
 t < t1 < t2 < t3 <…< tn
Algorithm
1. Remove the event notice for
the imminent event from FEL
2. Advance CLOCK to imminent
event time
3. Execute imminent event:
update system state, change
entity attributes, and set
membership as needed
Algorithm(cont’d)
4. Generate future events(if
necessary) and place their
event notice on FEL ranked by
event time
5. Update cumulative statistics
and counters
Algorithm(cont’d)
Simulation start
 Set CLOCK to 0
 Initialize all system state variables
and others for data collection
 Initialize FEL

Simulation end
 Set simulation end event
 Set simulation CLOCK for end
Overview
Concepts in Discrete-Event
Simulation
The Event-Scheduling algorithm
Examples
List processing
Other Algorithm
Summary
Manual simulation using
event scheduling
Example 1
 Reconsiderthe grocery store
with one checkout counter.
Example 1 (cont’d)
Model
 System state
LQ(t): the number of customers

in the waiting line at time t


LS(t): the number being

served(0 or 1) at time t
Example 1 (cont’d)
 Entities

The server and customers are


not explicitly modeled, except
in terms of the state variables
above
Example 1 (cont’d)
 Events

Arrival:A
Departure: D

Stopping event: E, scheduled

to occur at time 60
Why service begin not as a
event
Conditional event: the first at
queue + server is idle
Not a primary event
Only primary event at FEL
Example 1 (cont’d)
 Event notices
(A,t): an arrival event to occur

at future time t
(D,t): a customer departure at

future time t
(E,60): the simulation
Example 1 (cont’d)
 Activities

Interarrivaltime
Service time

 Delay

Customer time spent in waiting

line
Example 1 (cont’d)
 Cumulativestatistics
B: server busy time
MQ: Maximum queue length
How to generate a new event
The first arrival event come , a
second arrival event is generated.
1. an interarrival time is generated ----
a*
2. Current time----t , the resulting
(future) event time----t*=t+a*
3. t* is used to position the new arrival
event
a service-completion event
When one customer completes service, at
current time CLOCK t , if the next
customer is present, then a new service
time, s*, will be generated for the next
customer.
The next service-completion event will be
scheduled to occur at future time t*=t+s*
placing onto the FEL a new event notice of
type service completion with event time t*
System state Cumulative
statistics
Clock FEL B MQ
LQ(t) LS(t)

0 0 1 (D,4)(A,8) 0 0
(E,60)
4 0 0 (A,8)(E,60) 4 0
8 0 1 (D,9)(A,14) 4 0
(E,60)
9 0 0 (A,14)(E,60) 5 0
14 0 1 (A,15)(D,18) 5 0
(E,60)
15 1 1 (D,18)(A,23) 6 1
Metrics
Server utilitilization
 = busy time/total simulated time
Maximum queue length
Example 2
The checkout-counter
simulation, continued
To estimate mean response
time and mean proportion of
customers who spends 4 or
more minutes in the system
Example 2 (cont’d)
Entities
 (Ci,t):
representing customer Ci
who arrived at time t.
Example 2 (cont’d)
Event notices
 (A,t, Ci), the arrival of customer
Ci at future time t.
 (D,
t, Cj), the depature of
customer Cj at future time t.
Example 2 (cont’d)
New cumulative statistics
 S: the sum of customer response
times for all customers who have
departed by the current time
 F: the total number of customers
who spend 4 or more minutes at
checkout counter.
Example 2 (cont’d)
ND: the total number of
departures up to the current
simulation time
Cl System Cumulative
oc state statistics
FEL S ND F
k LQ(t LS(t
) )

0 0 1 (C1,0) (D,4,C1)(A,8,C2) 0 0 0
(E,60)
4 0 0 (A,8,C2)(E,60) 4 1 1
8 0 1 (C2,8) (D,9,C2) 4 1 1
(A,14,C3)(E,60)
9 0 0 (A,14,C3)(E,60) 5 2 1
14 0 1 (C3,14 (A,15,C4) 5 2 1
) (D,18,C3)(E,60)
15 1 1 (C3,14 (D,18,C3) 5 2 1
Example 2 (cont’d)
Metrics
 The average response time =
S/ND
 Theproportion of customers who
spend 4 or more minutes in the
system = F/ND
Overview
Concepts in Discrete-Event
Simulation
The Event-Scheduling algorithm
Examples
Other Algorithm
List processing
Summary
Process-interaction approach
Concentrate on processes
The life cycle of one entity
a process is a time-sequenced list of
events, activities, and delays,
including demands for resources,
Resources’ capacites are limited
waiting process interact
Why popular
intuitive appeal
allow an analyst to describe the
process in terms of high-level
block or network constructs ,while
interaction among processes is
handled automatically.
Process-interaction approach
Arrival Begin End
event service service
Delay Activity
Time Time
Customer n+1
Customer n

Arrival Begin End


event service service
Delay Activity

Time Time
Process-interaction approach
events are being scheduled on a future
event list
entities are being placed onto lists
whenever they face delays
causing one process to temporarily
suspend its execution while other
processes proceed.
hidden from a modeler's view
Need to have a basic understanding
The activity-scanning approach
the event-scheduling and the
process-interaction approaches use a
variable time advance
The activity-scanning approach uses
a fixed time increment
a rule-based approach to decide
whether any activities can begin at
each point in simulated time
The activity-scanning approach
modeler concentrates on the
activities of a model and those
conditions that allow an activity to
begin.
At each clock advance, the
conditions for each activity are
checked and, if the conditions are
true, then the corresponding
activity begins.
The activity-scanning approach
simple in concept and leads to
modular models
the repeated scanning result in
slow runtime on computers
the three-phase approach
Here ---- the three-phase approach
pure activity-scanning+ some
features of event scheduling
avoidance of unnecessary
scanning
keeping the main advantages of
the activity-scanning approach
the three-phase approach
two kinds of activities : B and C.
1. B: activities bound to occur;
Eg: primary events units(activities of
duration-zero time ),
unconditional activities.
2. C : activities that are conditional
upon certain conditions being true.
the three-phase approach
FEL
B can be scheduled ahead of time
(event-scheduling approach).
allows variable time advance.
The FEL contains only B-type
events.
the three-phase approach
Scanning
Scanning to check if any C-type
activities can begin or C-type
events occur happens only at the
end of each time advance,
after all B events have completed.
the three-phase approach
Phase A Remove all the imminent events
from the FEL and advance the clock to its
event time.
Phase B Execute all B-type events that
were removed from the FEL.  free
resources, change system state
Phase C Scan the conditions that trigger
each C-type activity and activate any
whose conditions are met
Example
Six dump trucks: Each truck is loaded
by one of two loaders.
Loading-- scale--travel.
Both the loaders and the scale have a
first-come first-served waiting line (or
queue) for trucks.
The purpose : estimate the loader
and scale utilizations
two cumulative statistics
Activity time
the utilizations
Use activity scanning
Process interaction
Overview
Concepts in Discrete-Event
Simulation
The Event-Scheduling algorithm
Examples
Other Algorithm
List processing
Summary
List processing
Implementation methods
 Static
List -> array
 Dynamic List -> pointer

Here, dynamic
For details, refer to books such
as “Data Structure”
List processing(cont’d)
Operations
 Inserta record to the list
Where? The top, end or

middle?
 Remove a record from the list

Where? The top, end or

middle?
List processing(cont’d)
Records
 Event notices
Ranking rules
 By time ( the latest, the first )
 By priority

List header
List processing(cont’d)
Insert operation ( by time )
 Find the appropriate place
 Insert

Top

Middle

end
Header
5 8
q Insert to
3 the top
Header
3 5 8
Header
3 8
q
Insert to
5 the middle

Header
3 5 8
Header
3 5
q Insert to
8 the tail

Header
3 5 8
List processing(cont’d)
Remove operation ( by time )
 Find the appropriate place
 Remove

Top

Middle

end
Header
3 5 8
q Remove
3 from the top

Header
5 8
Overview
Concepts in Discrete-Event
Simulation
The Event-Scheduling algorithm
Examples
List processing
Other Algorithm
Summary
Summary
Major concepts and building
blocks in simulation
 Entities

 Attributes

 Events

 Activities
Summary(cont’d)
Event-scheduling/time-advance
algorithm
List processing
homework
Bank’s book
Excise 7
Two weeks

You might also like