94
1 Introduction to JADE presenter: Ji-Yu Li

Introduction to JADE presenter: Ji-Yu Li

  • Upload
    archie

  • View
    79

  • Download
    2

Embed Size (px)

DESCRIPTION

Introduction to JADE presenter: Ji-Yu Li. Outline. Introduction Foundation for Intelligent Physical Agents (FIPA) Java Agent Development Environment (JADE) Running JADE Platform Install JDK 1.5 Install JADE Platform Run JADE Platform Run Agent on JADE Platform. Outline. Introduction - PowerPoint PPT Presentation

Citation preview

Page 1: Introduction to JADE  presenter: Ji-Yu Li

1

Introduction to JADE

presenter: Ji-Yu Li

Page 2: Introduction to JADE  presenter: Ji-Yu Li

2

OutlineOutline

IntroductionFoundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.5

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

Page 3: Introduction to JADE  presenter: Ji-Yu Li

3

OutlineOutline

IntroductionFoundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.5

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

Page 4: Introduction to JADE  presenter: Ji-Yu Li

4

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

Page 5: Introduction to JADE  presenter: Ji-Yu Li

6

OutlineOutline

IntroductionFoundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.5

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

Page 6: Introduction to JADE  presenter: Ji-Yu Li

7

JADEJADEJADE (Java Agent Development Framework)

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

Page 7: Introduction to JADE  presenter: Ji-Yu Li

8

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

Page 8: Introduction to JADE  presenter: Ji-Yu Li

9

JADEJADE

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

Page 9: Introduction to JADE  presenter: Ji-Yu Li

10

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

Page 10: Introduction to JADE  presenter: Ji-Yu Li

11 11

Page 11: Introduction to JADE  presenter: Ji-Yu Li

12

Containers and PlatformsContainers and Platforms

Page 12: Introduction to JADE  presenter: Ji-Yu Li

13

Containers and PlatformsContainers and Platforms

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

Page 13: Introduction to JADE  presenter: Ji-Yu Li

14

Containers and PlatformsContainers and Platforms

The set of active containers is called a Platform.

Page 14: Introduction to JADE  presenter: Ji-Yu Li

15

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.

Page 15: Introduction to JADE  presenter: Ji-Yu Li

16

JADEJADE

Page 16: Introduction to JADE  presenter: Ji-Yu Li

17

JADEJADE

Main container

Page 17: Introduction to JADE  presenter: Ji-Yu Li

18

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.

Page 18: Introduction to JADE  presenter: Ji-Yu Li

19

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

Page 19: Introduction to JADE  presenter: Ji-Yu Li

20

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

Page 20: Introduction to JADE  presenter: Ji-Yu Li

21

Directory FacilitatorDirectory Facilitator

Page 21: Introduction to JADE  presenter: Ji-Yu Li

22

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.

Page 22: Introduction to JADE  presenter: Ji-Yu Li

23

DF AgentDF Agent

Page 23: Introduction to JADE  presenter: Ji-Yu Li

24

Remote Monitoring AgentRemote Monitoring Agent

Provide the GUI to control agents’ lifecycle

Page 24: Introduction to JADE  presenter: Ji-Yu Li

25

Message Transport SystemMessage Transport System

Agent Communication Channel (ACC)

Agent to Agent

Agent Platform to Agent Platform

Page 25: Introduction to JADE  presenter: Ji-Yu Li

26

JADEJADE

Page 26: Introduction to JADE  presenter: Ji-Yu Li

27

JADEJADE

Agent identifier <nickname>@<platform_name>

nickname platform_name

Page 27: Introduction to JADE  presenter: Ji-Yu Li

28

OutlineOutline

IntroductionFoundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.5

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

Page 28: Introduction to JADE  presenter: Ji-Yu Li

29

Install JDK 1.5Install JDK 1.5

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

The Java Runtime Environment (JRE)

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

Page 29: Introduction to JADE  presenter: Ji-Yu Li

30 30

Install JDK 1.5 -- step 1Install JDK 1.5 -- step 1

downloads

Web Site

Page 30: Introduction to JADE  presenter: Ji-Yu Li

31 31

Install JDK 1.5 -- step 2Install JDK 1.5 -- step 2

Select Java SE

Page 31: Introduction to JADE  presenter: Ji-Yu Li

32 32

