Concepts > Attributes (MetaAttributes) > Calculation Rule (Simulation)
Calculation Rule (Simulation)
This vb script code computes the value of the indicator when it is seen from an hypothesis.
The result of this computation is displayed in the Simulated Value property of the indicator.
 
Value computation
To return the indicator value, store it in an implicit variable named value.
Other implicit variables are:
- oIndicator: the current indicator itself
- oHypothesis: the current hypothesis the indicator is linked to. The variable is only available when the indicator is seen from a hypothesis.
- Excel: a reference to a WorksheetFunction variable. This reference allows the access to all Excel mathematical functions. If Microsoft Excel is not installed on the machine, the access fails. For more details, refer to the Microsoft Excel documentation.
- Sampler: a reference to the MEGA SimulationSampleAnalyzer macro. This component is designed to manage simulation sample collect on data collector. Refer to the comment of the macro to determine which functions are available.
Some shortcuts are accessible. See the Sampling functions section for more details.
 
Sub-indicators
To compute value using sub-indicators, drag and drop them in any vb script statement.
The bold displayed name will be replaced by the value during the computation.
 
Related objects
In the simulation editor, the indicator shows related objects. Any attribute of these objects can be dragged and dropped.
Then, two fields are inserted separated by a dot: the object name and the attribute name.
This formula will return the value of the inserted object regarding the current hypothesis.
Some of related objects may display sub-objects such as operations. In that case, the attributes are written prefixed with two objects and the returned value match the correlated results (for example the performing time of a given org-unit for a specific operation).
If the seek attribute is a duration, the value returned is the number of seconds.
 
Time
When the attribute value is a time expressed in number of seconds, it can be converted using the following functions:
- dayOf(aTime): returns the number of days.
- hourOf(aTime): returns the number of hours including the day hours.
- minuteOf(aTime): returns the number of minutes including the hour minutes.
 
Sampling functions
These functions are shortcuts to the sampler component functions discussed above. They are prefixed with the letter 'S' which stands for Sampler.
In all functions:
sXmlSample is the sample returned in the xml format. This value can be retrieved dropping the Cost Sample Content or the Time Sample Content meta attribute from the object containing the corresponding sample.
sKey is the key name of the data researched for in the sample.
sCondition is a condition following the syntax defined in the SimulationSampleAnalyzer MEGA macro.
 
- SCount (sXmlSample): returns the number of rows in the sample.
- SMax (sXmlSample, sKey): returns the maximal value indexed by the key.
- SMin (sXmlSample, sKey): returns the minimal value indexed by the key.
- SCountIf (sXmlSample, sCondition): returns the number of rows satisfying the given condition.
- SMaxIf (sXmlSample, sCondition, sKey): returns the maximal value indexed by the key for rows satisfying the given condition.
- SMinIf (sXmlSample, sCondition, sKey): returns the minimal value indexed by the key for rows satisfying the given condition.
- SAverageIf (sXmlSample, sCondition, sKey): returns the average of values indexed by the key for rows satisfying the given condition.
 
Examples
 
' -------------------------------
' The two sub-indicators have been drag and dropped in the vb code.
value = subIndicator1 + subIndicator2
 
' -------------------------------
' Computes the hyperbolic sinus of one sub-indicator.
value = Excel.sinh (subIndicator1)
 
' -------------------------------
' Computes the sum of all sub-indicator unknowing how many they are in advance.
' Refer to the MEGA Api for more details.
value = 0
for each oSubIndicator in oIndicator.[Sub-Indicator]
value = value + oSubIndicator.[Simulated Value]
next
 
' -------------------------------
' Returns the average of processing time for a message sample with a date exceeding 3000 seconds
value = SAverageIf (myMessage.Time Sample Content, 'value(Date)
 
Translations
Type
VarChar (4) Standard
 
List of MetaClasses