Data builtins

Data builtins report the value of model variables at a particular time in the simulation.

This section describes the following builtins:

ENDVAL(<input>, [<initial>])

The ENDVAL builtin returns the ending value of input, from the most recent simulation run in a session with a model. The first time you run the model after opening it, ENDVAL will return the initial value you've specified. If you don't specify an initial value, ENDVAL assumes the first-run value to be the initial value of input.

Example:

Is_Performance_Improving = Current_Performance_Indicator -

ENDVAL(Current_Performance_Indicator,0)

enables your model to look at current performance, relative to the ending value of performance in the last simulation run of a given simulation session. In so doing, ENDVAL provides a mechanism for looking at run-to-run performance changes, and thus can provide a vehicle for triggering "as-needed" coaching to the model consumer.

HISTORY(<variable>, <time>)

The HISTORY builtin returns the value of a variable at a prior time in the simulation.

Note: HISTORY (stock, TIME-1) is the same as DELAY (stock,1).

INIT(<variable>)

The INIT builtin takes the initial value of the stock, flow, or converter, where the initial value for the variable has been calculated at the outset of a simulation. The INIT function will accept only a single model variable name within its parentheses.

Examples:

Distance_Traveled = Position - INIT(Position)

Computes Distance Traveled as the difference between current position and the initial value of position.

Debt_Ratio = Debt/INIT(Debt)

Computes Debt Ratio as the ratio of Debt to its initial value. When creating graphical functions, it's often useful to normalize the input to the graphical function in this manner.

PREVIOUS(<variable or arrayed variable>, <initial>)

The PREVIOUS builtin returns the value of a variable or array at the previous time in the simulation. When there's no previous time, it returns the <initial> value.

Examples:

PREVIOUS(A, 0) returns the value of A at the previous time, or returns 0 if there's no previous time.

PREVIOUS(SELF,2) returns the value of the current variable at the previous time, or returns 2 if there's no previous time.

Concept Link IconSee Also