Ok, now I've got enough code to try out the (new and improved) Alpha Network.
I decided to try a small and simple Alpha Network first. It consists of 4 constant tests (5 if you count the type test). The network is very straight forward, it's just a chain of 4 AlphaNodes with an ObjectTypeNode first and an AlphaMemory for each AlphaNode.
O (Foo) -> A1 (a == 2) -+-> AM1I use two classes (Foo and Bar) which are basically ValueObjects holding 4 attributes named a, b, c and d.
+-> A2 (b == 3) -+-> AM2
+-> A3 (c == 1) -+-> AM3
+-> A4 (d == 4) --> AM4
The code I use to calculate the time each test takes is very simple:
>>> start = datetime.datetime.now()Maybe, it's too simple, I don't know. Other activity on my laptop interfer from time to time but I've run the tests a few times now and the numbers below are sort of typical.
>>> stop = datetime.datetime.now()
To try out the network I generate a lot of Foo instances by assigning all combinations of 4 values out of [1, 2, 3, .., 15, 16] to a, b, c and d. That gives me a total of 43680 Foo objects.
It takes 0.84 seconds to generate them and 1.33 seconds to filter them through the network. 2730 matches 1 constant test, 182 matches 2 constant tests, 13 matches 3 constant tests and 1 instance matches all 4 constant tests.
Adding another type of Object (Bar) changes things a bit, but not too much. If I generate a Bar instance for every Foo instance I get 77361 objects and it takes 2.14 seconds to handle all of them. 2730 matches 1 constant test, 182 matches 2 constant tests, 13 matches 3 constant tests and 1 matches 4 constant tests.
Generating only Bar objects (43680 of them) gives me 0 matches but it still takes 1.12 seconds to go through them. Hmm... more on this later.