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. |
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. |