Data builtins report the value of model variables at a particular time in the simulation.
This section describes the following builtins:
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.
When you are editing a model the ENDVAL function will reset when you make changes to it directly or through actions such as changing array definitions. In this case it will act as if there is no previous run in the session. Publishing a model from the interface will also cause the function to reset.
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).
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.
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.