8 Simulation Of Computer Systems

Simulation and Modeling · Unit 8 · 9 hrs

Simulation of Computer Systems

Exam-focused notes for Simulation of Computer Systems (Simulation and Modeling, CSC328): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.

Simulation of Computer Systems in short

Every technique developed so far, random number and variate generation, queuing formulas, verification and validation, output analysis, comes together in practice inside dedicated simulation software. This closing chapter surveys that software and works through complete simulation models built with it.

Simulation of Computer Systems: notes

Simulation Tools

A simulation tool is software used to simulate hardware, software, or network behaviour by modeling a real-world phenomenon with mathematical formulas, letting an analyst observe how a system would operate without actually running that operation. Common categories of simulation tool in computing include processor simulation, memory simulation, ALU simulation, logic-network simulation, and CPU or network simulation. Beyond general-purpose simulation languages, engineering practice also relies on numerical computing packages such as MATLAB and its companion Simulink, which model and simulate dynamic systems (including the continuous, differential-equation-based systems of unit 2) using block diagrams rather than the discrete-event transaction flow used by GPSS. An early dedicated tool for continuous-system simulation was the Continuous System Modeling Program (CSMP), built specifically to model and numerically solve differential equations so that real-world continuous systems could be simulated and tested entirely on a digital computer. CSMP programs are built from three kinds of statement: structural statements, which define the model using FORTRAN-like arithmetic (so that $X = 6Y + (Z-2)^2$ becomes X = 6.0*Y + (Z-2)**2.0); data statements, which assign numerical values to parameters, constants, and initial conditions (such as setting the initial value of an integrator block); and control statements, which specify options for how the program is assembled and run, including which variables to print as output.

Simulation Languages: GPSS

The General Purpose Simulation System (GPSS) is a discrete-event, general-purpose simulation language in which the simulation clock advances in discrete steps and a system is modeled as transactions (customers, messages, machines) entering the system and passing from one service point to another. GPSS is less flexible than languages such as Simula or SIMSCRIPT, but it is markedly easier to learn and remains one of the most widely used discrete-event languages, since it was designed for analysts who are not necessarily programmers by training. Rather than writing a program in the conventional sense, a GPSS user builds a block diagram: a network of interconnected blocks, each one performing a specific simulation function, through which transactions flow. GPSS provides around 48 distinct block types, each reusable as many times as the model needs; a transaction, once created, is always contained in exactly one block at a time, although a single block may hold several transactions simultaneously. (Arena, a modern commercial descendant of this same block-diagram philosophy, extends the same transaction-flow idea with a graphical modeling interface and built-in statistical analysis of simulation output.)

What this unit covers

  • Simulation Tools
  • Simulation Languages: GPSS
  • Case Studies of different types of Simulation Models and Construction of sample mathematical models

Simulation Languages

2082 · 10 marks

Describe the MARK and TABULATE block in GPSS. A coffee shop has a single barista serving customers. Customers arrive at an average rate of one every 3 minutes and the barista takes an average of 2.5 minutes to serve a customer. Create a simulation model and block diagram representing the coffee shop using GPSS blocks and simulate the system for 8 hours.[10]

Show solved answer

MARK and TABULATE Block in GPSS & Coffee Shop Simulation


Part A: MARK Block

The MARK block is used to record the current simulation clock time into a specified parameter of a transaction. This timestamp is later used to calculate the transit time (total time spent in the system).

Syntax:

MARK A
  • If operand A is specified: the current clock time is stored in parameter A of the transaction
  • If A is blank: the clock time is stored in the Mark Time word of the transaction
  • Used in conjunction with the TABULATE block to measure time intervals
  • Helps collect time-in-system statistics for performance analysis

Symbol:

+--------+
|  MARK  |
|   A    |
+--------+

Part B: TABULATE Block

The TABULATE block is used to collect statistical data and record frequency distributions into a TABLE entity. Each time a transaction passes through this block, one entry is made in the specified table.

Syntax:

TABULATE A
  • Operand A specifies the TABLE name/number where data is recorded
  • Works with a previously defined TABLE definition statement

TABLE Definition Syntax:

name TABLE A, B, C, D
ParameterMeaning
AVariable to be tabulated (e.g., MP1 for transit time from parameter 1)
BUpper limit of the first frequency class
CWidth of each frequency class
DNumber of frequency classes

Symbol:

+-----------+
| TABULATE  |
|     A     |
+-----------+

How MARK and TABULATE work together:

  1. MARK records the arrival time in a transaction parameter (e.g., parameter 1)
  2. TABULATE later computes the elapsed time as: Current Clock Time - Marked Time
  3. This elapsed time is entered into the specified TABLE for statistical analysis

