Instance Method

evaluate

Evaluates the rule system, executing the list of rules in its agenda.

Declaration

- (void)evaluate;

Discussion

When you call this method, the system considers each rule in the agenda list in order. The agenda contains rules in the order of their salience values, or for rules with the same salience, the order in which they were added to the system.

For each rule, the system evaluates the rule’s predicate by calling its evaluatePredicateWithSystem: method. The rule’s predicate can evaluate the system’s state dictionary or call the methods listed in Drawing Conclusions from Facts to examine the set of facts claimed by the system.

If a rule is satisfied (that is, the evaluatePredicateWithSystem: method returns YES), the system moves that rule from the agenda list to the executed list and performs the rule’s action by calling the rule’s performActionWithSystem: method. The rule’s action can alter the system’s state dictionary or call the methods listed in Asserting and Retracting Facts to modify the set of facts claimed by the system.

Because other rules might depend on the set of facts, asserting or retracting facts causes the system to reevaluate itself—a single call to the evaluate method can cause the system to consider its set of rules several times. After your call this method returns, the agenda list contains only rules whose actions have not been triggered, the executed list contains rules that have executed, and the state dictionary and facts array together represent the complete set of conclusions drawn by the rule system.

See Also

Evaluating a Rule System

agenda

The list of rules to be considered when evaluating the system.

executed

The list of rules whose actions have been performed during evaluation of the system.

- reset

Returns the rule system to its original agenda and clears all facts.