Accumulating data in tables

Updated: 2025-09-27

Simulation and statistics go hand in hand. We can do very little if some basic concepts are not clear. In GPSS-Plus, statistical calculations are divided into three major groups:

  1. Times an entity remains in a resource (entity-oriented).

  2. Times a number of entities occupy a resource (resource-oriented).

  3. Any other custom data you want to measure (model-oriented).

In this first example, we work with case 3, where we want to measure the time an entity remains in a section of the circuit, including a resource (a FACILITY) and its surrounding area.

Using TABLE to record residence times:

GPSS-Plus automates much of the work. You only need to create a TABLE with the appropriate parameters:

TABLE {name: TABLA1, E_BIN_START:0, E_BIN_SIZE:1, E_BIN_COUNT:100, EXPRESSION:(AC1$ - P$TIEMPOINICIO)}

This configures a table with 100 bins of width 1, starting at 0. Each time TABULATE TABLA1 is executed, the EXPRESSION is evaluated:

(AC1$ - P$TIEMPOINICIO)

which computes the difference between the current time (AC1$) and a previously stored instant (P$TIEMPOINICIO).

This value, representing the entity’s residence time within the modeled zone, is accumulated in the corresponding bin.

A basic example

We create entities that move FROM ONE POINT, pass through a FACILITY, and reach ANOTHER POINT, then tabulate the duration:

GENERATE 8,3
    ADVANCE 30,0 {TO:POS1}
    ASSIGN TIEMPOINICIO,AC1$      ; Start timing
    ADVANCE 20,0 {TO:VENTANILLA1}

    SEIZE VENTANILLA1
    ADVANCE 20,20                 ; +20 to +40 (random) + queue time
    RELEASE VENTANILLA1

    ADVANCE 20,0 {TO:POS2}
    TABULATE TABLA1               ; End timing
    ADVANCE 20,0 {TO:POS3}

ENDGENERATE

What does the table measure?

If you inspect the report output, you will see a rectangular (uniform) distribution between 60 and 80, with some higher values for entities that spent time waiting in the queue. That is, all entities remained within that expected range.

This is a solid starting point for analyzing internal model behavior using objective data.

Example

/*

  	 	Accumulating data in tables
 
*/
FACILITY {NAME:VENTANILLA1,X:380,Y:348,capacity:4}
POSITION {NAME:POS1,X:218,Y:437}
POSITION {NAME:POS2,X:591,Y:429}
POSITION {NAME:POS3,X:713,Y:329}

Graphic {NAME:Line1,Type:LINE,color:#FF0000, X1:218,Y1:500,X2:592,Y2:500}
Graphic {NAME:Text1,Type:TEXT,X:410,Y:527,Text:"Statistics section"}

TABLE {name: TABLA1,E_BIN_START:50,E_BIN_SIZE:1,E_BIN_COUNT:60,EXPRESSION:(AC1$ - P$TIEMPOINICIO)}
;TABLE {name: TABLA1,E_BIN_START:0,E_BIN_SIZE:1,E_BIN_COUNT:160,EXPRESSION:(AC1$ - D$M0)}

START 500 

;***************************************************************

GENERATE 8,3 {NAME:GEN1,X:66,Y:350}

    ADVANCE 40,0 {TO:POS1}
    ASSIGN TIEMPOINICIO,AC1$
    ADVANCE 20,0 {TO:VENTANILLA1}

    SEIZE VENTANILLA1
    ADVANCE 20,20
    RELEASE VENTANILLA1

    ADVANCE 20,0 {TO:POS2}
    TABULATE TABLA1
    ADVANCE 20,0 {TO:POS3}

ENDGENERATE 1

;***************************************************************