$Values

The $Values reference provides information about all the results in the model, including those for array segments and decision variables.

The properties for many variables are set in your model, then displayed in your interface using the $Values statement. To learn more about setting variable properties, read Variable and Decision Properties

The $Value statement is really a collection of all "Values" in the model. A Value is a line item in the simulation and represents a series of numbers over time. It might be a variable such as TotalRevenue, a decision, such as Hires, or a segment of a arrayed variable such as Sales[Toys].

If you are not familiar with arrays, you can read about them in Modeling with Arrays. However, if your model does not contain any arrays, you can skip the next paragraph.

$Value does not contain any arrayed variables or decisions without the array subscript. For example, if Sales is arrayed over the range toys, electronics, furniture then Sales[toys] has a Value, but Sales does not.

FML statements can be combined and embedded into other FML statements. For example:

 

$Values.get('Profit').getResult($Run.EndStep)
 

 

Combines the method $Values.getResult method with the property $Run.EndStep property and will return the value for the variable Profit at the end of the simulation.

 

$Values Properties

$Values properties display values for variables, decisions, or arrayed variables in your model. The properties for many variables are set in your model, then displayed in your interface using the $Values statement.

Decision

Displays the decision value without any formatting. Works only with Decisions in your model.

The value displayed by the Decision property can be different than the value displayed by Result property if the ExecuteDecisionImmediately property is set to false, so that decisions don't take effect until the next time step, and the user has entered a decision but the simulation has not been advanced.

Consider this scenario: ExecuteDecisionImmediately is set to false. Price is a decision and it's value is 40. Before the user changes Price, the Decision property for Price and the Result property for Price are the same. Now the user changes Price to 60 and submits the form, but does not advance the simulation. Now the Decision property for Price is 60, but the Result property for Price is still 40. After the user advances the simulation, the Result property for Price will also be 60.

Example FML statement:

$Values.get('Price').Decision

Example result:

60.0

DecisionFormatted

Displays the formatted decision value of this variable for the current time. The format is determined by NumberFormat. Works only with Decisions in your model.

The value displayed by the DecisionFormatted property can be different than the value displayed by ResultFormatted property if the ExecuteDecisionImmediately property is set to false, so that decisions don't take effect until the next time step, and the user has entered a decision but the simulation has not been advanced.

Consider this scenario: ExecuteDecisionImmediately is set to false. Price is a decision and it's value is $40. Before the user changes Price, the DecisionFormatted property for Price and the ResultFormatted property for Price are the same. Now the user changes Price to $60 and submits the form, but does not advance the simulation. Now the DecisionFormatted property for Price is $60, but the ResultFormatted property for Price is still $40. After the user advances the simulation, the ResultFormatted property for Price will also be $60.

Example FML statement:

$Values.get('Price').DecisionFormatted

Example result:

$60

DecisionMax

Displays the maximum acceptable value for a user decision. DecisionMax is used with the #Validate macro on the Decisions form, to prevent the user from entering a  that is higher than DecisionMax. DecisionMax is displayed without any formatting. Works only with Decisions in your model.

Example variable property:

P Price.DecisionMax = 100

Example FML statement:

$Values.get('Price').DecisionMax

Example result:

100.0

DecisionMin

Displays the minimum acceptable value for a user decision. DecisionMin is used with the #Validate macro on the Decisions form, to prevent the user from entering a  that is lower than DecisionMin. DecisionMin is displayed without any formatting. Works only with Decisions in your model.

Example variable property:

P Price.DecisionMin = 0

Example FML statement:

$Values.get('Price').DecisionMin

Example result:

0.0

Label

Displays a user-friendly label associated with a variable or decision. This is the same label used in graphs. Labels are set in the model. When labels are not set, the default value for Label is the variable name.

Example variable property:

P Inventory Value.Label = "Current Value of Inventory"

Example FML statement:

$Values.get('Inventory Value').Label

Example result:

Current Value of Inventory

NumberFormat

Displays the number format for the variable or decision.

Example variable property:

P Profit.NumberFormat = "$#,##0"

Example FML statement:

$Values.get('Profit').NumberFormat

Example result:

$#,##0

Result

Displays the variable value for the current time without any formatting.

Example FML statement:

$Values.get('Profit').Result

Example result:

31647.3

ResultFormatted

Displays the formatted value of this variable for the current time. The format is determined by NumberFormat.  

Example FML statement:

$Values.get('Profit').ResultFormatted

Example result:

$31,647

 

$Values Methods

$Values methods take an argument and return a result based on your model information. $Values methods are case sensitive. All methods start in lower-case.

get('variable name')

Retrieves the properties and methods related to the named variable. The default property for get is ResultFormatted. That is, if no property or method is included with the get method, the get method will display the formatted value of this variable for the current time.

Example variable:

V Profit = Revenues - Costs

Example value for variable name: Profit

Example FML statement:

$Values.get('Profit')

Example result:

$1,000

getResult(step)

Displays the result at the specified step without any formatting. Note that step is an integer starting at 0.

Example value for step:

2

Example FML statement:

$Values.get('Profit').getResult(2)

Example result:

456234.2

 

getResultFormatted(step)

Displays the formatted result at the specified step. Note that step is an integer value starting at 0.

Example value for step:

2

Example FML statement:

$Values.get('Profit').getResultFormatted(2)

Example result:

$456,234

 

Getting a Variable Based on a List of Names

You can use the $Values.get(  ) statement within a #foreach loop to extract multiple variable names automatically from a list.  

For example:

 

#set ($VariableList = ["Sales", "Profit", "Price"])

#foreach ($VariableName in $VariableList )
The value of $VariableName is $Values.get($VariableName)<BR>
#end
 

 

This will return the following output:

 

The value of Sales is 121
The value of Profit is 71,000
The value of Price is $1,000