Download presentation
Presentation is loading. Please wait.
Published byEmery Phelps Modified over 9 years ago
1
Software Agent Computing Agent Mobility
2
Agent mobility is the ability for an agent program to migrate or to make a copy (clone) itself across one or multiple network hosts Support for mobility in JADE consists of a set of API classes and methods that allow an agent to perform the required actions by itself or via the AMS, and a mobility specific ontology, MobilityOntology, contained in the package jade.domain.mobility. Agent class in the package jade.core contains methods: doMove(), beforeMove(), afterMove(), doClone(), beforeClone() afterClone(). To move an agent, you just need to call the method doMove(Location) public void doMove(Location destination) Planning mobility – roadmap Moving Cloning doMove is called either by the Agent Platform or by the agent itself to start a migration process doMove() just changes the agent state to AP_TRANSIT. The actual migration take place asynchronously.
3
Mobility in JADE: intra and inter Intra-platform mobility is that, mobile agent can navigate across different agent containers but it is confined to a single JADE platform Inter-platform mobility provides agent with navigating among Agent Platforms FIPA defines extensions that are necessary to the AMS to support mobility. JADE containers are not FIPA compliant (FIPA does not specify them) “It should be noted that the concept of an AP does not mean that all agents resident on an AP have to be co-located on the same host computer.”* Therefore FIPA does not specify intra-platform migration JADE supports intra-platform migration by adaptation of inter- platform migration specification JADE does not support inter-platform mobility, but Migration Add- On does: http://jade.tilab.com
4
Mobility in JADE – weak or strong? “not-so-weak mobility” Status: an agent have to wait before currently scheduled behaviour finishes its cycle JADE agents can migrate in the middle of a conversation and a programmer can exploit the behaviour composition capability in order to define an arbitrarily fine-grained sequence of states in which an agent is allowed to migrate move to a remote container (possibly on a different host) restart its execution there from the exact point where it was interrupted Code: If the code of the moving agent is not available on the destination container it is automatically retrieved on demand An agent must be Serializable in order to be able to move Mobility can be self-initiated through doMove() of the Agent class forced by the AMS (following a request from another agent) Agent cloning is also available - method doClone()
5
The tricky point - Location You cannot create a Location object by yourself Ask AMS – by sending it a REQUEST with content WhereIsAgentAction – allows to obtain with the location of a given agent; parameter - the identifier of the agent that your are querying the location – via method setAgentIdentifier(AID) or QueryPlatformLocationsAction - allows to obtain all available locations within a given platform. It takes no parameter) package jade.domain.JADEAgentManagement
6
Agent Management Reference Model Agent Management System – AMS: Mandatory component of Agent Platform Exerts supervisory control over use of the AP Only one in a single AP Maintains of a directory AID Offers white pages services to other agent Each agent must register with an AMS in order to get a valid AID number Message Transport System
7
AMS as White Pages Services Scenario 1 1. Agent A asks AMS about all possible containers in the AP 2. Agent A receives set of locations from AMS 3. Agent A migrate to the randomly chosen location Scenario 2 1. Agent A asks AMS about location of the agent B 2. Agent A receives the response from AMS about location 3. Agent A migrate to the location of agent B Let’s talk about ontology
8
Documentation: JADE Tutorial Application-defined Content Languages and Ontologies, http://jade.tilab.com/doc/CLOntoSupport.pdf API documentation (javadoc): jade.content package and subpackage Sample code: examples.content package in the examples included in the JADE distribution Semantic of communication in JADE Setting content SetContent() SetContentObject() fillContent() Content type Strings Java Objects Ontology Getting content getContent() getContentObject() ObjectsextractContent()
9
Agent Communication A B Inside the ACL message, Info is represented as a content expression consistent with a proper content language (e.g. SL) and encoded in a proper format (e.g. string). Both A and B have their own (possibly different) way of internally representing Info. Example: there is a person whose name is John and who is 35 years old (Person :name John :age 35) Info class Person { String name; int age; public String getName() {return name; } public void setName(String n) {name = n; } public int getAge() {return age; } public void setAge(int a) {age = a; } …. }
10
A needs to convert his internal representation of Into the corresponding ACL content expression representation and B needs to perform the opposite conversion. B should also perform a number of semantic checks to verify that Info is a meaningful piece of information, i.e. that it complies with the rules (for instance that the age of John Is actually an integer value) of the ontology by means of which both A and B ascribe a proper meaning to Info Handling Content Expression A B
11
Main Elements of Communication content manager object of the ContentManager class included in the jade.content package received through the getContentManager() method content manager delegates the conversion and check operations to an ontology (i.e. an instance of the Ontology class included in the jade.content.onto package) and a content language codec (i.e. an instance of the Codec interface included in the jade.content.lang package)
12
REQUEST :sender (agent-identifier :name da1@Zadig:1099/JADE) :receiver (set (agent-identifier :name ams@Zadig:1099/JADE)) :content (( action (agent-identifier :name ams@Zadig:1099/JADE) (where-is-agent (agent-identifier :name Peter@Zadig:1099/JADE)) )) :language FIPA-SL0 :ontology JADE-Agent-Management :protocol fipa-request ) Denotes the ontology which is used to give a meaning to the symbols in the content expression. An ontology gives meanings to symbols and expressions within a given domain language. Denotes the encoding scheme of the content of the action. Brings representation of message, e.g FIPA SL or it subsets (SLO, SL1). Content represents the domain dependent component of the communication. Define semantical structure of message content.
13
(REQUEST... :content ((“action” (ActorOfAction) (ActionName (ActionParameters)) ))... ) (REQUEST :sender (agent-identifier :name da1@Zadig:1099/JADE) :receiver (set (agent-identifier :name ams@Zadig:1099/JADE)) :content (( action (agent-identifier :name ams@Zadig:1099/JADE) (where-is-agent (agent-identifier :name Peter@Zadig:1099/JADE)) )) :language FIPA-SL0 :ontology JADE-Agent-Management :protocol fipa-request Summary: The sender requests the receiver to perform some action Message content: An action description Description: The action can be any action the receiver is capable of performing: pick up a box, book a plane flight, change a password etc. An important use of the request act is to build composite conversations between agents, where the actions that are the object of the request act are themselves communicative acts such as inform
14
(INFORM.. :content ((“result” (“action” (ActorOfAction) (ActionName (ActionParameters)) ) (ResultOfAction) ))... ) (INFORM :sender (agent-identifier :name ams@Zadig:1099/JADE) :receiver (set (agent-identifier :name da1@Zadig:1099/JADE)) :content ((result (action (agent-identifier :name ams@Zadig:1099/JADE) (where-is-agent (agent-identifier :name Peter@Zadig:1099/JADE)) ) (set (location :name Container-1 :protocol JADE-IPMT :address Zadig:1099/JADE.Container-1 )) :reply-with da1@Zadig:1099/JADE976984777740 :language FIPA-SL0 :ontology JADE-Agent-Management :protocol fipa-request
15
Registering language and ontology instance 1. Registering the defined ontology and the selected content language to the agent // register the SL0 content language getContentManager().registerLanguage(new SLCodec(), FIPANames.ContentLanguage.FIPA_SL0); 1. Creating and handling content expression as Java objects that are instances of the classes developed in step 2 and let JADE translate these Java objects to/from strings or sequences of bytes that fit the content slot of ACLMessages // register the mobility ontology getContentManager().registerOntology(MobilityOntology.getInstance());
16
Creating request to AMS private ACLMessage prepareRequestToAMS(AID agent) { ACLMessage request = new ACLMessage(ACLMessage.REQUEST); request.addReceiver(getAMS()); request.setLanguage(FIPANames.ContentLanguage.FIPA_SL0); request.setOntology(MobilityOntology.NAME); request.setProtocol(FIPANames.InteractionProtocol.FIPA_REQUEST); // creates the content of the ACLMessage Action act = new Action(); act.setActor(getAMS()); WhereIsAgentAction action = new WhereIsAgentAction(); action.setAgentIdentifier(agent); act.setAction(action); try { getContentManager().fillContent(request, act); } catch (CodecException ignore) { } catch (OntologyException ignore) {} return request; } public class WhereIsAgentAction implements AgentAction { private AID agentName; public WhereIsAgentAction() {} public void setAgentIdentifier(AID id) { agentName = id; } public AID getAgentIdentifier() { return agentName; } (REQUEST :sender (agent-identifier :name da1@Zadig:1099/JADE) :receiver (set (agent-identifier :name ams@Zadig:1099/JADE)) :content (( action (agent-identifier :name ams@Zadig:1099/JADE) (where-is-agent (agent-identifier :name Peter@Zadig:1099/JADE)) )) :language FIPA-SL0 :ontology JADE-Agent-Management :protocol fipa-request)
17
Parsing answer from AMS (INFORM :sender (agent-identifier :name ams@Zadig:1099/JADE) :receiver (set (agent-identifier :name da1@Zadig:1099/JADE)) :content ((result (action (agent-identifier :name ams@Zadig:1099/JADE) (where-is-agent (agent-identifier :name Peter@Zadig:1099/JADE)) ) (set (location :name Container-1 :protocol JADE-IPMT :address Zadig:1099/JADE.Container-1 )) :reply-with da1@Zadig:1099/JADE976984777740 :language FIPA-SL0 :ontology JADE-Agent-Management :protocol fipa-request ) private Location parseAMSResponse(ACLMessage response) { Result results = null; try { results = (Result)getContentManager().extractContent(response); } catch (UngroundedException e) { } catch (CodecException e) { } catch (OntologyException e) {} Iterator it = results.getItems().iterator(); Location loc = null; if (it.hasNext()) loc = (Location) it.next(); return loc; }
18
Mobility Example 6 Documentation: Chapter 3.7 in the Programmers guide included in the JADE distribution provides a detailed explanation of the mobility support API documentation (javadoc): jade.core.Agent class, jade.core.Location interface and jade.domain.mobility package Sample code: examples.mobile package in the examples included in the JADE distribution. In FIPA Agent Management Support for Mobility Specificationhttp://www.fipa.org/specs/fipa00087/inde x.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.