Re: JESS: Can't use funcalls in backchained patterns?
"Ernest Friedman-Hill" <[email protected]>
| Newsgroups | gmane.comp.java.jess |
|---|---|
| Message-ID | <[email protected]> |
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
> [email protected]'
> in the BODY of a message to [email protected], NOT to the list
> (use your own address!) List problems? Notify [email protected]
> .
> --------------------------------------------------------------------
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012 [email protected]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
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].
--------------------------------------------------------------------