Formula Block

formulaHelp

Description

The Formula block can evaluate an expression based on state or model information. You create variables to be used in the expression (called input variables) and you formulate them into an expression that is evaluated every time a value is pulled from the Formula block’s OutValue port. The expression is also evaluated and pushed out of the Formula block’s OutValue port every time input is pushed into one of the Formula block’s input value ports. The value associated with an input variable can come either from an entity attribute or from an input value port. If the source for an input variable is designated to be a port, an input value port is created on the block and is associated with the appropriate input variable. Whenever a value is requested from a Formula block, or new input arrives at a Formula block, the Formula block first determines which values associated with its input variables need to be acquired (based on the setting for the To Acquire Port Values Only When Needed properties dialog box option), and then attempts to evaluate its expression. The result of this evaluation leaves through the OutValue port.

Fixed Ports

OutValue

Output value port for the result of evaluating the Formula block’s expression.

Properties Dialog Box Controls

Add

Adds a new input variable with a default Name, Type, and Source to the Input Variables table. You can edit the Name, Type, and Source of the variable directly in the table. The variable names listed in the Formula block’s Input Variables table must be unique. You can change the Type through a drop-down box on the cell in the table. (A variable Type cannot be changed in the table after the Apply button is clicked. If you want to change a variable Type after Apply has been clicked, you must remove the variable, add it again, and then modify the Type of the newly added variable before clicking Apply again.)

Remove

Deletes the selected variable from the Input Variables table.

To Acquire Port Values Only When Needed

If this option is turned off, the Formula block always acquires values for all of its input variables. If this option is turned on, the Formula block acquires only the values for its input variables that are required in order to determine the result of the expression.

Expression

Contains the expression to be evaluated for the Formula block. Any variables used in the expression must be defined in the Input Variables table. In addition to the expressions listed in Appendix F: Expressions, the Formula block also supports a dot (.) operator. When there is an input variable of type Observation, the dot operator can be used to access the values of the observation’s member variables. For example, suppose an observation input variable named Record has member variables Name and GPA (so that the observation Record is a row from a data set with columns Name and GPA). The expression Record.Name will return the value of Name for the current observation. Similarly, the following expression will return a string that depends on the value of GPA:

cond(Record.GPA < 60.0, "Fail", "Pass")

Expression Result

Identifies the value type that results from evaluating the expression. The selected option generates the appropriate output port type for the Formula block.

Apply

Validates the expression and saves the input variables, the expression, and the expression result. Input value ports are created or deleted and the type of the output value port is set as needed.

Candidates for Design of Experiments

Factors

None

Responses

None