Part C: Coffee Shop Simulation Model

Given Data

ParameterValue
Inter-arrival timeAverage 3 minutes (exponential)
Service timeAverage 2.5 minutes (exponential)
Number of servers1 (single barista)
Simulation duration8 hours = 480 minutes

System Type

This is an M/M/1 queuing system:

  • Poisson arrivals (exponential inter-arrival times)
  • Exponential service times
  • Single server (one barista)
  • FIFO discipline

Theoretical Performance (Pre-Simulation)

Server Utilization (rho):

rho = lambda / mu
    = (1/3) / (1/2.5)
    = 2.5 / 3
    = 0.833  (83.3%)

Expected customers served in 480 minutes:

Customers = 480 / 3 = 160 customers (approximately)

Since rho < 1, the system is stable.


Block Diagram

         +------------------+
         |   GENERATE 3     |  <-- Customers arrive every 3 min (exponential)
         +------------------+
                  |
         +------------------+
         |     MARK 1       |  <-- Record arrival time in parameter 1
         +------------------+
                  |
         +------------------+
         |   QUEUE  LINE    |  <-- Customer joins the waiting line
         +------------------+
                  |
         +------------------+
         |  SEIZE  BARISTA  |  <-- Customer occupies the barista
         +------------------+
                  |
         +------------------+
         |  DEPART  LINE    |  <-- Customer leaves the queue count
         +------------------+
                  |
         +------------------+
         |  ADVANCE 2.5,FN$ |  <-- Service time avg 2.5 min (exponential)
         +------------------+
                  |
         +------------------+
         | RELEASE BARISTA  |  <-- Barista is freed for next customer
         +------------------+
                  |
         +------------------+
         | TABULATE THRUPUT |  <-- Record transit time in table
         +------------------+
                  |
         +------------------+
         |   TERMINATE      |  <-- Customer leaves the system
         +------------------+

GPSS Program Code

* ================================================
* Coffee Shop Simulation Model
* Single Barista, 8-hour simulation (480 minutes)
* ================================================

        SIMULATE

* Define Table for Transit Time (time in system)
* MP1 = transit time from parameter 1
* Upper limit of first class = 0
* Class width = 1 minute
* Number of classes = 20

THRUPUT TABLE MP1,0,1,20

* ------------------------------------------------
* Customer Arrival and Service Segment
* ------------------------------------------------

        GENERATE  3,FN$XPDIS    ;Customers arrive, avg every 3 min (exponential)
        MARK      1              ;Store arrival time in parameter 1
        QUEUE     LINE           ;Customer joins the waiting line
        SEIZE     BARISTA        ;Customer seizes the single barista
        DEPART    LINE           ;Customer departs from queue
        ADVANCE   2.5,FN$XPDIS  ;Service takes avg 2.5 min (exponential)
        RELEASE   BARISTA        ;Barista is released
        TABULATE  THRUPUT        ;Record time-in-system in table
        TERMINATE                ;Customer exits the system

* ------------------------------------------------
* Timer Segment (controls simulation end time)
* ------------------------------------------------

        GENERATE  480            ;Generate one transaction at 480 minutes
        TERMINATE 1              ;Decrement termination counter to 0

* ------------------------------------------------
* Control Statement
* ------------------------------------------------

        START     1              ;Run simulation until counter reaches 0
        END

Explanation of Each Block

BlockPurpose
GENERATE 3,FN$XPDISCreates a customer transaction on average every 3 minutes, the function XPDIS spreading the inter-arrival times exponentially
MARK 1Writes the current clock time into parameter 1 of the customer, fixing the instant of arrival
QUEUE LINEEnters the customer in the queue entity LINE and starts collecting waiting line statistics
SEIZE BARISTAThe customer takes the single server facility BARISTA, and waits here if the barista is already busy
DEPART LINERemoves the customer from the queue count once service begins
ADVANCE 2.5,FN$XPDISHolds the customer for the service time, exponentially distributed about a mean of 2.5 minutes
RELEASE BARISTAFrees the barista so that the next waiting customer can be served
TABULATE THRUPUTEnters the elapsed time since the MARK block into the table THRUPUT
TERMINATERemoves the served customer from the model, leaving the termination counter unchanged
GENERATE 480Timer segment: produces a single transaction at clock time 480, the end of the 8 hour day
TERMINATE 1Reduces the termination counter by 1, bringing it to zero and stopping the run
START 1Sets the termination counter to 1 and starts the simulation

What the 8 Hour Run Produces

The line THRUPUT TABLE MP1,0,1,20 is a definition statement rather than a block: MP1 is the transit time measured from parameter 1, the first frequency class closes at 0, each class is 1 minute wide, and 20 classes are kept. Since MARK writes the arrival time and TABULATE reads it back through MP1, every entry in THRUPUT is one customer's total time in the shop.

