next up previous

5.4.10.1 The Salience Rule Property

The salience rule property allows the user to assign a priority to a rule. When multiple rules are in the agenda, the rule with the highest priority will fire first. The declared salience value should be an expression that evaluates to an an integer in the range 10000 to +10000. Salience expressions may freely reference global variables and other functions (however, you should avoid using functions with sideeffects). If unspecified, the salience value for a rule defaults to zero.

Example

(defrule test-1
   (declare (salience 99))
   (fire test-1)
   =>
   (printout t "Rule test-1 firing." crlf))
(defrule test-2
   (declare (salience (+ ?*constraint-salience* 10)))
   (fire test-2)
   =>
   (printout t "Rule test-2 firing." crlf))

Salience values can be evaluated at one of three times: when a rule is defined, when a rule is activated, and every cycle of execution (the latter two situations are referred to as dynamic salience). By default, salience values are only evaluated when a rule is defined. The setsalienceevaluation command can be used to change this behavior. Note that each salience evaluation method encompasses the previous method (i.e. if saliences are evaluated every cycle, then they are also evaluated when rules are activated or defined).


next up previous