Conditions as Processing Threshold

The default behavior for a rulesheet is to try all of the rules against all of the instances that are referred to in the conditions. If there are multiple instances of entities or aliases then Corticon will automatically try all combinations of those entities or aliases (it’s this power that makes it possible to solve a Sudoku, or Magic Square problem with a single rule!)

 

In nearly all cases this is the behavior that you want. Corticon generally does the right thing and you don’t have to think about it.

 

However sometimes you may be faced with a situation where you don’t want all the instances processed or you don’t want all the rules processed.Perhaps you want to find only the first instance out of a set of thousands that meets certain conditions

 

CAPT is a mechanism that enables you to terminate processing of a rulesheet once a rule has fired without needing to evaluate the remaining instances. If you want to terminate the processing of other rules on a rulesheet once one of the rules has fired then that is done by adding an explicit “stop” condition to the rule. These two techniques can be used in combination.

In this paper we’ll look at several scenarios

 

Single Rule

  • 0 no stop, no CaPT
  • 1 stop condition, no CaPT
  • 2 stop condition,  CaPT
  • 3 no stop condition, CaPT

Multiple Rules

  • 4 local stop condition, CaPT
  • 5 global stop condition, no CaPT
  • 6 global stop condition, CaPT

 

A local stop condition is one that tests an attribute of the instances being processed

A global stop condition is one that tests an independent attribute

General Functioning of CaPT

This feature only works at a single-rule level.  It doesn’t work across multiple rules.  After a rule fires against one alias binding and potentially updates working memory, but before moving on to evaluate the rule against the next alias binding, the engine performs a check against the current alias binding:  If all the conditions that held true before the rule fired no longer hold afterwards then we’ve reached the “processing threshold” for this rule and we stop processing.  Otherwise, we keep going. 

Consider the following scenarios:

 

Scenario 0 – No CaPT and no stop condition. 

Note how the rule fires against both Thing[2] and Thing[3] as expected.

  

Scenario 1 – No CaPT but add stop condition. 

Note how the stop condition doesn’t prevent rule 1 from firing against both Thing[2] and Thing[3].

  

Scenario 2 – Both CaPT and stop condition. 

Note how rule 1 now only fires against Thing[2] and not against Thing[3].

 

Scenario 3 – No stop condition but with CaPT

Note how the CaPT doesn’t prevent the rule from firing against both Thing[2] and Thing[3].  This is because the lack of stop condition causes the “Processing Threshold” to never be triggered. Basically nothing that is used in the condition has changed.

  

Scenario 4 Instance Stop condition and CaPT

Finds the FIRST small and the FIRST large thing

  

Scenario 5 Global Stop Condition but no CaPT

Finds ALL the small (if there are any) OR ALL the large but not both.

 

Scenario 6 CaPT and Global Stop Condition

Finds only ONE instance that is large or small

Summary

Here are the rules about CaPT expressed as a decision table

 

Local means that the stop condition is an attribute of the instance being tested

Global means that the stop condition is a single global value

Download

Download PDF version.