About the Rule Compiler II

Today I fixed some minor bugs in the Rule Compiler and the activation methods in rete.py.

It still doesn't compile Rules to an optimal Rete Network but it seems to work (the right Tokens end up in the Production Nodes).

I'm also preparing to run some more complex tests. I'm really hoping to be able to run Manners soon, but there's still some stuff to be done before that. Among other things I'm rewriting things from the CLIPS manuals to make sure that everything (from a user perspective) appears to work as it's supposed to. Once that's done I'm really looking forward to see how much tweaking can be done behind the scenes and also to see how much of a difference the Pypy project's bags of tricks and magic can speed things up.

Here's the Rete Network with two more Rules added:

>>> import pyRete
>>> class Foo(pyRete.Fact):
... def __init__(self, n, p = 1, q = 1):
... self.n = n
... self.p = p
... self.q = q

>>> @pyRete.Rule
... def rule1(foo1 = Foo):
... if foo1.n == 1:
... pass

>>> @pyRete.Rule
... def rule2(foo1 = Foo):
... if foo1.n == 1 and foo1.p == 1:
... pass

>>> @pyRete.Rule
... def rule3(foo1 = Foo, foo2 = Foo):
... if foo1.n > 0 and foo2.n > 1 and foo1.n > foo2.n:
... pass

>>> @pyRete.Rule
... def rule4(foo1 = Foo, foo2 = Foo):
... if foo1.n > foo2.n:
... pass

>>> ruleengine = pyRete.RuleEngine(None)
>>> ruleengine.addRules([rule1, rule2, rule3, rule4])

>>> ruleengine.showReteNetwork()

The Production Nodes' (white) layout is a bit strange, the order is: rule1, rule3, rule4 and rule2.

Inga kommentarer: