pyRete status

I haven't posted anything about pyRete for a while. Development hasn't stopped. It has just slowed down to really really slow. I'm sad to say that my rule compiler algorithm that is supposed to translate a Python compiler.AST to a (hopefully, at some point, optimized) Rete Network is far too complicated.

I'm on my third attempt of refactoring, things are going the right way, but it's moving very slowly ahead. Irritating slow. The main problem is still the Test nodes, I also need to implement Not and Exists but I haven't even started on them yet so God only knows what kind of trouble that will put me in.

I've gotten as far as actually constructing a "correct" Rete Network from, for example:

>>> @pyRete.Rule
... def foo(a = int, b = int):
... ab = a + b
... if ab == 9:
... pass
but it doesn't propagate facts correctly yet.

The thing is that, as a new fact object activates the Test Node it needs to generate all possible combinations of that object (bound to a variable name) and all other variable's possible values in order to evaluate the expression (in the example: a+b) and store the result in an AlphaMemory which can be used by an AlphaNode (to test: ab == 9).

I don't know if it is the best way, or even a good way, to enable expressions in a rule's LHS but it's one way of doing it and if I get it working at some point I might figure out a better way after testing, testing and testing.

2 kommentarer:

woolfel sa...

keep plugging away, you'll figure out a good way. after several months of beating your head, it will make you stronger. In my case, I look like a neanderthal now :) Oh wait, I looked like a neanderthal to begin with, so it wasn't RETE's fault.

Johan Lindberg sa...

Yeah, I know. It's always frustrating to find the point where my hubris meets reality. I had hoped to be running various tests by now, profiling the code and trying out improvements. Looks like that'll have to wait. The whole point of the exercise though is learning and if there's something I've gotten out of this Rete implementation business it's a better understanding of Rete, Rule engines and programming in general. So I can't really complain.