Hi Steffen, If you wanted to stay just within the rule system, it seems to me you could have a network of rules rather than a single rule compute the result.
The first layer would match a fixed <k> accounts and assert the sum of that set. To make it simple, let's say <k>=2 so you have a rule that matches two accounts and sums them. Then you have a second layer to match two first-level sums and sum those to create a second-level sum etc. This approach should let you sum up to k^n accounts using n rules and the rules don't vary as working memory changes. I can't write this in Jess as I'm new to Jess and clearly handling the cases where you have less than <k> elements to sum together at a given layer needs a little thought but I think it's a fairly general approach. It can't handle an infinite number of accounts, but if you chose e.g. k=10 and n=6 you should be able to sum up to a million accounts with about 6 rules. The key thing is that the final sum still logically depends on the original account values, it just doesn't do it in one step. Doug -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steffen Luypaert Sent: Thursday, May 06, 2004 11:19 AM To: [EMAIL PROTECTED] Subject: JESS: Re: logical and groups of patterns > My > problem is to make the sum fact logically dependent of all account > facts used to compute it. If an old account fact is modified or > retracted, or a new one is asserted, I want the sum fact to be > retracted automatically. > > I presume there isn't a good solution to this, as this is a typical > problem for rulebased systems, but I could be wrong. > I think I can answer this myself now. What I want is a rule which number of patterns depends on the working memory. The working memory changes over time, so the representation of the rule in the Rete network will also have to change over time. The Rete network has only join nodes with a specified number of inputs. So rules with an unspecified number of inputs can't be represented in it. Building rules on the fly is the only solution. At least, in the current version of Jess. Maybe this process could be automated in a way. This is the last time I'm replying my own question! I should have thought this through before asking.. Regards, Steffen. -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] -------------------------------------------------------------------- -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------