Introduction of Java Agent Development Environment JADE Software

  • Slides: 51
Download presentation
Introduction of Java Agent Development Environment (JADE) Software Agent 余萍 yuping@nju. edu. cn

Introduction of Java Agent Development Environment (JADE) Software Agent 余萍 yuping@nju. edu. cn

Outline � Introduction Foundation for Intelligent Physical Agents (FIPA) Java Agent Development Environment (JADE)

Outline � Introduction Foundation for Intelligent Physical Agents (FIPA) Java Agent Development Environment (JADE) � Running JADE Platform Install JADE Platform Run Agent on JADE Platform 2

Foundation for Intelligent Physical Agents (FIPA) � IEEE Computer Society standards organization A body

Foundation for Intelligent Physical Agents (FIPA) � IEEE Computer Society standards organization A body for developing and setting computer software standards for heterogeneous and interacting agents and agent-based systems. http: //www. fipa. org/ � A software agent A piece of software that acts for a user or other program in a relationship of agency 3

Within the scope of FIPA �Agent �Lifecycle Management �Message Transport �Message Structure �Inter-agent Interaction

Within the scope of FIPA �Agent �Lifecycle Management �Message Transport �Message Structure �Inter-agent Interaction Protocols �Ontologies �Security 4

The FIPA Agent Platform 5

The FIPA Agent Platform 5

Agent Management 6

Agent Management 6

Agent Management 7

Agent Management 7

