I think Greg Biegel wrote:
> And I have the following rule: > > (defrule InUse-BottomLeft > ?ac <- (active-context InUse) > ?cu <- (context-updated true) > (and > (and > (LoadCellSensor1_MassEvent_Bean (sensorID 1)) > (LoadCellSensor1_MassEvent_Bean (mass ?LoadCellSensor1_MassEvent&:(> > ?LoadCellSensor1_MassEvent ?*averageweight*))) > ) ... Two comments. First, regarding writing rules efficiently: you can, and most certainly should, match multiple slots in a single pattern. Using multiple patterns this way consumes more memory and does more computational work (and of course, if there were more than one LoadCellSensor1_MassEvent_Bean object, then the above would match all the possible permutations of matches based only on single-slot matching, which I'm sure you wouldn't want. Also, there's an implicit "and" around the whole LHS of a rule, and furthermore, an "and" inside an "and" is just extra work for the parser, as (and (and X Y) (and P Q)) is precisely equivalent in meaning to (and X Y P Q). So drop all the "and"s, combine the multiple patterns, and just write: (defrule InUse-BottomLeft ?ac <- (active-context InUse) ?cu <- (context-updated true) (LoadCellSensor1_MassEvent_Bean (sensorID 1) (mass ?mass1&:(> ?mass1 ?*averageweight*))) I picked a shorter variable name for you, too. Secondly, pattern-matching is driven by fact assertions, modifications, and deletions; as you observed, if you match with a global variable, the matches won't be updated until the facts are modified. From the end of section 2.8.2 of the manual: "If you match to a defglobal with a pattern like (foo ?*x*), the match will only consider the value of the defglobal when the fact is asserted. Subsequent changes to the defglobal's value will not invalidate the match - i.e., the match does not reflect the current value of the defglobal, but only the value at the time the matching fact was asserted." If you need matches to respond to changes in the average weight in real time, then simply store the average weight in a fact (or a dynamic definstance) rather than in a defglobal. --------------------------------------------------------- Ernest Friedman-Hill Science and Engineering PSEs 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] --------------------------------------------------------------------