Install JDK 1.5 -- step 3Install JDK 1.5 -- step 3

Download

Page 32: Introduction to JADE  presenter: Ji-Yu Li

33

OutlineOutline

IntroductionFoundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.5

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

Page 33: Introduction to JADE  presenter: Ji-Yu Li

34

JADEJADE

http://jade.tilab.com/

Page 34: Introduction to JADE  presenter: Ji-Yu Li

35

JADE PackageJADE Package

•JADE-doc•Document

•JADE-src•Source Code

•JADE-bin•Binary Code

•JADE-example•Example Code

Page 35: Introduction to JADE  presenter: Ji-Yu Li

36

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/

Page 36: Introduction to JADE  presenter: Ji-Yu Li

37

Download eclipseDownload eclipse

Page 37: Introduction to JADE  presenter: Ji-Yu Li

38

OutlineOutline

IntroductionFoundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.5

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

Page 38: Introduction to JADE  presenter: Ji-Yu Li

39

Page 39: Introduction to JADE  presenter: Ji-Yu Li

40

Page 40: Introduction to JADE  presenter: Ji-Yu Li

41

Page 41: Introduction to JADE  presenter: Ji-Yu Li

42

Page 42: Introduction to JADE  presenter: Ji-Yu Li

43

Page 43: Introduction to JADE  presenter: Ji-Yu Li

44

Page 44: Introduction to JADE  presenter: Ji-Yu Li

45

Page 45: Introduction to JADE  presenter: Ji-Yu Li

46

jade.Boot

1

2

3

Page 46: Introduction to JADE  presenter: Ji-Yu Li

47

-gui

1

2

3

Page 47: Introduction to JADE  presenter: Ji-Yu Li

48

Page 48: Introduction to JADE  presenter: Ji-Yu Li

49

OutlineOutline

IntroductionFoundation for Intelligent Physical Agents (FIPA)

Java Agent Development Environment (JADE)

Running JADE PlatformInstall JDK 1.5

Install JADE Platform

Run JADE Platform

Run Agent on JADE Platform

Page 49: Introduction to JADE  presenter: Ji-Yu Li

50

ImplementationImplementation

1. Import jade.core.Agent Library

2. setup() 初始化 agent ,向 AMS 註冊,此時狀態為ACTIVE

3. addBehaviour() 加入 behaviours 到排程佇列,傳入的參數為一個 Behaviour class

4. action() 定義 behaviour 中的行為

5. doDelete() 結束此 agent

Page 50: Introduction to JADE  presenter: Ji-Yu Li

51

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(); } }}

Page 51: Introduction to JADE  presenter: Ji-Yu Li

52

Page 52: Introduction to JADE  presenter: Ji-Yu Li

53

Page 53: Introduction to JADE  presenter: Ji-Yu Li

54

Page 54: Introduction to JADE  presenter: Ji-Yu Li

55

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

Page 55: Introduction to JADE  presenter: Ji-Yu Li

56

Page 56: Introduction to JADE  presenter: Ji-Yu Li

57

End

Page 57: Introduction to JADE  presenter: Ji-Yu Li

58

Introduction to Agent

presenter: Ji-Yu Li

Page 58: Introduction to JADE  presenter: Ji-Yu Li

59

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

Page 59: Introduction to JADE  presenter: Ji-Yu Li

60

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.

Page 60: Introduction to JADE  presenter: Ji-Yu Li

61

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.

Page 61: Introduction to JADE  presenter: Ji-Yu Li

62 62

Page 62: Introduction to JADE  presenter: Ji-Yu Li

63

ImplementationImplementation

OneShotBehaviouragent 只會執行一次

CyclicBehaviouragent 的會以輪詢的方式來執行

import jade.core.behaviours.OneShotBehaviour

import jade.core.behaviours.CyclicBehaviour

Page 63: Introduction to JADE  presenter: Ji-Yu Li

64

Page 64: Introduction to JADE  presenter: Ji-Yu Li

65

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.

Page 65: Introduction to JADE  presenter: Ji-Yu Li

66

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.

Page 66: Introduction to JADE  presenter: Ji-Yu Li

67

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

Page 67: Introduction to JADE  presenter: Ji-Yu Li

68

Agent CommunicationAgent Communication

Page 68: Introduction to JADE  presenter: Ji-Yu Li

69

Agent CommunicationAgent Communication

sender of the message

list of receivers

communicative intention (or “performative”)

content

content language

ontology

some fields

Page 69: Introduction to JADE  presenter: Ji-Yu Li

70

Agent CommunicationAgent Communication

Receiving Messages

Page 70: Introduction to JADE  presenter: Ji-Yu Li

71

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

Page 71: Introduction to JADE  presenter: Ji-Yu Li

72

Example Example

寫兩支 Agent 於 JADE 上 :SenderAgent

OneShotBehaviour

用 ACLMessage 傳送字串給 ReceiverAgent

ReceiverAgentCyclicBehaviour

接收由 SenderAgent 傳送之字串並印出

Page 72: Introduction to JADE  presenter: Ji-Yu Li

73

ExampleExample

Page 73: Introduction to JADE  presenter: Ji-Yu Li

74

SenderSender

Page 74: Introduction to JADE  presenter: Ji-Yu Li

75

ReceiverReceiver

Page 75: Introduction to JADE  presenter: Ji-Yu Li

76

Exmaple Exmaple

Page 76: Introduction to JADE  presenter: Ji-Yu Li

77

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

Page 77: Introduction to JADE  presenter: Ji-Yu Li

78

Sniffer Sniffer

Page 78: Introduction to JADE  presenter: Ji-Yu Li

79

Sniffer Sniffer

Page 79: Introduction to JADE  presenter: Ji-Yu Li

80

Sniffer Sniffer

Page 80: Introduction to JADE  presenter: Ji-Yu Li

81

Outline Outline

Behaviour

Agent Communication

Example

Sniffer Agent

Example 2

Page 81: Introduction to JADE  presenter: Ji-Yu Li

82

Example 2 Example 2

寫三支 agent

•Sender 送給 HelloAgent 字串” Hello” , HelloAgent 會在執行畫面上印出 sender 的名稱並回傳 Hi

•接著 SenderAgent 再傳送數字給 MathAgent , MathAgen 收到後再回傳從 1加到該數字的總和,並在SenderAgent 端執行畫面印出。

Page 82: Introduction to JADE  presenter: Ji-Yu Li

83

Arguments Arguments

Page 83: Introduction to JADE  presenter: Ji-Yu Li

84

SenderAgent SenderAgent

Page 84: Introduction to JADE  presenter: Ji-Yu Li

85

SenderAgent SenderAgent

Page 85: Introduction to JADE  presenter: Ji-Yu Li

86

SenderAgentSenderAgent

Page 86: Introduction to JADE  presenter: Ji-Yu Li

87

HelloAgent HelloAgent

寫三支 agent

•Sender 送給 HelloAgent 字串” Hello” , HelloAgent 會在執行畫面上印出 sender 的名稱並回傳 Hi

•接著 SenderAgent 再傳送數字給 MathAgent , MathAgen 收到後再回傳從 1加到該數字的總和,並在SenderAgent 端執行畫面印出。

Page 87: Introduction to JADE  presenter: Ji-Yu Li

88

HelloAgentHelloAgent

Page 88: Introduction to JADE  presenter: Ji-Yu Li

89

MathAgent MathAgent

寫三支 agent

•Sender 送給 HelloAgent 字串” Hello” , HelloAgent 會在執行畫面上印出 sender 的名稱並回傳 Hi

•接著 SenderAgent 再傳送數字給 MathAgent , MathAgen 收到後再回傳從 1加到該數字的總和,並在SenderAgent 端執行畫面印出。

※一樣要 do sniffer 觀察這三支 agent

Page 89: Introduction to JADE  presenter: Ji-Yu Li

90

MathAgentMathAgent

Page 90: Introduction to JADE  presenter: Ji-Yu Li

91

Results Results

SenderAgent

HelloAgent

MathAgent

Page 91: Introduction to JADE  presenter: Ji-Yu Li

92

ResultsResults

Page 92: Introduction to JADE  presenter: Ji-Yu Li

93

Sniffer AgentSniffer Agent

Page 93: Introduction to JADE  presenter: Ji-Yu Li

94

HomeworkHomework

寫兩支 Agent 互相溝通

(a) 輸入地點,查詢今日天氣預報

(b) 猜數字遊戲

Page 94: Introduction to JADE  presenter: Ji-Yu Li

95

End