102
1 Introduction to JADE presenter: Syuan-Hao Li

1 Introduction to JADE presenter: Syuan-Hao Li. 2 Outline Introduction Java Virtual Machine Foundation for Intelligent Physical Agents (FIPA) Java Agent

  • View
    227

  • Download
    0

Embed Size (px)

Citation preview

1

Introduction to JADE

presenter: Syuan-Hao Li

2

OutlineOutline

IntroductionJava Virtual Machine

Foundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.6

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

3

OutlineOutline

IntroductionJava Virtual Machine

Foundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.6

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

4

Java Virtual Machine

An abstract computing machine.

The JVM knows nothing of the Java PL, only of a particular binary format, the class file format.

A class file contains JVM instructions (or byte codes) and a symbol table, as well as other ancillary information.

5

Java Byte Codes

Rather than generating an executable machine instructions, a Java compiler outputs what are known as Java byte codes.

Java byte codes are instructions written for a Java Virtual Machine that does not really exist.

Java interpreter executes the byte code by emulating the JVM on whatever platform you happen to be using.

6

Comparison Java Virtual Machine

7

Example

HelloWorld.java

import javax.swing.JOptionPane;

public class HelloWorld{ public static void Print() { JOptionPane.showMessageDialog(null, "Hello! World!"); }

public static void main(String[] args) { System.out.println("Hello! World!"); Print(); }}

Import library

Must be the same to the file name

Entry point

8

Homework

Write a java programQuery the information of a web site (ex. Stock, Weather forecast ) by user input.

ReferenceJava API Docs http://java.sun.com/javase/6/docs/api/

良葛格 java 學習筆記http://caterpillar.onlyfun.net/Gossip/JavaGossip-V1/JavaGossip.htm

9

OutlineOutline

IntroductionJava Virtual Machine

Foundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.6

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

10

Foundation for Intelligent Physical Agents (FIPA)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. Agent managementAgent communication language (ACL)Integration agent and other computer softwarehttp://www.fipa.org/

A software agentA piece of software that acts for a user or other program in a relationship of agency

11

OutlineOutline

IntroductionJava Virtual Machine

Foundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.6

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

12

JADEJADEJADE (Java Agent Development Framework)

Framework aimed at developing multi-agent systems and applications conforming to FIPA standards for intelligent agents.

13

JADEJADEThe agent platform can be split among several hosts. Only one Java application(Main container) is executed on each host.

14

JADEJADE

Support to the execution of multiple, parallel and concurrent agent activities via the behaviour model.

15

JADE platformJADE platform

JADE is a middleware that facilitates the development of Multi Agent Peer-to-Peer applications.

Full Java

Runs on all JVM from J2EE to J2ME MIDP1.0

Downloadable from http://jade.tilab.com

16 16

17

Containers and PlatformsContainers and Platforms

18

Containers and PlatformsContainers and Platforms

Each running instance of the JADE runtime environment is called a Container as it can contain several agents.

19

Containers and PlatformsContainers and Platforms

The set of active containers is called a Platform.

20

Containers and PlatformsContainers and Platforms

A single special Main container must always be active in a platform and all other containers register with it as soon as they start.

21

JADEJADE

22

JADEJADE

Main container

23

JADEJADE

AMS (Agent Management System) Provides the naming service and represents the authority in the platform.

DF (Directory Facilitator) 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.

RMA(Remote Management Agent)Acting as graphical console for platform management and control.

24

Agent Management System (AMS)Agent Management System (AMS)

25

Agent Management SystemAgent Management System

Provides the naming serviceEnsures that each agent in the platform has a unique name

Represents the authority in the platformTo create/kill agents on remote containers by requesting that to the AMS

26

Directory FacilitatorDirectory Facilitator

27

Directory FacilitatorDirectory Facilitator

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.

28

DF AgentDF Agent

29

Remote Monitoring AgentRemote Monitoring Agent

Provide the GUI to control agents’ lifecycle

30

Message Transport SystemMessage Transport System

Agent Communication Channel (ACC)

Agent to Agent

Agent Platform to Agent Platform

31

JADEJADE

32

JADEJADE

Agent identifier <nickname>@<platform_name>

nickname platform_name

33

OutlineOutline

IntroductionJava Virtual Machine

Foundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.6

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

34

Install JDK 1.6Install JDK 1.6

http://java.sun.com/ Download J2SE Development Kit (JDK) 1.6

The Java Runtime Environment (JRE)

Command-line development tools, such as compilers and debuggers, that are necessary or useful for developing applets and applications

35 35

Install JDK 1.6 -- step 1Install JDK 1.6 -- step 1

downloads

Web Site

36 36

Install JDK 1.6 -- step 2Install JDK 1.6 -- step 2

Download

37 37

Install JDK 1.6 -- step 3Install JDK 1.6 -- step 3

Your platform

38 38

Install JDK 1.6 -- step 4Install JDK 1.6 -- step 4

Download

39

OutlineOutline

