Examples

For example, suppose two rules declare CustName and SupportLevel. You assign the same rule function to both rules. The function returns 3.0 for Gold support level, 2.0 for Silver, and 1.0 for Bronze. As a result, among rule tuples with priority 1, those for customers with Gold support execute before those for customers with Silver support, which execute before those for customers with Bronze support.

Below is an example showing how rule priority and ranking determine the sort order. Suppose you assign the same rule function for ranking rules 1, 2, and 3. At run time these are some rule tuples to be sorted in the agenda for an RTC:

Rule 1 (Tuple X) Priority: 5 Rank: 10.0
Rule 2 (Tuple A, B) Priority: 1 Rank: 1.0
Rule 2 (Tuple A, C) Priority: 1 Rank: -1.0
Rule 2 (Tuple A, D) Priority: 1 Rank: -2.0
Rule 3 (Tuple A) Priority: 4 Rank: 0.0

They are sorted and executed as follows. (This could change during a conflict resolution cycle depending on the effect of rule actions.)

Rule 2 (Tuple A, B) Priority: 1 Rank: 1.0
Rule 2 (Tuple A, C) Priority: 1 Rank: -1.0
Rule 2 (Tuple A, D) Priority: 1 Rank: -2.0
Rule 3 (Tuple A) Priority: 4 Rank: 0.0
Rule 1 (Tuple X) Priority: 5 Rank: 10.0

Reverse Order Example

If you want the rule with the smallest return value to be ranked highest, multiply by negative one (-1.0) to reverse the size of the values. For example suppose you want rules that were asserted earlier to execute before those that were asserted later. The time values returned by three rules are 100, 150, and 300. Using -1.0 * time), they will be fired in the desired order: -100.0 (the largest value), then -150.0, then -300.0.