Sample DF Description (df-agent-description : name (agent-identifier : name dummy@foo. com : addresses (sequence

Sample DF Description (df-agent-description : name (agent-identifier : name dummy@foo. com : addresses (sequence iiop: //foo. com/acc)) : protocols fipa-request : ontologies (set fipa-agent-management) : languages (set fipa-sl 0) : lease-time +0000 T 60000 T ) 8

Message Transport �Agent message transport comprises two levels: (1) The Message Transport Protocol (MTP)

Message Transport �Agent message transport comprises two levels: (1) The Message Transport Protocol (MTP) carries out the physical transfer of messages between two ACCs. (2) The Message Transport Service (MTS) is provided by the AP to which an agent is attached. The MTS supports the transport of FIPA ACL messages between agents on any given AP and between agents on different APs. 9

FIPA Conceptual model of an Agent Platform provides Normative services Life cycle Management Service

FIPA Conceptual model of an Agent Platform provides Normative services Life cycle Management Service Optional services Agent-Software Integration White page service Ontology Service Yellow page service Human Agent Interaction Message Transport service 10

FIPA Message Structure 11

FIPA Message Structure 11

Java Agent Development Framework �JADE is an enabling technology, a middleware for the development

Java Agent Development Framework �JADE is an enabling technology, a middleware for the development and runtime execution of peer-to-peer applications which are based on the agents paradigm and which can seamless work and interoperate both in wired and wireless environment. distributed system topology with peer-to-peer networking software component architecture with agent paradigm 12

JADE Features �FIPA-compliant distributed agent platform which can be split onto several hosts. �Java

JADE Features �FIPA-compliant distributed agent platform which can be split onto several hosts. �Java Application Programmer’s Interface. �Library of FIPA interaction protocols, such as Contract Net, ready to be used. �Graphical User Interface to manage several agents from the same Remote Management Agent. �Available at http: //jade. tilab. com Latest version: Jade 4. 3 (29/03/2013) JADE is free software and is distributed by Telecom Italia 13

JADE Application Fields �Mobile Applications �Internet Applications �Corporate Applications �Machine-to-Machine Applications 14

JADE Application Fields �Mobile Applications �Internet Applications �Corporate Applications �Machine-to-Machine Applications 14

15

15

JADE Platform Jade Main-container JRE Application Agent host 3. us Application Agent host 2.

JADE Platform Jade Main-container JRE Application Agent host 3. us Application Agent host 2. jp Application Agent host 1. it Jade distributed Agent Platform Jade Agent Container JRE Network protocol stack 16

JADE Platform Agent Management System Directory Facilitator White page service Yellow page service Agent

JADE Platform Agent Management System Directory Facilitator White page service Yellow page service Agent Communication Channel Intra-Container Message Transport (Java events) Inter-Containers Message Transport (Java RMI) cache of agent addresses Inter-Platforms Message Transport (IIOP, HTTP, …) 17

Directory Facilitator (DF) 18

Directory Facilitator (DF) 18

Directory Facilitator (DF) �Provides a Yellow Pages service by means of which an agent

Directory Facilitator (DF) �Provides a Yellow Pages service by means of which an agent can find other agents providing the services he requires in order to achieve his goals. 19

Agent Management System (AMS) 20

Agent Management System (AMS) 20

Agent Management System (AMS) �Provides the naming service Ensures that each agent in the

Agent Management System (AMS) �Provides the naming service Ensures that each agent in the platform has a unique name �Represents the authority in the platform To create/kill agents on remote containers by requesting that to the AMS 21

Remote Monitoring Agent (RMA) � Provide the GUI to control agents’ lifecycle 22

Remote Monitoring Agent (RMA) � Provide the GUI to control agents’ lifecycle 22

Agent Life Cycle 23

Agent Life Cycle 23

Message Transport System � Agent Communication Channel (ACC) Agent to Agent Platform Agent Management

Message Transport System � Agent Communication Channel (ACC) Agent to Agent Platform Agent Management System Directory Facilitator White page service Yellow page service Agent Communication Channel Intra-Container Message Transport (Java events) Inter-Containers Message Transport (Java RMI) cache of agent addresses Inter-Platforms Message Transport (IIOP, HTTP, …) 24

JADE - Message Transport Service controls the agent’s private queue of ACL messages designed

JADE - Message Transport Service controls the agent’s private queue of ACL messages designed as a chameleon the transport mechanism is selected according to the situation ▪ to achieve the lowest cost for message passing ▪ the overheads depend on the receiver’s location and the cache status � distributed Agent Communication Channel the main container is not a bottle-neck, thanks to the distributed caches Message Transport Protocols (MTP) can be activated/deactivated at run-time on any container via the GUI ▪ IIOP based on the ORB implementation of Sun ▪ IIOP based on the ORBacus implementation ▪ allows to make persistent the object reference ▪ allows a more friendly URL-format corbaloc: iiop: hostname: port/name ▪ HTTP MTP provided by EPFL under LGPL multiple ACL encodings have been implemented ▪ String-based, XML-based (EPFL), bit-efficient (Sonera) � � 25

Agent Execution Model � agent is autonomous it completely controls its thread of execution

Agent Execution Model � agent is autonomous it completely controls its thread of execution Ø has a private proxy of the life-cycle manager decides itself when to read messages and which messages to read Ø the transport mechanism fills a private queue but it does not call the agent code (no automatic callback) � agent needs concurrency can engage multiple simultaneous conversations can execute several concurrent tasks Ø Java multi-thread or/and Ø JADE behaviours with cooperative scheduling Ø one thread-per-agent rather than one thread-per-task/conversation. Ø Programming Model A JADE agent is mapped onto an user defined Java class, that must subclass Agent class in jade. core package. Agent tasks are mapped onto user defined subclasses of Behaviour class in jade. core. behaviours package. 26

Agent Communication Model � Agents send/receive Java objects, that represent ACLMessages, within the scope

Agent Communication Model � Agents send/receive Java objects, that represent ACLMessages, within the scope of interaction protocols JADE hides all message coding (encoding/parsing) ▪ Envelope level ▪ String-based, XML-based ▪ Agent Communication Language level ▪ String-based, XML-based, bit-efficient ▪ Content Language level ▪ FIPA SL-0 + API to register user-defined content languages ▪ support for Base 64 -encoded direct Java object serialization ▪ Ontology level ▪ FIPA-Agent Management; JADE Agent Management ▪ API to register user-defined content languages ▪ the framework can be extended by users ▪ all levels provide APIs to implement/register new codecs ▪ work is in progress to improve CL and ontology level extendibility JADE provides a library of common interaction protocols ▪ users just need to implement the handle methods ▪ users can compose agent tasks like super-states of FSM 27

Agent mobility � JADE supports intra-platform mobility and cloning A platform can be distributed

Agent mobility � JADE supports intra-platform mobility and cloning A platform can be distributed across multiple hosts ▪ each host is an agent container Agents can migrate between containers Agents can clone across containers Self-initiated ▪ do. Move(Location) / do. Clone(Location, String) ▪ before/after. Move() before/after. Clone() Requested to the platform (via the AMS) ▪ Fipa-request interaction protocol ▪ jade. domain. Mobility. Ontology defines all the concepts and actions needed to support agent mobility and cloning 28

Some graphical tools to support development � RMA (Remote Monitoring Agent) � to browse

Some graphical tools to support development � RMA (Remote Monitoring Agent) � to browse the white-page service to control the agent life-cycle (e. g. remote creation, agent migration, …) to activate/deactivate MTPs on containers to browse white-page services of remote agent platforms DF GUI to browse the yellow-page service to make DF federations and browse remote DF’s � Dummy. Agent send/receive store/save ACLMessages � Sniffer Agent to sniff, debug, save to file, multi-agent conversations � Introspector Agent to debug an agent: queue of sent/received messages, queue of behaviours, … 29

Scalability in JADE �Configuration of a platform from one MAS on a single host

Scalability in JADE �Configuration of a platform from one MAS on a single host ▪ single-host platform to one agent on a single host ▪ agent platform on a cluster of hosts configuration can be changed at run-time ▪ hot restarting is possible thanks to the local caches ▪ agent is referred by name => no need to get new reference �Is the main-container a bottle-neck? the Agent Communication Channel is distributed the main container is involved only when strictly necessary 30

How much of FIPA is hidden by JADE to the programmer? � no need

How much of FIPA is hidden by JADE to the programmer? � no need to implement the Agent Platform AMS, DF, and ACC automatically launched at start-up � no need to implement agent-management ontology and functionalities an agent is registered with the AP by the Java constructor itself ▪ it is given a name and an address the Agent class provides a simplified interface to access the services of the DF (registration, searching, …) � no need to implement Message Transport and Parsing automatically (and possibly efficiently) done by the framework when sending/receiving messages � no need to implement Interaction Protocols they must only be extended via handle methods 31

Example � Book Seller & Book Buyer Seller 1 Buyer Seller 2 32

Example � Book Seller & Book Buyer Seller 1 Buyer Seller 2 32

Agent Communication Language 33

Agent Communication Language 33

Agent Communication Language � sender of the message � list of receivers � communicative

Agent Communication Language � sender of the message � list of receivers � communicative intention (or “performative”) � content language � ontology � some fields 34

Agent Communication Language �Receiving Messages 35

Agent Communication Language �Receiving Messages 35

36

36

An Example of Sender 37

An Example of Sender 37

An Example of Receiver 38

An Example of Receiver 38

Book. Seller. Agent � Book. Seller. Agent extends Agent import jade. core. Agent; Initial

Book. Seller. Agent � Book. Seller. Agent extends Agent import jade. core. Agent; Initial process ▪ Setup() ▪ add. Behaviour(new Offer. Requests. Server()); ▪ add. Behaviour(new Purchase. Orders. Server()); Agent Behaviour ▪ import jade. core. behaviours. *; ▪ Purchase. Orders. Server extends Cyclic. Behaviour ▪ Offer. Requests. Server extends Cyclic. Behaviour 39

Book. Seller. Agent Setup() Service Registration • Service Name • Service Type Add Behaviour

Book. Seller. Agent Setup() Service Registration • Service Name • Service Type Add Behaviour 40

Book. Seller. Agent Takedown() Service deregistration 41

Book. Seller. Agent Takedown() Service deregistration 41

class Behaviour �This abstract class provides an abstract base class for modelling agent tasks,

class Behaviour �This abstract class provides an abstract base class for modelling agent tasks, and it sets the basis for behaviour scheduling as it allows for state transitions (i. e. starting, blocking and restarting a Java behaviour object). 42

43

43

class Behaviour (Cont. ) � class Simple. Behaviour This abstract class models simple atomic

class Behaviour (Cont. ) � class Simple. Behaviour This abstract class models simple atomic behaviours. Its reset() method does nothing by default, but it can be overridden by user defined subclasses. class One. Shot. Behaviour ▪ This abstract class models atomic behaviours that must be executed only once and cannot be blocked. So, its done() method always returns true. class Cyclic. Behaviour ▪ This abstract class models atomic behaviours that must be executed forever. So its done() method always returns false. 44

Book. Seller. Agent One. Shot. Behaviour() 45

Book. Seller. Agent One. Shot. Behaviour() 45

Book. Seller. Agent Cyclic. Behaviour() 46

Book. Seller. Agent Cyclic. Behaviour() 46

class Behaviour (Cont. ) �class Waker. Behaviour This abstract class implements a one-shot task

class Behaviour (Cont. ) �class Waker. Behaviour This abstract class implements a one-shot task that must be executed only once just after a given timeout is elapsed. �class Ticker. Behaviour This abstract class implements a cyclic task that must be executed periodically. 47

class Behaviour (Cont. ) � class Composite. Behaviour This abstract class models behaviours that

class Behaviour (Cont. ) � class Composite. Behaviour This abstract class models behaviours that are made up by composing a number of other behaviours (children). So the actual operations performed by executing this behaviour are not defined in the behaviour itself, but inside its children while the composite behaviour takes only care of children scheduling according to a given policy. class Sequential. Behaviour ▪ This class is a Composite. Behaviour that executes its sub-behaviours sequentially and terminates when all sub-behaviours are done. Use this class when a complex task can be expressed as a sequence of atomic steps (e. g. do some computation, then receive a message, then do some other computation). 48

class Behaviour (Cont. ) class Parallel. Behaviour ▪ This class is a Composite. Behaviour

class Behaviour (Cont. ) class Parallel. Behaviour ▪ This class is a Composite. Behaviour that executes its sub-behaviours concurrently and terminates when a particular condition on its sub-behaviours is met. Proper constants to be indicated in the constructor of this class are provided to create a Parallel. Behaviour that ends when all its sub-behaviours are done, when any one among its sub-behaviour terminates or when a user defined number N of its subbehaviours have finished. Use this class when a complex task can be expressed as a collection of parallel alternative operations, with some kind of termination condition on the spawned subtasks. 49

class Behaviour (Cont. ) class FSMBehaviour ▪ This class is a Composite. Behaviour that

class Behaviour (Cont. ) class FSMBehaviour ▪ This class is a Composite. Behaviour that executes its children according to a Finite State Machine defined by the user. More in details each child represents the activity to be performed within a state of the FSM and the user can define the transitions between the states of the FSM. When the child corresponding to state Si completes, its termination value (as returned by the on. End() method) is used to select the transition to fire and a new state Sj is reached. At next round the child corresponding to Sj will be executed. Some of the children of an FSMBehaviour can be registered as final states. The FSMBehaviour terminates after the completion of one of these children. 50