When you have finished modeling rules, analyze the rules for logical errors.
Often, initial business rule specifications are:
Ambiguous—The rules conflict under certain scenarios.
Incomplete—The rules fail to address all possible scenarios.
Looping—The rules form circular logic or loops.
Before automating the rules, it is critical to eliminate logical errors to
ensure that the decision service provides correct and consistent results. Corticon Studio
provides unique and powerful features to help you ensure that rules are complete and
consistent.
Discover Ways to Improve Your Rules
The AI Assistant can help identify potential improvements in your
rulesheets, such as redundancies or inefficiencies. Try prompts like:
“How could this rulesheet be improved?”
“What other conditions might this rulesheet need to cover?”
Check for conflicts
Begin by checking for conflicts in the rules:
Open the Rulesheet and select the Cargo.ers tab.
Select Rulesheet > Logical Analysis > Check for
Conflicts.
If one or more columns contain conflicting rules, Corticon detects
them and highlights the columns in pink. The total number of conflicts is also
displayed in a dialog box.
Click OK to dismiss the dialog box.
Resolve conflicts
Sometimes, conflicts may not be immediately visible just by looking at
the rules because each rule is actually made up of sub-rules (rules without dashes) and
it is the sub-rules that are in conflict. To see these sub-rules, select Rulesheet
> Rule Column(s) > Expand Rules.
It helps you pinpoint the source of the conflict.
Rule 1 is expanded into three columns, 1.1, 1.2, and 1.3, and rule 2 is
expanded into three columns 2.1, 2.2, and 2.3. The expansion shows all of the logical
possibilities for each rule. Rule 1 states Cargo weighing <= 20,000 kilos, regardless
of volume, must be packaged in a standard container. Corticon Studio recognizes three
possible ranges for Cargo.volume (<=30, >30, and null), as seen in the expanded
rules.
With the rules expanded, the source of the conflict becomes obvious.
Scenarios with Cargo.weight <=20000 and Cargo.volume > 30 are in conflict, because
they define mutually exclusive actions (rule 1.2 assigns a standard container while rule
2.1 assigns an oversize container). To get your rules right, this conflict must be
addressed.
To resolve the conflict, you can either change your original rules, or
decide that one rule should override the other. To implement the override:
Collapse your rules back to the original state by selecting
Rulesheet > Rule Column(s) > Collapse Rules.
Override Rule 1 with Rule 2. In the Overrides cell in Rule 2,
select the column number of the rule that you want Rule 2 to override—in this case,
Rule 1.
Check for conflicts again by selecting Rulesheet > Logical
Analysis > Check for Conflicts. You see that the conflict has been
resolved. With the override, Rule 2 now means “Use oversized containers when volume
is >30, even when weight is <=20000.”
Dismiss the dialog box by clicking OK.
Save your Rulesheet by clicking on the Save icon on the toolbar or by
choosing File>Save.
Check for completeness
Conflict is one form of logical error. Another form is incompleteness in
the logic.
To see if the rules are complete, select Rulesheet > Logical
Analysis > Check for Completeness.
A message window opens informing you that the rules are incomplete. You
missed some scenarios.
The completeness checking algorithm calculates the set of all possible
combinations of values in all conditions. The algorithm then compares this set of
possible combinations to those already specified in the Rulesheet and automatically
inserts missing combinations of conditions as new columns. These new columns are
highlighted in green.
In this case, Corticon Studio has added a new rule in column 3—where the
cargo weighs > 20000 and the cargo volume is less than or equal to 30. The
completeness check adds condition values, but does not choose actions—leaving it to the
rule modeler.
Click OK to dismiss the window.
Resolve completeness errors
Add a new rule statement for Rule 3: Cargo weighing > 20,000
kilos, with volume <= 30 cubic meters, must be packaged in a heavyweight
container.
Note: Do not forget to link the
rule statement with the corresponding column.
Define an action in rule cell 3A. In this case, select
heavyweight as the container option.
Post an Info message to the Cargo entity as you did for the first
two rules in the Rulesheet.
Select Rulesheet > Logical Analysis > Clear Analysis
Results to remove the highlighting in Rule 3. After you clear analysis results, your Rulesheet looks like this.
Run the completeness check again. The dialog box should indicate
that the Rulesheet is complete.
Click OK in the dialog box.
Note: Although checking for
completeness can identify rules that you should include in your Decision Service,
there may be situations where you do not want a newly-added rule. In this case,
you can just delete the rule.
Save your Rulesheet.
Check for logical loops
A third form of logical error is circular logic or loops. To check for
this, select Rulesheet > Logical Analysis > Check for Logical Loops.
You see the following result.
This Rulesheet is very simple and contains no logical loops. Click
OK in the dialog box to dismiss it.
Note: While unintended logical loops should be
fixed, sometimes logical loops are a useful technique for implementing rule logic
that requires recursive reasoning.