The (watch), (agenda), and (facts) commands are very useful in trying to understand these kinds of things.
All that's happening here is that your rule "end-of-execution" calls "(halt)" before the other rules have a chance to fire. Under Jess's default conflict resolution strategy, the most recent rule to be activated is the next one to fire. Since the counting rule generates a new activation on each cycle, it fires repeatedly until the end-of-execution rule stops the looping. But then it calls (halt), so the other rules (which are activated -- see the output of (agenda)) never get a chance to fire. Note that you would get entirely different behavior if the (assert (counter 0)) was first instead of last, since them the counter rule would be activated first,a nd thus fire last. See the documentation for the (set-strategy) command, as well as for the other commands mentioned. I think Anderson de Rezende Rocha wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > > Hi all, I made a simple example to training in Jess and something > interesting has occurred. See below... > > =================== > (deftemplate id(slot name)(slot lastname)) > > (defrule regra-01 > ?fact <- (id(name mary)(lastname dechamps)) > => > (store name "dechamps, mary") > (retract ?fact) > (assert (id(name dechamps)(lastname mary))) > ... > ) > > (defrule regra-02 > ?fact <- (id(name ?n)(lastname ?ln)) > => > (retract ?fact) > (assert (id(name ?ln)(lastname ?n))) > ... > ) > > (defrule increment > ?cont <- (counter ?c&~10) > => > (bind ?new-c (+ ?c 1)) > (assert (counter ?new-c)) > (printout t "counter now is " ?new-c crlf) > (retract ?cont) > ) > > (defrule end_of_execution > (counter 10) > => > (halt) > ) > > (assert (id(name mary)(lastname dechamps))) > (assert (id(name desireh)(lastname fronchaw))) > (assert (id(name carmen)(lastname morris))) > (assert (counter 0)) > > (run) > > =================== > > The problem is: > Only [increment] and [end-of-execution] fires. The rule1 and rule2 don_t > fires any time. What happens? What I forgot? > > Thanks for help! > > > --------------------------------------------------------------------- > 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 Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 Org. 8920, MS 9012 [EMAIL PROTECTED] PO Box 969 http://herzberg.ca.sandia.gov Livermore, CA 94550 --------------------------------------------------------------------- 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] ---------------------------------------------------------------------