IntroductionJava Virtual Machine

Foundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.6

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

40

JADEJADE

http://jade.tilab.com/

41

JADE PackageJADE Package

•JADE-doc•Document

•JADE-src•Source Code

•JADE-bin•Binary Code

•JADE-example•Example Code

42

Download eclipseDownload eclipse

Eclipse - an open development platformEclipse is an open source community whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle.

http://www.eclipse.org/downloads/

43

Download eclipseDownload eclipse

44

OutlineOutline

IntroductionJava Virtual Machine

Foundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.6

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

45

46

47

48

49

50

51

52

jade.Boot

1

2

3

53

-gui

1

2

3

54

55

-help

1

2

3

56

Arguments Options

-host <host name>Host where RMI registry for the platform is located

-port <port number>The port where RMI registry for the platform resides

-containerIf specified, a new Agent Container is added to an existing platform. Otherwise a new Agent Platform is created

-confShows the gui to set the configuration properties to start JADE.

-guiIf specified, a new Remote Management Agent is created.

-versionIf specified, current JADE version number and build date is printed.

57

OutlineOutline

IntroductionJava Virtual Machine

Foundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.6

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

58

ImplementationImplementation

1. Import jade.core.Agent Library

2. setup() Initialize and register this agent to AMS, the current state is ACTIVE.

3. addBehaviour() Add behaviours to queue, the parameter is a behaviour class.

4. action() Define action of behaviour.

5. doDelete() Shut down the agent.

59

ImplementationImplementation

import jade.core.Agent;import jade.core.behaviours.OneShotBehaviour;

public class HelloAgent extends Agent{ protected void setup() { addBehaviour(new InitBeha()); }

class InitBeha extends OneShotBehaviour { public void action() { System.out.println(“Hello!"); doDelete(); } }}

60

61

62

63

-container -host <IP> <agent_name>:<class_name>

64

65

End

66

Introduction to Agent

presenter: Syuan-Hao Li

67

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

68

Behaviour Behaviour

The setup() method should add at least one behaviour to the agent.

Every JADE agent is compose of a single execution thread and all its tasks are modeled and can be implemented as Behaviour objects.

addBehavior(Behaviour) & removeBehaviour(Behaviour) allow to manage the ready tasks queue of an agent.

69

Behaviour Behaviour

class WakerBehaviourThis abstract class implements a one-shot task that must be executed only once just after a given timeout is elapsed.

class TickerBehaviourThis abstract class implements a cyclic task that must be executed periodically.

70 70

71

ImplementationImplementation

OneShotBehaviourAgent execute only once.

CyclicBehaviourAgent execute by polling.

import jade.core.behaviours.OneShotBehaviour

import jade.core.behaviours.CyclicBehaviour

72

73

SimpleBehaviourSimpleBehaviour

class SimpleBehaviourclass OneShotBehaviour

This abstract class models atomic behaviours that must be executed only once and cannot be blocked. So, its done() method always returns true.

class CyclicBehaviourThis abstract class models atomic behaviours that must be executed forever. So its done() method always returns false.

74

CompositeBehaviourCompositeBehaviour

class CompositeBehaviourclass SequentialBehaviour

This class is a CompositeBehaviour that executes its sub-behaviours sequentially and terminates when all sub-behaviours are done.

class ParallelBehaviourThis class is a CompositeBehaviour that executes its sub-behaviours concurrently and terminates when a particular condition on its sub-behaviours is met.

class FSMBehaviourThis class is a CompositeBehaviour that executes its children according to a Finite State Machine defined by the user.

75

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

76

Agent CommunicationAgent Communication

77

Agent CommunicationAgent Communication

sender of the message

list of receivers

communicative intention (or “performative”)

content

content language

ontology

some fields

78

Agent CommunicationAgent Communication

Receiving Messages

79

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

80

Example Example

Write two agent in JADE Platform:SenderAgent

OneShotBehaviour

Send string to ReceiverAgent by using ACLMessage.

ReceiverAgentCyclicBehaviour

Receive and print the string from SenderAgent.

81

SenderSender

82

ReceiverReceiver

83

Exmaple Exmaple

84

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

85

Sniffer Sniffer

86

Sniffer Sniffer

87

Sniffer Sniffer

88

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

89

Example 2 Example 2

90

Arguments Arguments

91

SenderAgent SenderAgent

92

SenderAgent SenderAgent

93

SenderAgentSenderAgent

94

HelloAgent HelloAgent

95

HelloAgentHelloAgent

96

MathAgent MathAgent

97

MathAgentMathAgent

98

Results Results

SenderAgent

HelloAgent

MathAgent

99

ResultsResults

100

Sniffer AgentSniffer Agent

101

HomeworkHomework

Game: Three In A Row (3X3)

Five In A Row (9X9)

Write two or three Agent (A,B+C or A,B,C)Agent A : User

Input the position (X,Y) in chess board.

Agent B : Chess boardStore position of chess and judge who win.

Agent C : AI

102

End