Why wouldn't a simple

(defrule r
   (k (when ?w))
=>
   (schedule-timer-alert (+ ?w 3000))
)

be sufficient?

-W

On 21 July 2010 16:00, Ernest Friedman-Hill <ejfr...@sandia.gov> wrote:
> This is quite clever, but as you found, this won't work due to limitations
> in the implementation. But you could skip backward chaining altogether and
> just do something like
>
> (defrule r
>   (k (when ?w&:(progn (schedule-time-alert (+ ?w 3000)) TRUE)))
>   (time (when =(+ ?w 3000)))   ; a time fact 3 seconds after k is expected
>   =>
>   (printout t "3 seconds after k!" crlf) )
>
> You would not need the progn/TRUE if schedule-time-alert returned a true
> value.
>
>
> On Jul 21, 2010, at 5:59 AM, Henrique Lopes Cardoso wrote:
>
>> Hi,
>>
>> I was trying to make a rule that fires a few seconds after a fact is
>> asserted. Here is my experiment:
>>
>> (deftemplate time (slot when))
>> (do-backward-chaining time)
>>
>> (defrule do-time
>>   (need-time (when ?w))
>>   =>
>>   (schedule-time-alert ?w) )
>>
>> (deftemplate k
>>   (slot when (default-dynamic (call System currentTimeMillis))) )
>>
>> (defrule r
>>   (k (when ?w))
>>   (time (when =(+ ?w 3000)))   ; a time fact 3 seconds after k is expected
>>   =>
>>   (printout t "3 seconds after k!" crlf) )
>>
>> Function schedule-time-alert is implemented in Java and is supposed to
>> add a fact at the indicated time.
>> While this approach looks pretty clean to me, it does not even compile.
>> I am getting a "Can't use funcalls in backchained patterns when", in
>> rule r. This does not seem to be documented (at least I did not find it).
>>
>> There is a work arround described in
>> http://www.jessrules.com/jess/FAQ.shtml#Q9
>> That approach has been suggested in previous e-mail threads, I have
>> noticed.
>> But while it seems to work, it is also much more CPU-intensive, as a
>> number of time events (idle facts in faq Q9) would be added for no reason.
>>
>> Any thoughts?
>>
>> Thanks.
>>
>> Henrique
>>
>>
>>
>> --------------------------------------------------------------------
>> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
>> in the BODY of a message to majord...@sandia.gov, NOT to the list
>> (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
>> --------------------------------------------------------------------
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences          Phone: (925) 294-2154
> Sandia National Labs
> PO Box 969, MS 9012                            ejfr...@sandia.gov
> Livermore, CA 94550                             http://www.jessrules.com
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
> in the BODY of a message to majord...@sandia.gov, NOT to the list
> (use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
> --------------------------------------------------------------------
>
>




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------

Reply via email to