Deciding on an execution mode

You can choose a different execution mode than the default one and provide selection criteria.

You can choose an execution mode for each rule task of a ruleflow. By default, a rule task is assigned the Fastpath execution mode when you create it. To achieve optimal performance, you might need to choose another execution mode that is better adapted for the rules in a particular rule task.

Here is a brief table that shows which execution mode to select in what cases.

Table 1. Quick view of execution mode selection
Choose this mode: In this case:
RetePlus
  • All included semantically.
  • Stateful application.
  • Rule chaining.
  • Useful in the case of many objects and limited changes.
Sequential
  • Covers most cases.
  • Many rules, few objects. Has limitations. Use with homogeneous rules.
  • Highly efficient in multi-threaded environment.

Fastpath

  • The default mode for ruleflow tasks.
  • Rules implementing a decision structure, many objects.
  • Highly efficient in multi-threaded environment.

To determine which execution mode to use on a rule task, you must analyze the structure of the rules in the rule task and what type of processing they do.

Note:

You cannot use the Fastpath or Sequential algorithm when the rules have actions that create, modify, or remove objects that are matched in the conditions of the rules.

To make the best choice, answer the following questions:

What type of application do your rules implement?

Depending on the purpose of the business logic that is defined in a rule task, you choose a different execution mode.

Compliance and validation

Loosely interrelated rules that check a set of conditions to yield a go/no go or similar constrained result. Compliance business rule applications are often used in underwriting, fraud detection, data validation, and form validation. Business rules in such applications generally have a yes or no result and provide some explanation on the decision.

For compliance applications, preferably use the sequential or Fastpath execution modes.

Computation

Strongly interrelated rules that compute metrics for a complex object model. Computation business rule applications are often used for scoring and rating, contracts, and allocation. Business rules in such applications carry out different calculations on an object that is responsible for providing a final value (or rating).

For such applications, preferably use the RetePlus execution mode if inference is necessary, or use the Fastpath execution mode.

Correlation

Strongly interrelated rules that correlate information from a set of objects to compute some complex metrics. Correlation business rule applications are often used for billing. Business rules in such applications insert information.

For correlation applications, preferably use the RetePlus execution mode if inference is necessary, or use the Fastpath execution mode.

Stateful session

Strongly interrelated rules that correlate events in a stateful engine session. Stateful applications are often used in alarm filtering and correlation, GUI customization, and web page navigation.

For such applications, preferably use the RetePlus execution mode without a ruleflow.

What types of objects do your rules use?

Depending of the types of objects acted upon by your rules, you choose a different execution mode.

Homogeneous or heterogeneous rules?

Bindings are heterogeneous when rules do not operate on the same classes. When bindings are heterogeneous, the rules might have condition parts of different heights. For example:

Rule Condition
Rule1 ... when{A();B()} ...
Rule2 ... when{A()} ...
Rule3 ... when{B()} ...

If your rules define heterogeneous bindings, use the RetePlus or Fastpath execution mode.

Bindings are homogeneous when all the rules operate on the same class (the same kind and number of objects), but introduce different tests, for example:

Rule Condition
Rule1 ... when{Person(age == 12);} ...
Rule2 ... when{Person(age > 20);} ...

If your rules define homogeneous bindings, use the sequential execution mode.

What is the effect of rule actions?

Depending of the types of effects generated by your rules on execution, you choose a different execution mode.

Modifications to the working memory

If rule actions manipulate working memory objects and use of the IRL keywords insert, retract, or update, use the RetePlus execution mode. Because these keywords entail modifications to the working memory, the rule engine reevaluates subsequent rules. If you use another execution mode, the rule engine does not reevaluate subsequent rules after the modifications.

Rule chaining

When rule actions cause modifications in the working memory or in the parameters, and when they do pattern matching on objects that have no relationship, like people and hobbies, there is chaining between your rules. This process is also known as inference.

For example:

SILVER LEVEL CUSTOMER, GREATER THAN $5000 purchase
promote to GOLD LEVEL
GOLD LEVEL CUSTOMER, GREATER THAN $5000 purchase
apply 25% discount

You can see there is chaining between these two rules because they do pattern matching on two different objects, customer and purchase, and that the second one modifies the level attribute of the customer object.

Basically, if you know your rule actions cause the execution of other rules, use the RetePlus execution mode.

What sort of tests do you find in rule conditions?

Depending on the type of conditions used in your rules, you choose a different execution mode.

Tests that require a working memory

If rule conditions test the existence of an object or gather items of a collection directly in working memory, with the IRL keywords exists or collect, without in or from constructs, use the RetePlus or Fastpath execution modes.

Regular pattern for tests

If the tests in rule conditions have the same pattern and order, such as the tests that are generated from decision tables, use the Fastpath execution mode.

If the order of tests in rule conditions is not regular, use the RetePlus or sequential execution modes.

What priorities have you set on your rules?

Depending on the priorities you have set on the rules, you choose a different execution mode.

  • If you have set static priorities, you can use any algorithm.

  • If you set dynamic priorities, that is, priorities that are defined as an expression, you must use the RetePlus execution mode.

Summary

You can use the following table as a reference to make your decision when you choose an execution mode for a rule task. The number of stars indicates the degree of performance.

Table 2. Choosing an execution mode
In your rule task: RetePlus Sequential Fastpath
Compliance and validation application Yes YesYesYes YesYesYes
Computation application with inference YesYesYes No No
Computation application without inference Yes Yes YesYesYes
Correlation application with inference YesYesYes No No
Correlation application without inference Yes Yes YesYesYes
Working memory objects YesYesYes YesYesYes YesYesYes
Rule chaining YesYesYes No No
Tests on existence or collection items directly in working memory YesYesYes No YesYesYes
Shared test patterns YesYes Yes YesYesYes
Heterogeneous bindings YesYesYes No YesYesYes
Dynamic priorities YesYesYes No No
Runtime rule selection that selects a few rules among many YesYesYes YesYesYes

Decision engine: YesYes

Numerous rules Yes YesYesYes YesYesYes