Hi
 
I'm testing a JADE agent integrated with Jess by using the "BasicJessBehaviour" provided by the JADE platform.
My testing environment consists of 2 agents : agent A and agent B wich includes the Jess engine. Agent A is sending 3 messages to agent B. Agent B uses the rules from the file that which is a slightly modified version of the JadeAgent.clp so that it looks like that:
 
(defrule proposal1
 "When a 'QUERY_IF' message arrives from an agent ?s, this rule asserts a
  'AGREE' message to the same sender and retracts the just arrived message"
  (MyAgent (name ?r))
  ?m <- (ACLMessage (communicative-act QUERY-IF) (sender ?s) (receiver ?r)
                    (reply-with ?id) (in-reply-to nil) (envelope nil)
      (conversation-id ?cid) (protocol nil) (language nil)
      (ontology nil) (content ?con1) (encoding nil) (reply-to )
      (reply-by nil)
        )
 =>
  (send (assert (ACLMessage (communicative-act AGREE) (sender ?r) (receiver ?s))))
  ;(assert (ACLMessage (communicative-act AGREE) (sender ?r) (receiver ?s)))
  (retract ?m)
)
 
(defrule proposal2
 "When a 'QUERY_REF' message arrives from an agent ?s, this rule asserts a
  'SUBSCRIBE' message to the same sender and retracts the just arrived message"
  (MyAgent (name ?r))
  ?m <- (ACLMessage (communicative-act QUERY_REF) (sender ?s) (receiver ?r)
                    (reply-with ?id) (in-reply-to nil) (envelope nil)
      (conversation-id ?cid) (protocol nil) (language nil)
      (ontology nil) (content ?con2) (encoding nil) (reply-to )
      (reply-by nil)
        )
 =>
  (send (assert (ACLMessage (communicative-act SUBSCRIBE) (sender ?r) (receiver ?s))))
  ;(assert (ACLMessage (communicative-act SUBSCRIBE) (sender ?r) (receiver ?s)))
  (retract ?m)
)
 
(defrule proposal3
 "When a 'REQUEST' message arrives from an agent ?s, this rule asserts a
  'REFUSE' message to the same sender and retracts the just arrived message"
  (MyAgent (name ?r))
  ?m <- (ACLMessage (communicative-act REQUEST) (sender ?s) (receiver ?r)
                    (reply-with ?id) (in-reply-to nil) (envelope nil)
      (conversation-id ?cid) (protocol nil) (language nil)
      (ontology nil) (content ?con2) (encoding nil) (reply-to )
      (reply-by nil)
        )
 =>
  (send (assert (ACLMessage (communicative-act REFUSE) (sender ?r) (receiver ?s))))
  ;(assert (ACLMessage (communicative-act REFUSE) (sender ?r) (receiver ?s)))
  (retract ?m)
)
 

(defrule send-a-message
 "When a message is asserted whose sender is this agent, the message is
  sent and then retracted from the knowledge base."
  (MyAgent (name ?n))
 ?m <- (ACLMessage (sender ?n))
 =>
 (send ?m)
 (retract ?m)
)
 

(watch facts)
(watch all)
(reset)
 
When running, I get the following strange results:
 

Agent container [EMAIL PROTECTED]://bercaru56 is ready.

--------------------------------------------

 ==> Focus MAIN

 ==> f-0 (MAIN::initial-fact)

 ==> f-1 (MAIN::MyAgent (name [EMAIL PROTECTED]:1099/JADE))

 

 - A -> QUERY_IF to B. in 1000

 

 ==> f-2 (MAIN::ACLMessage (communicative-act QUERY-IF) (sender A/JADE)

 (receiver B/JADE) (reply-with nil) (in-reply-to nil)

 (envelope nil) (conversation-id I121223475640_0) (protocol nil)

 (language nil) (ontology nil) (content "ask QUERY_IF") (encoding nil)

 (reply-to ) (reply-by nil))

==> Activation: MAIN::proposal1 :  f-1, f-2

FIRE 1 MAIN::proposal1 f-1, f-2

 

perf AGREE

receiver A/JADE

 

 <== f-2 (MAIN::ACLMessage (communicative-act QUERY-IF) (sender A/JADE)

 (receiver B/JADE) (reply-with nil) (in-reply-to nil)

 (envelope nil) (conversation-id I121223475640_0) (protocol nil)

 (language nil) (ontology nil) (content "ask QUERY_IF") (encoding nil)

 (reply-to ) (reply-by nil))

Jess has executed 1 passes

 

pause

 - A -> QUERY_REF to B. in 1000

 

 ==> f-3 (MAIN::ACLMessage (communicative-act QUERY-REF) (sender A/JADE)

 (receiver B/JADE) (reply-with nil) (in-reply-to nil)

 (envelope nil) (conversation-id I121223475640_1) (protocol nil)

(language nil) (ontology nil) (content "ask QUERY_REF") (encoding nil)

 (reply-to ) (reply-by nil))

 <== Focus MAIN

Jess has executed 0 passes

 

pause

 - A -> REQUEST to B. in 1000

 

 ==> f-4 (MAIN::ACLMessage (communicative-act REQUEST) (sender A/JADE)

 (receiver B/JADE) (reply-with nil) (in-reply-to nil) (envelope nil)

 (conversation-id I121223475640_2) (protocol nil) (language nil)

 (ontology nil) (content "ask REQUEST") (encoding nil) (reply-to ) (reply-by nil))

==> Activation: MAIN::proposal3 :  f-1, f-4

FIRE 1 MAIN::proposal3 f-1, f-4

 

perf REFUSE

receiver A/JADE

 

 <== f-4 (MAIN::ACLMessage (communicative-act REQUEST) (sender A/JADE) (receiver B/JADE) (reply-with nil) (in-reply-to nil) (envelope nil) (conversation-id I121223475640_2) (protocol nil) (language nil)

(ontology nil) (content "ask REQUEST") (encoding nil) (reply-to )

(reply-by nil))

Jess has executed 1 passes

 
Could you please give me a hint why the second rule is not fired and the fact f3 is not retracted?
 
Thanks for help, regards.
_____________________________________________________
Vladimir Florian
Senior Researcher
National Institute for R&D in Informatics
B-dul Maresal Averescu, nr.8-10
1-Bucharest, 011455-ROMANIA
Mobile: 0744 777730
Phone +40 21 316 12 59 /159 
Fax   +40 21 316 0539;
E-mail: [EMAIL PROTECTED]
 

 

Reply via email to