On Sun, 2006-03-12 at 07:36 -0800, [EMAIL PROTECTED] wrote: > I think Dave Tapley wrote: > > ---------------------------------------- > > Is this a known issue or am I over looking something here? > > I just don't see how the (test) can return TRUE and the rule not fire. > > Pattern-matching is driven by working memory modifications (assert, > retract, modify) and proceeds from the top down in any one rule. A > "test" CE is evaluated only when the preceding pattern is > matched. Therefore the test in your oneSmall rule will be evaluated > only when a Cell fact is or asserted/modified. Presumably the Small > facts are all asserted after all the Cell facts, so at the time the > test is evaluated, there *are* no Small facts in working memory. > > Using test to run a query is a sort of end run around the normal > pattern-matching process; there are better ways to write this so that > you get the answer you want. One would be like this: > > (defrule oneSmall-good > ;; There is a cell > (Cell (r ?r) (c ?c)) > > ;; With a small value > (Small (r ?r) (c ?c) (v ?v)) > > ;; And no other different small value > (not (Small (r ?r) (c ?c) (v ~?v))) > => > (printout t ?r"x"?c " has 1 small number: " ?v crlf) > > You could also use "accumulate" to count the Small facts and match the > count; that would be convenient if you wanted to have exactly 27 > matches, for example. But using a query on a rule LHS should be an > absolute last resort. > > --------------------------------------------------------- > Ernest Friedman-Hill > Advanced Software Research Phone: (925) 294-2154 > Sandia National Labs FAX: (925) 294-2234 > PO Box 969, MS 9012 [EMAIL PROTECTED] > Livermore, CA 94550 http://herzberg.ca.sandia.gov > > -------------------------------------------------------------------- > 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] > -------------------------------------------------------------------- > > >
Thank you kindly Ernest. Cleared that one up and on to new problems :) -- Dave Tapley <[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] --------------------------------------------------------------------
