Show TOC

Background documentationRetract Action Locate this document in the navigation structure

 

Retract is an action type used to withdraw an earlier asserted object from the engine (either passed as a part of the invokeRuleset method or as a result of firing the Assert action), which has been used in the condition of any of the rule in a ruleset.

The retract action does not affect the list returned by the invokeRuleset method

The outcome of a Retract action is that the engine discards any inferences caused by the object. A rule that was satisfied earlier by that object is removed from the firing queue. But, if a rule was satisfied and the actions fired, those actions cannot be undone.

Note Note

Firing queue represents a collection of actions of all satisfied rules that are to be fired by the rule engine. When a rule is satisfied, the engine creates an entity which represents all the actions for this rule. This entity is then added to the firing queue at the appropriate place depending on the rule's priority. The engine then retrieves each entity from the firing queue and fires the actions in that entry.

End of the note.
Syntax

Retract :: object to be retracted

Example

If

Solution is not OK

Then

Retract :: solution

Typical Uses

Optimization, best match/first match and solutions are asserted initially or created and introduced as a part of assert separation. In this case, you might want to retract the unfit ones and clear the clutter and speed up processing.

Example Example

If

Solution is not OK

Then

Retract :: solution

In this example, the second action would usually be to assert the next proposed solution object.

Sometimes, an object satisfies many rules. Of these rules, there may be an exception rule, which if true, should prevent other rules from being fired. In this case, you might want to retract that object. Retracting an object results in rules which might have been satisfied to be discarded. This can be handled in other ways too, defining a mutual exclusion rule may be an option. However, in some cases, using the Retract action may be easier.

End of the example.