Hi all,
I was wondering if someone could help me to understand
how the agenda works, especially the activation
process.
I understand that all rules with the LHD matching a
fact are activated and put in the agenda which also
decides the order of execution. So why rules that on
the LHD are empty or (declare (salience -100)) get
activated at the beginning and fired only once. Why
those rules do not get reactivated in the agenda
again.
In my simple example I am trying to use the MAIN
module to redirect the assertion from module A and B
and vice versa. Why the rule call-loop in the MAIN
module is activated only at the beginning. Why the
agenda does not reactivate the rule in the MAIN
call-loop so that can fire again.
I know that I could add a pattern match on the LHD of
call-loop rule to make it run. But I am trying to
understand how jess behaves with rules missing the
LHD.
Thank in advance,
Giovanni
--------------------SOURCE CODE--------------------
(clear)
(reset)
(watch all)
;-------------MAIN--------------------------------
(deftemplate speech (multislot text))
(defrule call-loop
(declare (salience -100))
;;(speech ( text $?x))
=>
(printout t "*Salience Rule in main*" crlf)
(focus B A )
)
;------------- MODULE A----------------------------
(defmodule A)
(defrule R0-A
?fact <-(speech (text a))
=>
(printout t "*MODULE A*" crlf)
(assert (MAIN::speech ( text b)))
(retract ?fact))
;-------------MODULE B-----------------------------
(defmodule B)
(defrule R0-B
?fact <-(speech (text b))
=>
(printout t "*MODULE B*"crlf)
(assert (MAIN::speech ( text a)))
(retract ?fact))
(set-current-module MAIN)
(assert (MAIN::speech ( text b)))
----------------OUTPUT---------------------------
Copyright (C) 2004 Sandia Corporation
Jess Version 7.0a2 10/8/2004
==> Activation: MAIN::call-loop : f-0
MAIN::call-loop: +1+1+t
A::R0-A: +1+1+1+1+t
B::R0-B: =1=1+1+1+t
==> f-1 (MAIN::speech (text b))
==> Activation: B::R0-B : f-1
FIRE 1 MAIN::call-loop f-0
*Salience Rule in main*
<== Focus MAIN
==> Focus A
<== Focus A
==> Focus B
FIRE 2 B::R0-B f-1
*MODULE B*
==> f-2 (MAIN::speech (text a))
==> Activation: A::R0-A : f-2
<== f-1 (MAIN::speech (text b))
<== Focus B
==> Focus A
FIRE 3 A::R0-A f-2
*MODULE A*
==> f-3 (MAIN::speech (text b))
==> Activation: B::R0-B : f-3
<== f-2 (MAIN::speech (text a))
<== Focus A
==> Focus MAIN
<== Focus MAIN
___________________________________
Nuovo Yahoo! Messenger: E' molto piy divertente: Audibles, Avatar, Webcam, Giochi,
Rubrica Scaricalo ora!
http://it.messenger.yahoo.it
--------------------------------------------------------------------
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]
--------------------------------------------------------------------