Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial 5 Object to Agent Communication Fuhua Lin, PhD, Professor, School of Computing and Information Systems Athabasca University, Alberta, Canada Nov.

Similar presentations


Presentation on theme: "Tutorial 5 Object to Agent Communication Fuhua Lin, PhD, Professor, School of Computing and Information Systems Athabasca University, Alberta, Canada Nov."— Presentation transcript:

1 Tutorial 5 Object to Agent Communication Fuhua Lin, PhD, Professor, School of Computing and Information Systems Athabasca University, Alberta, Canada Nov. 7, 2009

2 In many cases, besides starting one or more agents, an external application needs to interact with the agents to instruct them to perform some tasks. For instance, an agent- based online book-selling system must notify the book buyer agent each time there is a new book to buy. Similarly, the book buyer agent must notify the system when it successfully purchases a book

3 However, the AgentControoler class does not disclose the reference of the wrapped agent instance and therefore the external application can not invoke any method of the agent directly. Interactions between an external application and an agent started by means of the in- process interface are made possibly by the object-to-agent (O2A) communication mechanism.

4 Idea: – Each agent has a synchronized FIFO queue (called O2A queue) where the external application can put Java objects that can be later extracted by the agent. – The AgentController object wrapping an agent provides the putO2AObject() method that can be used by the external application to insert objects in the O2A queue of the agent. – Similarly. The Agent class provides the getO2AObject() method that can be used by the agent to read objects passed by the external application.

5 The O2A communication mechanism is disabled by default and so an agent wishing to interact with external applications must enable it explicitly by means of the setEnableO2ACommunication() method. Similarly to the standard message queue model, inserting an object into the O2A queue of an agent has the effect of restarting all behaviors of the agent to give them a chance to read and process the inserted object.

6 Agent ______________ … getO2AObject(); … Agent ______________ … getO2AObject(); … Object to Agent Communication Jade provides the Object-to-Agent (O2A) communication mechanism, which is basically FIFO queue where the external application can put Java objects that can be later extracted by the agent External Java Application Agent Controller ______________ … putO2AObject(); … Agent Controller ______________ … putO2AObject(); … O2A queue putO2AObject() Object 1 CondVar

7 The external application (1)

8 External application (2)

9 testAgent (1)

10 testAgent (2)

11 Running result Wrong! We did not see the display of the passed objects!

12 Agent ______________ … getO2AObject(); … Agent ______________ … getO2AObject(); … External Java Application Agent Controller ______________ … putO2AObject(); … Agent Controller ______________ … putO2AObject(); … O2A queue putO2AObject() Object 1 startupLatch latch

13 Add Class CondVar serving as an event semaphore

14 The external application with class Condvar (2) To achieve a startup Synchronization!!!

15 Class testAgent with class CondVar (1)

16 Running Results ✓


Download ppt "Tutorial 5 Object to Agent Communication Fuhua Lin, PhD, Professor, School of Computing and Information Systems Athabasca University, Alberta, Canada Nov."

Similar presentations


Ads by Google