2082 1

CSC328 · 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

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]

Simulation and ModelingChapter 8: Simulation of Computer SystemsSimulation Languages

Quick answer

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).

MARK and TABULATE Block in GPSS & Coffee Shop Simulation


Part A: MARK Block

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.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.