Sorry, One more thing,

Is there anyway of setting a rule to check after all the facts have been
asserted???

A rule with a low salience will fire according to whats on the agenda at
the current time. I require to check whether or not, after all the facts
have been asserted, whether or not a certain slot value has a particular
count?  ( a bit like a "finally" clause for a rule )? The problem I am
having is that, I need to check whether a count is less than 50 at the
end of execution. This rule keeps adding an activation record all the
way up to 50 as more facts are asserted. 

Cheers,

Chirag

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: 04 August 2004 15:13
To: [EMAIL PROTECTED]
Subject: Re: JESS: Questions

I think Mehta, Chirag (IT) wrote:
> Hello,
>  
> I have a few more questions. Hopefully, these aren't as simple as my 
> previous ones.
>  
> Firstly, is there a simple way of checking how many facts have a 
> particular slot value??

As you said, a query with count-query-results is one good way. The
upcoming Jess 7 has "accumulate" which would allow you to do the
counting on the LHS of a rule and have the RHS of the rule get the count
and be able to act on it.

>  
> Also, I need to check whether a particular slot value, of any already 
> activated fact, is less than the corresponding slot value of the 
> current fact? What would be the best way of implementing this? The 
> slot value that needs to be checked is calculated by another rule. I 
> think backward chaining maybe an option here but I'm sure how I would
use it.


In general, if you're thinking procedurally like this, then the answer
is usually to use a query. But a better answer is not to think
procedurally. If you want to do something with the fact that has the
lowest value in a given slot, then write a rule to match it and do that
something:

(defrule process-lowest-value
  (some-fact (some-slot ?v1))
  (not (some-fact (some-slot ?v2&:(< ?v2 ?v1))))
  =>
  (printout t ?v " is the lowest value." crlf))

The second pattern says "there's does not exist a some-fact where
some-slot contains a smaller value than ?v1."


---------------------------------------------------------
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]
-------------------------------------------------------------------- 
--------------------------------------------------------
 
NOTICE: If received in error, please destroy and notify sender.  Sender does not waive 
confidentiality or privilege, and use is prohibited. 
 

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to