# Functions

### From Support

## Contents |

# Using SIGMA Functions

A number of predefined functions have been incorporated into the SIGMA simulation environment: functions for reading data files, runtime interactions, mathematics, modeling priority ranked queues, and statistics.

Functions can be placed in expressions, which can be used in state changes, edge conditions, edge priorities, and edge attributes. The functions are treated just like any state variable. Arguments of SIGMA functions are in braces {} and multiple arguments are separated by semicolons.

Functions can often be nested and used as arguments for each other. For example, -6*LN{RND} (a random number function used as the argument for a natural log) will approximate an exponentially distributed random variable with a mean of 6 (see Methods of Generating Random Variates). Any of the expressions in these functions can, of course, be replaced by real constants, which are rounded down if integers are required. Note that you cannot use an array as an argument for a function. For example, you should break the function MAX{X[I;J];Y} into the two statements: Z=X[I;J], MAX{Z;Y}.

NOTE: Arguments of SIGMA functions are in braces {} and multiple arguments are separated by semicolons (;).

SIGMA functions are presented by category below.

## Statistical Functions

Several functions have been included in SIGMA for statistical analysis. Several of these functions can be used to generate random variables. These include BET{} for beta variates, TRI{} for triangular variates, ERL{} for Erlang variates, GAM{} for highly skewed gamma variates, and NOR{} for normal variates. The use of these functions and the generation of other types of random input are discussed in Input Modeling. The remaining functions are primarily for model diagnostics and are not included in the C translations generated by SIGMA. Note that the variables used as arguments in these functions must have been used as traced variables for at least one previous run in the current SIGMA session.

- AVE{X} Gives the cumulative average of traced variable X.

- BET{X;Y} Generates a standard Beta variate with nonnegative parameters given by the values of expressions X and Y.

- ERL{X} Generates an Erlang pseudo random variate with shape parameter X; an Exponential with mean M is generated using M*ERL{1}.

- GAM{X} Generates a Gamma pseudo random variate with fractional shape parameter X.

- NOR{M;S} Generates a Normal (M,S^2) pseudo random variate.

- RND Generates a Uniform (0,1) pseudo-random variate.

- STS{X} Area under the standardized time series for the traced variable X.

- TAV{X} Time average of traced variable X.

- TRI{X} Generates a Triangular p.r.v. on (0,1) with mode X.

- VAR{X} Cumulative variance of traced variable X.

## Mathematical Functions

A number of standard mathematical operations are included in SIGMA.

- COS{Y} Returns the cosine of Y (Y in radians).

- LN{Y} Returns the natural log of Y.

- MAX{Y;X} Returns the maximum of X and Y.

- MIN{Y;X} Returns the minimum of X and Y.

- MOD{Y;X} Returns the integer remainder of Y divided by X.

- PI Predefined constant = 3.14159.

- SIN{Y} Returns the sine of Y (Y in radians).

## Reading Data File Functions

It is sometimes useful to read data into simulations. The most common uses for this are running batched experiments and trace driven simulations. SIGMA accomplishes this using the DISK function.

- DISK{F;I} Reads the I-th number from disk file, F, where I is any valid integer-valued SIGMA expression. If I=0, the file is read sequentially.

## List Functions

Ranked queues occur whenever the order of service might differ from the order of entity arrival. SIGMA primarily uses two functions that make it very easy to model priority ranked queues and other types of lists: The PUT function puts entries onto lists and the GET function gets entries off from lists. Several sample models using SIGMA’s ranked lists functions, PUT and GET, have been included.

- CGET{C,L} Gets first entry from list, L, where condition, C is true.

- GET{O;L} Gets values for the ENT[] array from list L with option O.

- PUT{O;L} Puts the present ENT[] array on list L according to option O.

## Runtime Functions

Runtime functions are either used for interactive execution during a run (i.e. a simulation requires user interaction during a simulation), or are used to report the current simulated time (i.e. the clock).

- ASK{} Displays the value of expression, X, during the run and allows you to change it.

- CLK Is the current simulated clock time, which is automatically updated to the time of each event occurrence.

- PAUSE{} Halts the execution of a simulation run. Useful for debugging.

- SET{X} Resets all variables to zero and the random number seed to the integer N. If no argument is given, the original random number stream continues to be used.