skip to main content
Corticon Studio: Rule Modeling Guide : Rules containing calculations and equations : Supported uses of calculation expressions : Calculation as a comparison in a condition

Try Corticon Now
Calculation as a comparison in a condition
Once planWeight has been derived by the Nonconditional calculation in the figure below, it may be used immediately elsewhere in this or subsequent Rulesheets. 
Note: "Subsequent Rulesheets" means Rulesheets executed later in a Ruleflow. The concept of a Ruleflow is discussed in the Quick Reference Guide.
An example of such usage appears in the following figure:
Figure 140. planWeight Derived and Used in Same Rulesheet
In Condition row a, planWeight is compared to the aircraft's grossWeight to make sure the aircraft is not overloaded. An overloaded aircraft must not be allowed to fly, so the approved attribute is assigned a value of false.
This has the advantage of being both clear and easy to reuse – the term planWeight, once derived, may be used anywhere to represent the data produced by the calculation. It is also much simpler and cleaner to use a single attribute in a rule expression than it is a long, complicated equation.
But this does not mean that the equation cannot be modeled in a Conditional expression, if preferred. The example shown in the figure below places the calculation in the LHS of the Conditional comparison to derive planWeight and compare it to grossWeight all in the same expression.
Figure 141. A Calculation in a Conditional Expression
This approach might be preferable if the results of the calculation were not expected to be reused, or if adding an attribute like planWeight to the Vocabulary were not possible. Often, attributes like planWeight are very convenient intermediaries or holders to carry calculated values that will be used in other rules in a Rulesheet. In cases where such attributes are conveniences only, and are not used by external applications consuming a Rulesheet, they may be designated as transient attributes in the Vocabulary, which causes their icons to change from blue/yellow to orange/yellow. More details on transient attributes are included in Modeling the Vocabulary in Corticon Studio of this guide.