skip to main content
Rule Dependencies
A rule’s dependencies are all the slots that the rule’s logic referenced the last time the rule fired during the current timestep. These are the slots on which the rule’s outcome depends. As a rule’s logic is executed, the rule processor keeps track of all slots referenced in the logic. In practice, any slot whose value at the current timestep is used during a rule firing is automatically added to the dependency list for that rule.
If any of the values of the dependencies subsequently change during the rest of the timestep, the rule must refire. When it refires, the RHS may evaluate to a different value — resulting in a different slot assignments—and perhaps a different outcome, than during its previous firing.
 
Rule dependencies
A rule’s dependencies is a list of dependent slots—slots that the rule referenced the last time it fired during the current timestep. These are the slots upon which the outcome of the rule execution depended. A new value in a dependent slot causes the rule to be refired.
The dependency list is generated anew each time a rule fires.
 
Example 2.2  Rule firing
Consider the following rule:
Object.SlotToBeAssigned = IF (Object.SlotA > Object.SlotB) THEN
IF (Object.SlotA > Object.SlotC) THEN
Object.SlotA
1. The first time the rule fires, the slot values are as follows:
SlotA = 30
SlotB = 20
SlotC = 10
2. The rule firing starts by clearing the dependency list.
3. The first IF evaluates to true, and both SlotA and SlotB are added to the dependency list. The second IF also evaluates to true, and SlotC is added to the dependency list.
4. The rule assigns 30 to the SlotToBeAssigned, finishes successfully, and the dependency list is now: SlotA, SlotB and SlotC.
5. Now assume that during the ensuing dispatching, SlotB is recalculated to be 40, requiring that the rule fire again.
6. The second time the rule fires, the slot values are as follows:
SlotA = 30
SlotB = 40
SlotC = 10
7. The rule firing starts by clearing the dependency list.
8. The first IF evaluates to false, and both SlotA and SlotB are added to the dependency list.
9. There is no ELSE clause, so there is no RHS value. The rule finished ineffectually, and the dependency list is now: SlotA and SlotB.
10. Now assume that during the ensuing dispatch, SlotC is recalculated to be 50.
11. The rule is not fired again because SlotC is not a dependency; the result of firing the rule again would not be different.
12. When a rule terminates early because one of the slots it references is a NaN, that slot is put on the rule’s dependency list. This ensures that the rule will refire whenever the slot value becomes known. If the slot does not get a value during the current timestep, the rule is not put back on the agenda, and it will not refire at the current timestep.
Revised: 01/05/2024