Now that we have finished modeling our rules, we should analyze our rules for logical errors. Often, initial business rule specifications are ambiguous and incomplete. By ambiguous, we mean that the rules are conflicting under certain scenarios. By incomplete, we mean that the rules fail to address all possible scenarios.

Before we automate our rules, it is critical to eliminate logical errors in order to ensure that our decision service provides correct, consistent results. Corticon Studio provides unique and powerful features to help you ensure that rules are complete and consistent.

Check for conflicts

Let’s begin by checking for conflicts in our rules:

  1. Ensure that the Rulesheet is open and that the Cargo.ers tab is selected. media/image28.png
  2. Select Rulesheet > Logical Analysis > Check for Conflicts.

    media/image30.png

If Corticon Studio detects conflicts, columns containing conflicting rules are shaded in pink. This indicates that one or more conflicts exist between the shaded rules. The total number of conflicts is also displayed in a dialog box. Click OK to dismiss the dialog box.


media/image31.png

Resolve conflicts

Sometimes, conflicts may not be immediately visible just by looking at the rules. This is 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.



This helps you pinpoint the source of the conflict.

media/image33.png

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 that there are three possible ranges for Cargo.volume (<=30, >30, and null), which we see 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, since 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. Let’s implement the override:

  1. Collapse your rules back to the original state by selecting Rulesheet > Rule Column(s) > Collapse Rules.
  2. 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.
    media/image34.png
  3. Check for conflicts again by selecting Rulesheet > Logical Analysis > Check for Conflicts. You will 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 <=20,000.”

Dismiss the dialog box by clicking OK. Save your Rulesheet. Click on the Save icon on the toolbar or choose File>Save.

Check for completeness

Conflict is one form of logical error. Another form is incompleteness in our logic.

To see if our rules are complete, select Rulesheet > Logical Analysis > Check for Completeness.


media/image35.png

A message window opens informing us that the rules are incomplete. We missed some scenarios.


media/image36.png

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 shaded 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—that is left to the rule modeler.

Click OK to dismiss the window.

Resolve completeness errors

  1. We begin by adding 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: Don’t forget to link the rule statement with the corresponding column.
    media/image37.png
  2. Define an action in rule cell 3A. In this case, select “heavyweight” as the container option.
    media/image38.png
  3. Post an Info message to the Cargo entity as we did for the first two rules in the Rulesheet.
    media/image39.png
  4. Select Rulesheet > Logical Analysis > Clear Analysis Results. This removes the highlighting in Rule 3.

    media/image40.png
    After you clear analysis results, your Rulesheet will look like this.
    media/image41.png
  5. 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 don’t 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.


media/image42.png

You see the following result.

media/image43.png

This is a very simple Rulesheet 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.