Stop rete activations

84 views Asked by At

I have a rule that retracts thousands of facts when a certain condition is met. This rule sits in a module that contains two other rules that use "not" statements. My questions are:

  1. Does the rete network get recalculated every time the first rule retracts a fact?
  2. It is because of the "not" statements in the other two rules or would that happen anyway?
  3. Is there a way to stop recomputing activations until the first rule has no more facts to retract?

Thanks!

2

There are 2 answers

0
laune On

Precise answers aren't possible without knowing the patterns in the rules that use the type of the retracted facts.

Clearly, if Fact is that type and the rules #2 and #3 contain just

not Fact(...constraints...)

nothing tremendous should happen until the last of those Fact facts (that meets the constraints, if any) is removed from working memory: then an additional node may have to be created, depending on what else is that not CE); this may continue depending on what is after the not CE and result in terminal nodes, i.e., activations.

If a pattern like

Fact(...constraints...)

is in any of these rules, retracting a Fact (that meets these constraints, if any) causes some immediate action on any pending activations and removal of nodes in the network, provided it has been included before.

There is not much you can do to avoid happenings in the Rete network.

That said, the necessity of having to retract thousands of facts is rather scary. How many remain? It might be cheaper to pick out the select few and start over in an entirely new Rete. Or use a design pattern that does not expose all of those thousands at once to the Engine. Or something else.

0
Mark Proctor On

We've written a lazy algorithm, that avoids re-producing partial matches and activations, until the rule is potentially ready to fire. Being lazy you can use salience to delay when rule is evaluated. http://blog.athico.com/2013/11/rip-rete-time-to-get-phreaky.html