Computer System Modeling and Simulation
Computer System Modeling and Simulation
Sosina M.
AAiT
Computer system modeling and simulation 1
Introduction
Dynamic systems modeling
Continuous simulation
Continuous system – state variables change continuously over time
Continuous simulation
Simulation of continuous system
continuously tracks system responses over time according to a set of equations
𝜕𝑥
= 𝑢(𝑡)
𝜕𝑡
The most simple algorithm that can be applied on a digital computer is to discretize the
time variable
𝑥 𝑡 + ∆𝑡 = 𝑥 𝑡 + ∆𝑡 𝑢(𝑡)
Discrete-event simulation
The state variables changes discretely at points in time referred to as events
The term continuous and discrete refers to changes in the state of the system, not of
time management.
Appropriate for systems where change in system state occur only at discrete
points in time
The number waiting at a stop can change only when the bus arrives there or
when a new individual comes to the stop
System state: A collection of variables (entities and attributes) that contain all
the information necessary to describe the system at any time
Event list: A list of event notices for future events, ordered by time of
occurrence; known as the future event list (FEL)
Important questions
Event
How does each event affect system state, entity attributes, and set contents?
Activity
How are activities defined (i.e., deterministic, probabilistic, or some other
mathematical equation)?
What event marks the beginning or end of each activity?
Can the activity begin regardless of system state, or is its beginning conditioned on
the system being in a certain state? (For example, a machining “activity" cannot
begin unless the machine is idle, not broken, and not in maintenance.)
Computer system modeling and simulation 8
DES: model description
Delay
Which events trigger the beginning (and end) of each delay?
Under what condition does a delay begin or end?
System state
What is the system state at time 0? What events should be generated at time 0 to get
the simulation started?
Process interaction
Entities/objects and their life cycle as they flow through the system, demanding
resources and queueing to wait for resource
Activity scanning
Use a fixed time increment and a rule based approach to decide whether any
activities can begin at each point in simulation time
Describe the activities associated with each of the events and how the state may
be altered by the events, whether conditioned on the current state or not
At any given time t, the FEL contains all previously scheduled future events + their
associated time
The sequence of actions that a simulator must perform to advance the clock and build
a new system snapshot is called the event-scheduling/time-advance algorithm
Computer system modeling and simulation 16
Event scheduling algorithm
The system snapshot at time 0 is defined by the initial conditions and the
generation of exogenous events
The specified initial conditions define the system state at time t0
Algorithm
1. Remove the event notice for the imminent event from FEL
(event (3, t1) in the example)
2. Advance clock to imminent event time (set clock=t1)
3. Execute imminent event: update system state, change entity
attributes and set membership as needed
4. Generate future events (if necessary) and place their event
notice on FEL, ranked by event time
5. Update cumulative statistics and counters
Service times 2 5 5 8 4 5
Prepare a snapshot table for the given data. Stop simulation when the clock
reaches 20.
Some activities might require the use of one or more resources whose
capacities are limited
This and other constraints cause the processes to interact
Then, the simulation time is advance to the time of the next imminent event on
the FEL
Processes
One process for the operations done by each client
One process for the operation done by the server
Server
If the queue is empty
Wait until a client arrives
Otherwise
Select a client to be served
Extract the client record from the queue
Determine the service time Ts
Holds for Ts , until the end of the service (t+Ts)
− If ServerState==idle
− Activate the server process
− Hold for TnextArr time
Initial conditions
Queue length, server state (idle, busy), arrival time (t_arrival), departure time
(t_depart)
If t>=t_arrival If t>=t_depart
t_arrival= t + Ti If queue length =0
If the server is idle Server state=idle
Server state=busy Otherwise
Determine the service time Reduce queue length by 1
Ts Determine the service time Ts
t_depart=t+ Ts t_depart=t+ Ts
If the server is busy
Increase queue length by 1 If t>=t_end
End simulation
Computer system modeling and simulation 29
Activity scanning
→ Initialize
%Check departure events
→ Schedule the first arrival [TnextArr=CurrentTime + generated InterArrTime] → While TnextDepart <= CurrentTime
− if Number of customers in the queue≠ 0
→ While the CurrentTime <= SimTime − Server state=busy
− Schedule departure event [TnextDepart =
%Check arrival events
DepartTimeOfTheLastCustomer + generated
InterDepartTime]
→ While TnextArr <= CurrentTime
− Number of customers in the queue--
→ Inset the event in the queue
− Else
→ Number of customers in the queue++
− Server state=idle
→ Schedule the next arrival a
− Break
− If the server state== idle
%update the time
− Server state=busy
− Schedule departure time [TnextDepart = ArrivalTimeOfThisArrival→ CurrentTime=CurrentTime+Δt
+ generated InterDepartTime]
− Delete the event from the queue
− Number of customers in the queue--
Classification of activities
B activities – activities bound to occur (all primary events and unconditional activities)
Can be scheduled ahead of time
FEL contains only B type events
E.g., service completion is an example of a primary event
C activities – activities or events that are conditional upon certain condition being true
Scanning to learn whether any C type activities can begin
E.g., beginning service is a conditional event – its occurrence is triggered only on the
condition that a customer is present and a server is free
Phase A
Remove the imminent event from the FEL and advance the clock to its event time.
Remove from the FEL any other events that have the same event time
Phase B
Execute all B-type events that were removed from the FEL (this could free a number of
resources or otherwise change system state.)
Phase C
Scan the conditions that trigger each C-type activity and activate any whose conditions
are met.
Rescan until no additional C-type activities can begin and no event occur
Procedures
Initialization
simulation time
%Type B events
− If the event==arrival event
− Destroy the record (from FES)
− Number of customers in the queue++
− Schedule the next arrival [TnextArr=CurrentTime + generated InterArrTime]
− Insert the scheduled arrival in the FES and Sort FES
− Else If the event==departure event
− Destroy the record (from FES)
− Server state=idle