Download JADE

Document related concepts
no text concepts found
Transcript
Introduction to JADE
presenter: Syuan-Hao Li
1
Outline
Introduction
Java Virtual Machine
Foundation for Intelligent Physical Agents (FIPA)
Java Agent Development Environment (JADE)
Running JADE Platform
Install JDK 1.6
Install JADE Platform
Run JADE Platform
Run Agent on JADE Platform
2
Outline
Introduction
Java Virtual Machine
Foundation for Intelligent Physical Agents (FIPA)
Java Agent Development Environment (JADE)
Running JADE Platform
Install JDK 1.6
Install JADE Platform
Run JADE Platform
Run Agent on JADE Platform
3
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.
4
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.
5
Comparison Java Virtual Machine
6
Example
HelloWorld.java
import javax.swing.JOptionPane;
Import library
Must be the same to the file name
public class HelloWorld
{
public static void Print()
{
JOptionPane.showMessageDialog(null, "Hello! World!");
}
public static void main(String[] args)
{
System.out.println("Hello! World!");
Print();
}
Entry point
}
7
Homework
Write a java program
Query the information of a web site (ex. Stock,
Weather forecast ) by user input.
Reference
Java API Docs http://java.sun.com/javase/6/docs/api/
良葛格 java 學習筆記
http://caterpillar.onlyfun.net/Gossip/JavaGossipV1/JavaGossip.htm
8
Outline
Introduction
Java Virtual Machine
Foundation for Intelligent Physical Agents (FIPA)
Java Agent Development Environment (JADE)
Running JADE Platform
Install JDK 1.6
Install JADE Platform
Run JADE Platform
Run Agent on JADE Platform
9
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
10
Outline
Introduction
Java Virtual Machine
Foundation for Intelligent Physical Agents (FIPA)
Java Agent Development Environment (JADE)
Running JADE Platform
Install JDK 1.6
Install JADE Platform
Run JADE Platform
Run Agent on JADE Platform
11
JADE
JADE (Java Agent Development Framework)
Framework aimed at developing multi-agent systems
and applications conforming to FIPA standards for
intelligent agents.
12
JADE
The agent platform can be split among several hosts.
Only one Java application(Main container) is executed on
each host.
13
JADE
Support to the execution of multiple, parallel and
concurrent agent activities via the behaviour model.
14
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
15
16
16
Containers and Platforms
17
Containers and Platforms
Each running instance of the JADE runtime
environment is called a Container as it can contain
several agents.
18
Containers and Platforms
The set of active containers is called a Platform.
19
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.
20
JADE
21
JADE
Main container
22
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.
23
Agent Management System (AMS)
24
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
25
Directory Facilitator
26
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.
27
DF Agent
28
Remote Monitoring Agent
Provide the GUI to control agents’ lifecycle
29
Message Transport System
Agent Communication Channel (ACC)
Agent to Agent
Agent Platform to Agent Platform
30
JADE
31
JADE
Agent identifier
<nickname>@<platform_name>
nickname
platform_name
32
Outline
Introduction
Java Virtual Machine
Foundation for Intelligent Physical Agents (FIPA)
Java Agent Development Environment (JADE)
Running JADE Platform
Install JDK 1.6
Install JADE Platform
Run JADE Platform
Run Agent on JADE Platform
33
Install 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
34
Install JDK 1.6 -- step 1
Web Site
downloads
35
35
Install JDK 1.6 -- step 2
Download
36
36
Install JDK 1.6 -- step 3
Your platform
37
37
Install JDK 1.6 -- step 4
Download
38
38
Outline
Introduction
Java Virtual Machine
Foundation for Intelligent Physical Agents (FIPA)
Java Agent Development Environment (JADE)
Running JADE Platform
Install JDK 1.6
Install JADE Platform
Run JADE Platform
Run Agent on JADE Platform
39
JADE
http://jade.tilab.com/
40
JADE Package
•JADE-doc
•Document
•JADE-src
•Source Code
•JADE-bin
•Binary Code
•JADE-example
•Example Code
41
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/
42
Download eclipse
43
Outline
Introduction
Java Virtual Machine
Foundation for Intelligent Physical Agents (FIPA)
Java Agent Development Environment (JADE)
Running JADE Platform
Install JDK 1.6
Install JADE Platform
Run JADE Platform
Run Agent on JADE Platform
44
45
46
47
48
49
50
51
2
1
3
jade.Boot
52
1
-gui
2
3
53
54
1
-help
2
3
55
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
-container
If specified, a new Agent Container is added to an existing
platform. Otherwise a new Agent Platform is created
-conf
Shows the gui to set the configuration properties to start JADE.
-gui
If specified, a new Remote Management Agent is created.
-version
If specified, current JADE version number and build date is
56
printed.
Outline
Introduction
Java Virtual Machine
Foundation for Intelligent Physical Agents (FIPA)
Java Agent Development Environment (JADE)
Running JADE Platform
Install JDK 1.6
Install JADE Platform
Run JADE Platform
Run Agent on JADE Platform
57
Implementation
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.
58
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();
}
}
}
59
60
61
62
-container -host <IP>
<agent_name>:<class_name>
63
64
End
65
Introduction to Agent
presenter: Syuan-Hao Li
66
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
67
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.
68
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.
69
70
70
Implementation
OneShotBehaviour
Agent execute only once.
import jade.core.behaviours.OneShotBehaviour
CyclicBehaviour
Agent execute by polling.
import jade.core.behaviours.CyclicBehaviour
71
72
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.
73
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.
74
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
75
Agent Communication
76
Agent Communication
sender of the message
list of receivers
communicative intention (or “performative”)
content
content language
ontology
some fields
77
Agent Communication
Receiving Messages
78
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
79
Example
Write two agent in JADE Platform:
SenderAgent
OneShotBehaviour
Send string to ReceiverAgent by using ACLMessage.
ReceiverAgent
CyclicBehaviour
Receive and print the string from SenderAgent.
80
Sender
81
Receiver
82
Exmaple
83
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
84
Sniffer
85
Sniffer
86
Sniffer
87
Outline
Behaviour
Agent Communication
Example
Sniffer Agent
Example 2
88
Example 2
89
Arguments
90
SenderAgent
91
SenderAgent
92
SenderAgent
93
HelloAgent
94
HelloAgent
95
MathAgent
96
MathAgent
97
Results
SenderAgent
HelloAgent
MathAgent
98
Results
99
Sniffer Agent
100
Homework
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 board
Store position of chess and judge who win.
Agent C : AI
101
End
102