What is a function?
A function is a component that produces a numeric value from an input. That value can represent times, quantities, costs, or any other variable parameter we want to incorporate into the model.
In mathematical terms, we could write something like:
f(x) = 10 + (x * 5)
If x takes values between 0 and 1, then f(x) will take values between 10 and 15.
In GPSS-Plus, when we use:
ADVANCE 10,5
we are using that implicit function: it generates a random value between 0 and 1, multiplies it, and resolves a value between 10 and 15.
In statistical terms, this is a uniform distribution between 10 and 15, meaning that all values within the range have the same probability of occurring.
Using functions:
In many cases, reality is not uniform.
If we measure how long 1000 vehicles take to travel 100 km, most will take close to 1 hour. Some will take a bit less, others a bit more. But almost none will do it in 30 minutes or in 2 hours.
That is not a uniform distribution. It is what is known as a normal distribution or Gaussian.
That is why GPSS-Plus allows defining functions that more accurately model behaviors like these. There are two ways to do it:
1. FUNCTION of type VALUES
With this method, we manually define a function based on a cumulative probability table.
Function {
NAME: funValues,
TYPE: "VALUES",
EXPRESSION: "RANDOM",
VALUES: "0.0001,0.0000/0.0002,0.0101/.../1.0000,1.0000/"
}
This table associates keys (cumulative probabilities between 0 and 1 using EXPRESSION: "RANDOM") with result values. If the generated random value is 0.33, the function finds the corresponding interval and returns the associated value, representing a bell-shaped (Gaussian) distribution, where extreme values are less likely than central ones.
So an instruction like:
ADVANCE 20 + (FN$funValues * 20)
will generate values between 20 and 40, concentrated around 30.
2. FUNCTION of type GAUSS
This method allows defining a Gaussian distribution directly through its characteristic parameters:
Function {
NAME: funGauss,
TYPE: "GAUSS",
A: 1,
B: 30,
SIGMA1: 3.3,
SIGMA2: 3.3,
INTERVALS: 100
}
A: curve height (visual only, does not affect the result)B: central value (mean)SIGMA1,SIGMA2: left and right standard deviationsINTERVALS: number of divisions for the function
With this function, we simply use:
ADVANCE FN$funGauss
Both techniques will produce a distribution of times around the value 30, but using different methods: a predefined table versus an automatically constructed curve.
Visualization and validation
Facilities with parameters such as:
E_BIN_START:16, E_BIN_SIZE:1, E_BIN_COUNT:40
automatically record statistics about how long each entity has remained in the resource. These statistics are shown in the report and allow checking how the function actually behaves.
We will see that, in both cases, the resulting graph is a Gaussian distribution. This allows validating that both the manual table and the generated function provide coherent behaviors.

Example
/*
Defining functions
*/
SYSTEM {TYPE:OPTIONS,Speed:5}
Facility {NAME:VENTANILLA1,X:165,Y:184,E_BIN_start:16,E_BIN_SIZE:1,E_BIN_COUNT:40,capacity:3}
Facility {NAME:VENTANILLA2,X:384,Y:186,E_BIN_start:16,E_BIN_SIZE:1,E_BIN_COUNT:40,capacity:3}
POSITION {NAME:POS1,X:278,Y:381}
POSITION {NAME:POS2,X:482,Y:380}
Function {name:funGauss, type:"GAUSS", a:1, b:30, sigma1:3.3, sigma2:3.3,intervals:100 }
Function {NAME:funValues,type:"VALUES",expression:"RANDOM",VALUES:"
0.0001,0.0000/0.0002,0.0101/0.0004,0.0202/0.0006,0.0303/0.0008,0.0404/
0.0011,0.0505/0.0015,0.0606/0.0020,0.0707/0.0025,0.0808/0.0032,0.0909/
0.0039,0.1010/0.0049,0.1111/0.0060,0.1212/0.0073,0.1313/0.0088,0.1414/
0.0106,0.1515/0.0128,0.1616/0.0152,0.1717/0.0180,0.1818/0.0213,0.1919/
0.0250,0.2020/0.0293,0.2121/0.0341,0.2222/0.0396,0.2323/0.0458,0.2424/
0.0527,0.2525/0.0603,0.2626/0.0689,0.2727/0.0783,0.2828/0.0887,0.2929/
0.1000,0.3030/0.1124,0.3131/0.1258,0.3232/0.1403,0.3333/0.1559,0.3434/
0.1726,0.3535/0.1904,0.3636/0.2093,0.3737/0.2292,0.3838/0.2501,0.3939/
0.2720,0.4040/0.2948,0.4141/0.3185,0.4242/0.3429,0.4343/0.3680,0.4444/
0.3937,0.4545/0.4199,0.4646/0.4464,0.4747/0.4731,0.4848/0.5000,0.4949/
0.5269,0.5051/0.5536,0.5152/0.5801,0.5253/0.6063,0.5354/0.6320,0.5455/
0.6571,0.5556/0.6815,0.5657/0.7052,0.5758/0.7280,0.5859/0.7499,0.5960/
0.7708,0.6061/0.7907,0.6162/0.8096,0.6263/0.8274,0.6364/0.8441,0.6465/
0.8597,0.6566/0.8742,0.6667/0.8876,0.6768/0.9000,0.6869/0.9113,0.6970/
0.9217,0.7071/0.9311,0.7172/0.9397,0.7273/0.9473,0.7374/0.9542,0.7475/
0.9604,0.7576/0.9659,0.7677/0.9707,0.7778/0.9750,0.7879/0.9787,0.7980/
0.9820,0.8081/0.9848,0.8182/0.9872,0.8283/0.9894,0.8384/0.9912,0.8485/
0.9927,0.8586/0.9940,0.8687/0.9951,0.8788/0.9961,0.8889/0.9968,0.8990/
0.9975,0.9091/0.9980,0.9192/0.9985,0.9293/0.9989,0.9394/0.9992,0.9495/
0.9994,0.9596/0.9996,0.9697/0.9998,0.9798/0.9999,0.9899/1.0000,1.0000/
"}
START 500
;*****************************************************
GENERATE 10,0,0,0 {NAME:GEN1,X:91,Y:383}
ADVANCE 20,4 {TO:VENTANILLA1}
SEIZE VENTANILLA1
ADVANCE 20 + (FN$funValues * 20) ; classic definition
RELEASE VENTANILLA1
ADVANCE 20,0 {TO:POS1}
ADVANCE 20,0 {TO:VENTANILLA2}
SEIZE VENTANILLA2
ADVANCE FN$funGauss ; parameter-based definition
;ADVANCE 2 ; parameter-based definition
RELEASE VENTANILLA2
ADVANCE 20,0 {TO:POS2}
ENDGENERATE 1