360 likes | 516 Views
AI-MAS 3.12.2004. JADE. An agent platform that implements the basic services and infrastructure of a distributed multi-agent application: agent life-cycle and agent mobility white & yellow-page services peer-to-peer message transport & parsing ; also multi-party communication
E N D
JADE • An agent platform that implements the basic services and infrastructure of a distributed multi-agent application: • agent life-cycle and agent mobility • white & yellow-page services • peer-to-peer message transport & parsing; also multi-party communication • agent security • scheduling of multiple agent tasks • set of graphical tools to support monitoring, logging, and debugging • encourages the development of pro-active applications • Some relevant features: • is extremely light-weight, ported to J2ME-CLDC-MIDP 1.0; mobile terminals • enables interoperability through FIPA compliance • is an open source project originated by TILAB and currently governed by an International Board • is used by several R&D projects
The architectural model • A JADE-based application is composed of a collection of active components called Agents • Each agent has a unique name • Each agent is a peer since he can communicate in a bidirectional way with all other agents • Each agent lives in a container (that provides its run time) and can migrate within the platform • One container plays the role of main (where AMS, DF live) • The main-container can be replicated via replication service
Agent class and names • A type of agent is created by extending the jade.core.Agent class and redefining the setup() method. • Each Agent instance is identified by an AID (jade.core.AID),composed of a unique name plus some addresses; the getAID() method of the Agent class • Agent names are of the form <local-name>@<platform-name> • The complete name of an agent must be globally unique. • The default platform name is <main-host>:<main-port>/JADE • The platform name can be set using the –name option • Within a single JADE platform agents are referred through their names only. • Given the name of an agent its AID can be created as • AID id = new AID(localname, AID.ISLOCALNAME); • AID id = new AID(name, AID.ISGUID); • It is possible to pass arguments to an agent; the getArguments() method • An agent terminates when its doDelete() method is called. • On termination the agent’s takeDown() method is invoked (intended to include clean-up operations).
The Behaviour class • The actual job that an agent does is typically carried out within “behaviours” • Behaviours are created by extending the jade.core.behaviours.Behaviour class • To make an agent execute a task it is sufficient to create an instance of the corresponding Behaviour subclass and call the addBehaviour() method of the Agent class. • Each Behaviour subclass must implement • public void action(): what the behaviour actually does • public boolean done(): Whether the behaviour is finished • An agent can execute several behaviours in parallel, however, behaviour scheduling is not preemptive, but cooperative and everything occurs within a single Java Thread • Behaviour switch occurs only when the action() method of the currently scheduled behaviour returns.
Behaviour types • “One shot” behaviours. • “Cyclic” behaviours. • “Complex” behaviours. • WakerBehaviour • The action() and done() method are already implemented so that the onWake() method (to be implemented by subclasses) is executed after a given timeout • After that execution the behaviour completes. • TickerBehaviour • The action() and done() method are already implemented so that the onTick() (to be implemented by subclasses) method is executed periodically with a given period • The behaviour runs forever unless its stop() method is executed
More about behaviours • The onStart() method of the Behaviour class is invoked only once before the first execution of the action() method. • The onEnd() method of the Behaviour class is invoked only once after the done() method returns true. • Each behaviour has a pointer to the agent executing it: the protected member variable myAgent • The removeBehaviour() method of the Agent class can be used to remove a behaviour from the agent pool of behaviours. The onEnd() method is not called. • When the pool of active behaviours of an agent is empty the agent enters the IDLE state and its thread goes to sleep
ACLMessage • Based on asynchronous message passing • Message format defined by the ACL language (FIPA) • Messages exchanged by agents are instances of the jade.lang.acl.ACLMessage • Sending a message = creating an ACLMessage object and calling the send() method of the Agent class • Reading messages from the private message queue is accomplished through the receive() method • Provide accessor methods to get and set all the fields defined by the ACL language : get/setPerformative(), get/setSender(), add/getAllReceiver(), get/setLanguage(), get/setOntology(), get/setContent()
Blocking or selecting • The block() method of the Behaviour class removes a behaviour from the agent pool and puts it in a blocked state (not a blocking call!!). Each time a message is received all blocked behaviours are inserted back in the agent pool and have a chance to read and process the message. • To avoid this it is possible to read only messages with certain characteristics specifying a jade.lang.acl.MessageTemplate parameter in the receive() method. • The Agent class also provides the blockingReceive() method; there are overloaded versions that accept a MessageTemplate and/or a timeout.
FIPA ACL Message Elements • p e r f o r m a t i v e What action the message performs • s e n d e r Initiator of the message • r e c e i v e r Recipient of the message • r e p l y - t o Recipient of the message reply • c o n t e n t Content of the message • l a n g u a g e Language used to express content • e n c o d i n g Encoding used for content • o n t o l o g y Ontology context for content • p r o t o c o l Protocol message belongs to • c o n v e r s a t i o n - i d Conversation message belongs to • r e p l y - w i t h Reply with this expression • i n - r e p l y - t o Action to which this is a reply • r e p l y - b y Time to receive reply by
ACL Message Example (request :sender (:name dominicagent@whitestein.com:8080) :receiver (:name rexhotel@tcp://hotelrex.com:6600) :ontology personal-travel-assistant :language FIPA-SL :protocol fipa-request :content (action movenpickhotel@tcp://movenpick.com:6600 (book-hotel (:arrival 25/11/2000) (:departure 05/12/2000) ... ))) • Any language can be used as a Content Language, e.g.: • KIF, Prolog, SQL, Serialized Objects, Binary Large Objects • FIPA-SL, FIPA-CCL, FIPA-RDF, FIPA-KIF
Communicative Act Library • accept-proposal: accept a previously submitted proposal • agree: agree to perform some action, possibly in the future • cancel: cancel some previously requested action • cfp: make a cal for proposals to perform a given action • confirm: inform a receiver that a given proposition is true • disconfirm: inform a receiver that a given proposition is false • failure: inform another agent that an action was attempted but failed • inform: inform a receiver that a given proposition is true • not-understood: informs a receiver that sender did not understand • query-if: ask another agent whether a given proposition is true • request: requests a receiver to perform some action
Communicative Act Library • propose: submit a proposal to perform a certain action • query-ref: ask another agent for the object referred to by a referential expression • refuse: refuse to perform a given action • reject-proposal: reject a proposal during a negotiation • request-when: request a receiver to perform some action when some given proposition becomes true • request-whenever: request a receiver to perform some action as soon as some proposition is true and thereafter each time the proposition becomes true again • subscribe: a persistent intention to notify the sender of a value, and to notify again whenever the value changes • propagate: the receiver treats the embedded message as sent directly to it, and must identify the agents denoted by the given descriptor and send the received propagate message to them • proxy: the receiver must select target agents denoted by a given description and to send an embedded message to them
Interaction protocols • Jade automatically handles the flow of messagesand the timeouts • callback methods that should be redefined to take the necessary actions • jade.proto package contains behaviours for both the initiator and responder role (FIPA-Request, FIPA-Contract-Net, FIPA-Subscribe) • Other FIPA IPs : FIPA-Query, FIPA-Request-When, FIPA-AIterated-Contract-Net, FIPA-Auction-English, FIPA-Auction-Dutch, FIPA-Brokering, FIPA-Recruiting, FIPA-Propose Predefined sequences of messages exchanged by agents during a conversation
Handling content expressions • Creating the Ontology (domain specific) • Defining the schemas ontology elements • Defining the corresponding Java classes • Handling content expressions as Java objects • Using the ContentManager to fill and parse message contents • Ontologies can be created with Protégé (with the beangenerator plugin)
Interacting with the DF Agent • The DF is an agent, it communicates using ACL • The ontology and language that the DF “understands” are specified by FIPA • The jade.domain.DFService class provides static utility methods that facilitate the interactions with the DF • register(); • modify(); • deregister(); • search(); • The JADE DF also supports a subscription mechanism
DFDescription format • When an agent registers with the DF it must provide a description • The agent AID • A collection of service descriptions (class ServiceDescription): • The service type (e.g. “Weather forecast”) • The service name (e.g. “Meteo-1”) • The languages, ontologies and interaction protocols that must be known to exploit the service • A collection of service-specific properties in the form key-value pair • When an agent searches/subscribes to the DF it must specify another DFAgentDescription that is used as a template
Agent Management System • The authority in a JADE platform; all platform management actions (creating/killing agents, killing containers...) • Other agents can request the AMS to perform these actions by using • The fipa-request interaction protocol • The SL language • The JADE-Management ontology and related actions • getAMS() => the AID of the AMS
Mobility • “Hard mobility” • Status: an agent can • stop its execution on the local container • move to a remote container (likely 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()
Security • Add-on that prevents the threats (malicious kill or shutdown, sniffing or tampering the messages) by providing support for: • Authentication and authorization • End-to-end message integrity and confidentiality • All security related API are embedded into the SecurityHelper • Signing, encryption • Policy files per user: Platform, Container, AMS, Agent, Message • ACLMessage msg = new ACLMessage(ACLMessage.INFORM); • ...... • SecurityHelper myHelper = (SecurityHelper) • getHelper("jade.core.security.Security"); • myHelper.setUseSignature(msg); • send(msg);
Advanced features • Using JADE (i.e. creating a container and starting agents) from an external Java program (servlets, applets, JSP..) • Executing a normal JADE behavior in a dedicated thread • Saving and reloading agent state on relational DB (persistence based on www.hibernate.org); add-on • Integration with JESS (Java Expert System Shell) • it allows reasoning about messages in JESS • it allows a JESS program to control sending/receiving messages and/or creating/destroying JADE behaviours • Distributed security, fault tolerance, support for replicated agents and services • Protégé, XML, RDF and OWL • Application-specific persistent delivery filters & JADE kernel-level services • The LEAP add-on
LEAP • JADE agents on PDA and mobile phones • JADE-LEAP (J2SE, PJava, MIDP): different internal implementation, same APIs for agents • JADE-LEAP for MIDP is itself a MIDlet; the main class is jade.MicroBoot • A MIDlet must be packaged as a single JAR file => mix library & app. Classes • MIDP configuration parameters are specified in the JAD/manifest of the MIDlet • Minimize target (ant) + obfuscator : 450 k -> 30-150 k • Logging - uniform way (jade.util.Logger class) • J2SE : JAVA Logging • PJava : System.out.println() • MIDP : RecordStore
The main graphical tools of JADE • Management, control, monitoring, and debugging of a multi-agent platform • RMA (Remote Monitoring Agent) • Dummy Agent • Sniffer Agent • Introspector Agent • Log Manager Agent • DF (Directory Facilitator) GUI
Advantages • No need to implement the Agent Platform • AMS, DF executed at start-up • No need to implement agent-management ontology and functionalities • An agent is registered with the Agent Platform within its constructor, it is given a name and an address • The DFService class provides a simplified interface to access the services of the DF (registration, searching, lease-renewal, …) • No need to implement Message Transport and Parsing • Automatically (and possibly efficiently) done by the framework when sending/receiving messages • Interaction Protocols must only be extended via handle methods • Standard FIPA !
Links http://jade.cselt.it http://www.fipa.org http://www.hibernate.org http://herzberg.ca.sandia.gov/jess/ http://protege.stanford.edu/ www.swi.psy.uva.nl/usr/aart/beangenerator http://jadex.sourceforge.net