Introduction to Agent and JADE Platform

Download Report

Transcript Introduction to Agent and JADE Platform

Introduction to JADE
presenter: Ji-Yu Li
1
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
2
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
3
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 management
Agent communication language (ACL)
Integration agent and other computer software
http://www.fipa.org/
A software agent
A piece of software that acts for a user or other
program in a relationship of agency
4
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
6
JADE
JADE (Java Agent Development Framework)
Framework aimed at developing multi-agent systems
and applications conforming to FIPA standards for
intelligent agents.
7
JADE
The agent platform can be split among several hosts.
Only one Java application(Main container) is executed on
each host.
8
JADE
Support to the execution of multiple, parallel and
concurrent agent activities via the behaviour model.
9
JADE 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
10
11
11
Containers and Platforms
12
Containers and Platforms
Each running instance of the JADE runtime
environment is called a Container as it can contain
several agents.
13
Containers and Platforms
The set of active containers is called a Platform.
14
Containers 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.
15
JADE
16
JADE
Main container
17
JADE
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.
18
Agent Management System (AMS)
19
Agent Management System
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
20
Directory Facilitator
21
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.
22
DF Agent
23
Remote Monitoring Agent
Provide the GUI to control agents’ lifecycle
24
Message Transport System
Agent Communication Channel (ACC)
Agent to Agent
Agent Platform to Agent Platform
25
JADE
26
JADE
Agent identifier
<nickname>@<platform_name>
nickname
platform_name
27
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
28
Install 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
29
Install JDK 1.5 -- step 1
Web Site
downloads
30
30
Install JDK 1.5 -- step 2
Select Java SE
31
31
Install JDK 1.5 -- step 3
Download
32
32
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
33
JADE
http://jade.tilab.com/
34
JADE Package
•JADE-doc
•Document
•JADE-src
•Source Code
•JADE-bin
•Binary Code
•JADE-example
•Example Code
35
Download eclipse
Eclipse - an open development platform
Eclipse 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/
36
Download eclipse
37
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
38
39
40
41
42
43
44
45
2
1
3
jade.Boot
46
1
-gui
2
3
47
48
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
49
Implementation
1. Import jade.core.Agent Library
2. setup() 初始化agent,向 AMS 註冊,此時狀態為
ACTIVE
3. addBehaviour() 加入behaviours到排程佇列,傳入的參
數為一個Behaviour class
4. action() 定義behaviour中的行為
5. doDelete() 結束此agent
50
Implementation
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();
}
}
}
51
52
53
54
-container -host <IP>
<agent_name>:<class_name>
55
56
End
57
Introduction to Agent
presenter: Ji-Yu Li
58
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
59
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.
60
Behaviour
class WakerBehaviour
This abstract class implements a one-shot task that
must be executed only once just after a given timeout
is elapsed.
class TickerBehaviour
This abstract class implements a cyclic task that must
be executed periodically.
61
62
62
Implementation
OneShotBehaviour
agent 只會執行一次
import jade.core.behaviours.OneShotBehaviour
CyclicBehaviour
agent的會以輪詢的方式來執行
import jade.core.behaviours.CyclicBehaviour
63
64
SimpleBehaviour
class SimpleBehaviour
class 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 CyclicBehaviour
This abstract class models atomic behaviours that must be
executed forever. So its done() method always returns false.
65
CompositeBehaviour
class CompositeBehaviour
class SequentialBehaviour
This class is a CompositeBehaviour that executes its subbehaviours sequentially and terminates when all subbehaviours are done.
class ParallelBehaviour
This class is a CompositeBehaviour that executes its subbehaviours concurrently and terminates when a particular
condition on its sub-behaviours is met.
class FSMBehaviour
This class is a CompositeBehaviour that executes its children
according to a Finite State Machine defined by the user.
66
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
67
Agent Communication
68
Agent Communication
sender of the message
list of receivers
communicative intention (or “performative”)
content
content language
ontology
some fields
69
Agent Communication
Receiving Messages
70
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
71
Example
寫兩支Agent於JADE上:
SenderAgent
OneShotBehaviour
用ACLMessage傳送字串給ReceiverAgent
ReceiverAgent
CyclicBehaviour
接收由SenderAgent傳送之字串並印出
72
Example
73
Sender
74
Receiver
75
Exmaple
76
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
77
Sniffer
78
Sniffer
79
Sniffer
80
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
81
Example 2
寫三支agent
•Sender送給HelloAgent字
串”Hello”, HelloAgent會在執
行畫面上印出sender的名稱並
回傳Hi
•接著SenderAgent再傳送數字
給MathAgent, MathAgen收
到後再回傳從1加到該數字的
總和,並在SenderAgent端執
行畫面印出。
82
Arguments
83
SenderAgent
84
SenderAgent
85
SenderAgent
86
HelloAgent
寫三支agent
•Sender送給HelloAgent字
串”Hello”, HelloAgent會在執
行畫面上印出sender的名稱並
回傳Hi
•接著SenderAgent再傳送數字
給MathAgent, MathAgen收
到後再回傳從1加到該數字的
總和,並在SenderAgent端執
行畫面印出。
87
HelloAgent
88
MathAgent
寫三支agent
•Sender送給HelloAgent字
串”Hello”, HelloAgent會在執
行畫面上印出sender的名稱並
回傳Hi
•接著SenderAgent再傳送數字
給MathAgent, MathAgen收
到後再回傳從1加到該數字的
總和,並在SenderAgent端執
行畫面印出。
※一樣要do sniffer觀察這三支
agent
89
MathAgent
90
Results
SenderAgent
HelloAgent
MathAgent
91
Results
92
Sniffer Agent
93
Homework
寫兩支Agent互相溝通
(a)輸入地點,查詢今日天氣預報
(b)猜數字遊戲
94
End
95