Hey,

I'm having trouble understanding why reordering 'defrule' statements in a
Jess script changes how the program runs.

Specifically, I've created a UserFunction timer that asserts a
'temporal-event' fact every second (source attached).  Then I have a simple
Jess script (also attached) that loads and executes the UserFunction, and
then defines 3 debugging rules.  These rules do a printout at each second,
quarter-minute and minute (there is also a rule to retract old facts).

My problem is that the seconds rule always fires, while quarter-minute and
minute rules are sporadic (sometimes they fire sometimes not).  If I simply
re-order the rules, putting the minute rule first, the quarter-minute rule
next and the second rule last, things seem to work fine.

Now, if I understood why, I'd be in pretty good shape. ;)

Any suggestions?

-Mitch

P.S. 'ctm' is for CurrentTimeMillis.  It's the only way I could find to keep
rules from firing more than once, i.e. "only fire if this fact has the
lowest ctm in working memory" and to fire in the proper order should
multiple temporal-event facts be asserted between (runs).

Attachment: MyTimer.java
Description: Binary data

Attachment: MyTimerBad.clp
Description: Binary data

Reply via email to