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.
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 answerHide 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
| Parameter | Meaning |
|---|---|
| A | Variable to be tabulated (e.g., MP1 for transit time from parameter 1) |
| B | Upper limit of the first frequency class |
| C | Width of each frequency class |
| D | Number of frequency classes |
Symbol:
+-----------+
| TABULATE |
| A |
+-----------+
How MARK and TABULATE work together:
- MARK records the arrival time in a transaction parameter (e.g., parameter 1)
- TABULATE later computes the elapsed time as: Current Clock Time - Marked Time
- This elapsed time is entered into the specified TABLE for statistical analysis
Part C: Coffee Shop Simulation Model
Given Data
| Parameter | Value |
|---|---|
| Inter-arrival time | Average 3 minutes (exponential) |
| Service time | Average 2.5 minutes (exponential) |
| Number of servers | 1 (single barista) |
| Simulation duration | 8 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
| Block | Purpose |
|---|---|
GENERATE 3,FN$XPDIS | Creates a customer transaction on average every 3 minutes, the function XPDIS spreading the inter-arrival times exponentially |
MARK 1 | Writes the current clock time into parameter 1 of the customer, fixing the instant of arrival |
QUEUE LINE | Enters the customer in the queue entity LINE and starts collecting waiting line statistics |
SEIZE BARISTA | The customer takes the single server facility BARISTA, and waits here if the barista is already busy |
DEPART LINE | Removes the customer from the queue count once service begins |
ADVANCE 2.5,FN$XPDIS | Holds the customer for the service time, exponentially distributed about a mean of 2.5 minutes |
RELEASE BARISTA | Frees the barista so that the next waiting customer can be served |
TABULATE THRUPUT | Enters the elapsed time since the MARK block into the table THRUPUT |
TERMINATE | Removes the served customer from the model, leaving the termination counter unchanged |
GENERATE 480 | Timer segment: produces a single transaction at clock time 480, the end of the 8 hour day |
TERMINATE 1 | Reduces the termination counter by 1, bringing it to zero and stopping the run |
START 1 | Sets 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.
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]
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 answerHide 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
| Block | Typical form | Function |
|---|---|---|
| STORAGE (definition) | name STORAGE N | A statement that defines a storage entity and its capacity $N$ |
| ENTER | ENTER name, k | A transaction occupies $k$ units of the storage. If fewer than $k$ units are free, the transaction is held (queued) until they become available |
| LEAVE | LEAVE name, k | A 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
| Feature | Facility | Storage |
|---|---|---|
| Capacity | $1$ | $N$ (multiple) |
| Occupy / free blocks | SEIZE / RELEASE | ENTER / LEAVE |
| Typical use | Single inspector or single machine | Pool 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
| Block | Parameters | Purpose |
|---|---|---|
GENERATE 5,0 | Mean $=5$, spread $=0$ | Creates exactly one part every $5$ minutes (deterministic) |
QUEUE INSPQ | Queue INSPQ | Part waits if inspector busy; records queue statistics |
SEIZE INSP | Facility INSP | Part captures the single inspector |
DEPART INSPQ | Queue INSPQ | Part leaves the queue after being served |
ADVANCE 10,3 | Mean $=10$, spread $=3$ | Uniform inspection time in range $[7, 13]$ minutes |
RELEASE INSP | Facility INSP | Frees 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
.100corresponds 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.
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]
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]
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]
Make Unit 8 stick
Practice CSC328 with flashcards & quizzes