When the timer transaction drives the termination counter to zero at 480 minutes, GPSS prints its standard report: the utilisation and number of entries of the facility BARISTA, the average and maximum contents of the queue LINE together with the average waiting time, and the THRUPUT table with its mean and standard deviation. With $\lambda = 1/3$ per minute and $\mu = 1/2.5 = 0.4$ per minute, the M/M/1 results give the values those simulated figures should settle near:

$$\rho = \frac{\lambda}{\mu} = 0.833, \qquad L_s = \frac{\rho}{1 - \rho} = 5 \text{ customers}, \qquad L_q = \frac{\rho^2}{1 - \rho} = 4.17 \text{ customers}$$

$$W_s = \frac{1}{\mu - \lambda} = 15 \text{ minutes}, \qquad W_q = \frac{\rho}{\mu - \lambda} = 12.5 \text{ minutes}$$

So over the 8 hour day about 160 customers arrive, the barista is busy for roughly 83 percent of the time, and a customer spends about 15 minutes in the shop of which about 12.5 minutes is spent waiting for service. A single 480 minute run is short, so the figures the simulation reports scatter around these analytical values rather than reproduce them exactly.

Open this answer on its own page →

2081 · 10 marks

Consider that a machine tool in a manufacturing shop is turning out parts at the rate of two every 5 minutes. As they are finished, the parts go to an inspector, who takes 5±25 \pm 25±2 minutes to examine each one and reject about 15% of the parts. Now develop a block diagram and write the code for simulating the above problem using GPSS, and also explain the function of each block used in the block diagram in detail.[10]

  • Machine produces parts at the rate of 2 every 5 minutes (i.e., one part every 2.5 minutes) - Inspector takes 5 ± 2 minutes to examine each part - Inspector rejects 15% of parts (accepts 85%) --- --- --- - This block creates transactions (parts) to enter the simulation model. - Since the machine...
Open this answer on its own page →

2080 · 10 marks

What is storage in GPSS? Describe the blocks associated to storage in GPSS. A machine tool in a manufacturing shop is turning out parts at the rate off one every 5 minutes. As they are finished the parts go on an inspector who takes 10±310 \pm 310±3 minutes to examine each one and rejects 1010%10 of the parts. Represent the system in GPSS using the concept of facility and run the simulation for 500 parts.[10]

Show solved answer

Storage in GPSS and Manufacturing Shop Simulation


Given

  • Part production rate: one part every $5$ minutes (deterministic inter-arrival time)
  • Inspection time: $10 \pm 3$ minutes (uniform distribution, range $7$ to $13$ minutes)
  • Rejection rate: $10%$ of parts rejected
  • Simulation length: $500$ parts
  • Modelling requirement: use the facility concept
  • Theory requirement: define storage and describe storage-related blocks

All data required is present and readable.


Solution

Part 1: Storage in GPSS

Definition

A storage in GPSS represents a resource that can be occupied by more than one transaction at the same time, up to a fixed capacity $N$. Whereas a facility is a single-server resource that only one transaction can hold at a time, a storage is a multi-server resource (a pool of $N$ identical servers). It is used to model things like a group of machines, a set of parking spaces, a bank of clerks, or a buffer of finite size.

Blocks Associated with Storage

BlockTypical formFunction
STORAGE (definition)name STORAGE NA statement that defines a storage entity and its capacity $N$
ENTERENTER name, kA transaction occupies $k$ units of the storage. If fewer than $k$ units are free, the transaction is held (queued) until they become available
LEAVELEAVE name, kA transaction releases $k$ units of the storage, freeing them for waiting transactions

If the amount k is omitted, it defaults to $1$.

Supporting blocks commonly used with storage

  • QUEUE / DEPART to gather waiting-line statistics before ENTER and after LEAVE
  • ADVANCE to represent the holding (service) time inside the storage

Facility vs Storage

FeatureFacilityStorage
Capacity$1$$N$ (multiple)
Occupy / free blocksSEIZE / RELEASEENTER / LEAVE
Typical useSingle inspector or single machinePool of machines, group of servers

Part 2: Manufacturing Shop Simulation (using a Facility)

System logic

Machine (1 part / 5 min) --> Queue --> Inspector (10±3 min) --> TRANSFER
                                                                    |
                                            90% ACCEPTED   <---+---> 10% REJECTED
                                            TERMINATE            TERMINATE

Since there is only one inspector, the inspector is modelled as a facility using SEIZE/RELEASE.

GPSS Program

