Rulesheet processing modes of looping
- Last Updated: March 24, 2022
- 2 minute read
- Corticon
- Version 6.3
- Documentation
Occasionally, you need rules to be re-evaluated and re-fired (if satisfied). This scenario requires the Corticon rule engine to make multiple passes through the same Rulesheet. This behavior is called advanced inferencing, and to enable it in Rulesheet execution, you must set Rulesheet processing mode to Advanced Inferencing by selecting from the Studio menubar, as shown:
We emphasize it here with an orange highlight to the immediate left of the Conditions header.
If the rule engine is permitted to loop through the rules, the following events occur:
Given a value of A as the initial data, the
condition in rule 1 will be satisfied and the rule will fireirclsetting the value to
B. The second rule's condition is then satisfied, so
the value will advance (or be reset) to C, and so on,
until the value is once again B after the fourth rule
fires. Up to this point, the rule engine is exhibiting standard, optimized inferencing
behavior.
Here is the new part: the value (state) changed since the second rule last
fired, so the rule engine will re-evaluate the condition, and, finding it satisfied, will
fire the second rule again, advancing the value to C. The
third rule will also be re-evaluated and re-fired, advancing the value to D, and so on. This sequence is illustrated in the following
figure.
Here is the key to understanding looping: when a looping processing mode is enabled, rules are continually re-evaluated and re-fired in a sequence determined by their dependency network as long as the data state changed since their last firing. Once the data state no longer changes, looping ceases.
Notice that the last column of the table indicates the number of loop iterations. The first loop does not begin until rule 2 fires for the second time. The first time through the rules (steps 1-4) does not count as the first loop iteration because the loop does not actually start until step 5.