*  ============================================
*  MANUFACTURING SHOP INSPECTION SIMULATION
*  Machine: 1 part every 5 minutes
*  Inspector: 10 +/- 3 minutes, rejects 10%
*  Run for 500 parts
*  ============================================

        SIMULATE

*  --- MACHINE GENERATES PARTS ---
        GENERATE    5,0         ; one part every 5 min (deterministic)

*  --- INSPECTOR (FACILITY) ---
        QUEUE       INSPQ       ; join inspection queue
        SEIZE       INSP        ; seize the single inspector
        DEPART      INSPQ       ; leave the queue
        ADVANCE     10,3        ; inspection time 10 +/- 3 (7..13)
        RELEASE     INSP        ; free the inspector

*  --- DECISION: 10% REJECTED, 90% ACCEPTED ---
        TRANSFER    .100,ACC,REJ  ; prob 0.100 -> REJ, else ACC

*  --- ACCEPTED PARTS ---
ACC     TERMINATE   1

*  --- REJECTED PARTS ---
REJ     TERMINATE   1

*  --- RUN CONTROL ---
        START       500
        END

Explanation of Each Block

BlockParametersPurpose
GENERATE 5,0Mean $=5$, spread $=0$Creates exactly one part every $5$ minutes (deterministic)
QUEUE INSPQQueue INSPQPart waits if inspector busy; records queue statistics
SEIZE INSPFacility INSPPart captures the single inspector
DEPART INSPQQueue INSPQPart leaves the queue after being served
ADVANCE 10,3Mean $=10$, spread $=3$Uniform inspection time in range $[7, 13]$ minutes
RELEASE INSPFacility INSPFrees inspector for the next part
TRANSFER .100,ACC,REJ$p = 0.100$With probability $0.10$ transaction goes to REJ; otherwise to ACC
TERMINATE 1 (ACC/REJ)Count $=1$Removes part and decrements termination counter
START 500$500$Runs until $500$ parts are terminated

Verification of numeric values

  • ADVANCE range: $10 - 3 = 7$ minimum, $10 + 3 = 13$ maximum. Correct uniform interval $[7,13]$.
  • TRANSFER probability operand .100 corresponds to $10%$ of parts routed to the reject branch, matching the stated $10%$ rejection.
  • Since each TERMINATE carries a count of $1$, the run stops after $500$ parts (accepted + rejected) have passed through, matching "run for 500 parts."

Expected proportions after 500 parts

  • Accepted $\approx 0.90 \times 500 = 450$ parts
  • Rejected $\approx 0.10 \times 500 = 50$ parts

These are the expected counts (subject to random variation of the RNG); the actual GPSS report gives the exact simulated figures.

Open this answer on its own page →

2079 · 10 marks

What is transaction in GPSS? Explain about facility in GPSS. Customers arrive at Joey Barbershop one every 15±3 minutes and it takes Joey 18±2 minutes to cut hair of a customer. Create a GPSS model with block diagram for the Barbershop using the concept of facility and run the simulation for 9 hours.[10]

Parameter Value ------ Inter-arrival time of customers $15 \pm 3$ minutes (uniform) Service time (haircut) $18 \pm 2$ minutes (uniform) Number of servers (barbers) 1 (single facility) Simulation duration 9 hours $= 9 \times 60 = 540$ minutes All required numeric data is present. --- A transaction...

Open this answer on its own page →

2078 · 5 marks

Workers come to a supply store at the rate of one every 6(+-) 2 minute. Their requisitions are processed by one of the two clerks who take 8 (+-) 2 minutes for each requisition. The requisitions are then passed to a single storekeeper who fills them one at a time, taking 6(+-)3 minutes for each. Draw GPSS Block diagram to simulate The above problem for 100 requisitions. [5]

Entity Details ----------------- Worker arrivals 1 every 6 ± 2 minutes Two clerks (Facilities) Process requisitions, 8 ± 2 minutes each Single storekeeper (Facility) Fills requisitions, 6 ± 3 minutes each Simulation termination After 100 requisitions completed --- - Workers arrive and join a queu...

Open this answer on its own page →

2076 · 5 marks

Parts are being made at the rate of one every 10 minutes. They are of two types, A and B. And are mixed randomly with about 10% being type B. A separate inspector is assigned to examine each part. Inspection of part A takes 6 ± 2 minutes. Both inspector rejects 10% of parts they inspect. Draw GPSS block diagram to simulate the above problem for 100 parts. [5]

Parameter Value ------------------ Part generation rate 1 part every 10 minutes Type A parts 90% of all parts Type B parts 10% of all parts Inspection time (Type A) 6 ± 2 minutes (uniform: 4,5,6,7,8 min) Inspection time (Type B) Not specified, assumed similar or same inspector logic Rejection rat...

Open this answer on its own page →