JADE

Report
Introduction to JADE
簡嘉建
Outline



DEMO
Agent Standards
JADE
–
–


Agent platform
Programming
Term Project進度報告
DEMO(again)
Agent Standards– FIPA



FIPA (Foundation for Intelligent Physical
Agents) 是一個國際組織, 其主要的任務在於促
進智慧型代理人技術。 FIPA組織會員是開放給
任何個人, 公司與政府單位或國際組織。 FIPA是
一個非營利性的組織在瑞士日內瓦註冊。
FIPA2000參與的公司包括SUN、IBM、Fujitsu、
HP….。
www.fipa.org
FIPA Standards



FIPA是一個國際性的非營利性組織,其目的在
為一致性的代理人技術訂定規格。
FIPA並不是為單一領域的技術做促銷,而是希
望對不同領域提供一互動的標準,來讓開發人員
能整合不同的系統。FIPA只針對系統元件外部
的行為作一規範,至於實作的細節和系統內部的
架構則留給平台的開發者。
FIPA-compliant Agent Platforms: JADE、
FIPA-OS(NORTEL)、ASL、Bee-gent(Toshiba)、
Grasshopper-2 ….
FIPA Standards Online

FIPA 標準目前線上可以閱讀的文件包括:
–
–
–
–
–
1) 代理人管理 (Agent management)
2) 發展者的指引 (developer guide)
3) 人機互動 (human-machine interaction)
4) 本體語言 (ontology) 與
5) 安全管理 (security management)
Mobile Agent Standards – MASIF


MAF (Mobile Agent Facility)的 MASIF提議自
1988年起由 OMG (Object Management Group)
開始研究。
MASIF 主要著眼於
–
–
–

1) 代理人管理: (啟始, 終止, 暫停, 回復)
2) 代理人的轉移
3) 代理人與代理人系統的命名
The MASIF specification is largely based on
the IBM Aglets mobile agent system design.
FIPA vs. OMG

FIPA is dominated by computer and
telecommunications companies and is focus
primarily on agent-level issues.
–

(BDI: belief-desire-intention) expecting agent to
have mental states, beliefs about other agents and
the state of the world, and desires and plans for
take actions to change the state of the world.
OMG is the standards body that created the
CORBA distributed object protocol and tends to
focus on object-level interoperability and
management.
JADE (Java Agent DEvelopment
Framework)

由CSLET S.p.A in Torino, Italy所開發。

一符合FIPA標準的多代理人系統(multi-agent
systems)開發架構。

JADE: http://sharon.cselt.it/projects/jade
Two Main Products in JADE


JADE包含著兩項主要套件:
符合FIPA標準的代理人平台(參照下圖)
–

JADE是一個符合FIPA的執行時期多代理人系統,可
以讓代理人在上面活動並使用它所提供的特色,如訊
息傳遞、代理人生命週期的管理。
開發Java代理人的程式套件
– 另一方面,JADE是一個Java架構,提供程式開發者
來發展一符合FIPA的代理人應用程式。
Agent Platform Reference Model
(FIPA )
Software
Agent
Agent Platform
Directory
Facilitator
Agent
Management
System
Internal Platform Message Transport
Agent
Communication
Channel
AMS (Agent Management System)


AMS本身是一個代理人,它擁有整個代理人平
台存取的管理權,並負責代理人平台內所有代理
人的認證和登錄。一個理人平台只能有一個
AMS。
AMS提供white-page和life-cycle服務,前者負責
AID(agent identifiers)的目錄,每個agent一初始
必須要跟AMS登錄以取得一個有效的AID;後者
維護代理人的各個狀態(參照下圖)。
Agent Life Cycle
Suspended
Waiting
Resume
Wait
Wake Up
Suspend
Unknow
Destroy
Active
Move
Quit
Invoke
Execute
Transit
Initiated
Create
DF (Directory Facilitator)

DF本身是一個代理人,提供yellow-page服務,
每個代理人都可向DF登錄自己所提供的服務,
而其他的代理人可以查詢平台內代理人所提供的
服務有哪些是自己需要的。
ACC (Agent Communication
Channel)



ACC是一個模組負責平台內所有訊息的傳遞,
和與遠方平台的訊息來往。
當JADE agent和non-JADE agent溝通時,ACC
負責雙向的交談。
FIPA要求ACC支援IIOP(Internet InterOrb
Interoperability Protocol)使得只要遵守FIPA的代
理人平台能夠互相運作。
JADE Platform

單一的JADE代理人平台可以跨數個主機系統
(host systems),但每一主機需要Java Virtual
Machine(JVM) 。
JADE Platform (cont’d)
Features of JADE

FIPA-compliant Agent Platform
–



Other FIPA-compliant Agent Platform, FIPAOS(NORTEL)、ASL、Bee-gent(Toshiba)、
Grasshopper-2 ….
以Java程式撰寫
分散式的代理人平台
圖形化的平台管理介面 Remote Management
Agent(RMA),也是一個Agent
Features of JADE (cont’d)




除錯工具Dummy Agent、Sniffer、
IntrospectorAgent
Mobility (Java Serialization, Reflection API)
開放的原始碼,遵從LGPL(Lesser General
Public License)
可與JESS(Java Expert System Shell, a Java
version of CLIPS)整合,提供代理人reasoning
的功能
JADE Agent程式設計最重要的三件事
Agent
Content Language :
Ontology
Agent communication
languages
Agent Behaviour
JADE Agent程式設計最重要的三件事
Agent
Content Language :
Ontology
Agent communication
languages
Agent Behaviour
Agent Language

Agent implementation languages
–
–

Agent communication languages
–
–

C++
Java
KQML (Knowledge Query Manipulation Language)
FIPA-ACL
Agent Content Language : Ontology
–
–
KIF (knowledge interchange format)
WORDNET
MAS(Multi-Agent System)


發展一個多代理人系統最重要的任務就是異質
軟體的整合,亦即獨立開發的代理人彼此間可
以成功的互動。
以多代理人為基礎的技術若缺乏一個相互溝通
的標準,它將無法運作。
–
Agent content language : Ontology
Domain 的vocabulary
 類似XML Schema

–
Agent communication languages
XML & XML Schema
<CD>
<TITLE>Carolyn Debern</TITLE>
<PRICE>480</PRICE>
<TRACKS>
<TRACK>Every breath you take</TRACK>
<TRACK>Autumn Leaves</TRACK>
<TRACK>Tore Amour</TRACK>
</TRACKS>
</CD>
Agent Content Language:
Ontology


There is a person whose name is Giovanni and
who is 33 years old in an ACL content
expression could be represented as the string
(Person :name Giovanni :age 33)
舊的content expression(用string表示)
–
–

Not suitable to handle the information (require each
time to parse the string)
Perform a number of semantic checks
新的content expression (用object表示)
–
Conveniently be represented inside an agent as
Java objects.
Internal Mechanism
Content slot of an
ACLMessage
Information
represented as a string
or a sequence of bytes
(easy to transfer)
Inside of an agent
Parser
Encoder
JADE support for content
languages and ontologies
Information
represented as Java
objects
(easy to manipulate)
CD.java
public class CD extends Item{
// title
private String title;
public void setTitle(String s) { this.title=s; }
public String getTitle() { return this.title; }
// price
private String price;
public void setPrice(String p) { this.price=p; }
public String getPrice() { return this.price; }
// tracks
private List tracks = new ArrayList();
public void addTracks(Track o) { tracks.add(o); }
public boolean removeTracks(Track o) {return tracks.remove(o); }
public List getTracks() {return tracks; }
public void setTracks(List l) {tracks = l; }}
MusicShopOntology.java
cdSchema.add(CD_TITLE,(TermSchema)getSchema(BasicOntology.
STRING), ObjectSchema.MANDATORY);
cdSchema.add(PRICE,(TermSchema)getSchema(BasicOntology.ST
RING), ObjectSchema.OPTIONAL);
cdSchema.add(CD_TRACKS, trackSchema, 1,20);
CD in ACLMessage
(CD
:TITLE \"Carolyn Debern\"
:PRICE \"480\"
:TRACKS (sequence
(Track :NAME \"Every breath you take\")
(Track :NAME \"Autumn Leaves\")
(Track :NAME \"Tore Amour\"))
)
Codec



SL language is a human-readable stringencoded
LEAP language is a non-human-readable byteencoded
XMLCodec
SL0Codec Vs. SLCodec


jade.lang.sl.SL0Codec(JADE2.0)
jade.content.lang.sl.SLCodec(JADE2.5)
Elements that can appear within a valid sentence
–
Concepts : indicate entities that“exist”in the world.
Ex. (Person :name John)
–
–
Predicates : say something about the status of the world and
can be true or false.
Ex. (Works-for (Person :name John)
(Company :name TILAB))
Agent action : indicate actions that can be performed by some
agents.
Ex. (Sell (Book :title “The Lord of the
rings”) (Person :name John))
JADE Agent程式設計最重要的三件事
Agent
Content Language :
Ontology
Agent communication
languages
Agent Behaviour
Agent Communication Language:
ACL-KQML



由KQML(Knowledge Query and Manipulation
Language)衍生而來
It describes the “speech act” of the message
using a set of performatives( message types ),
that express an attitude regarding the content
of the exchange.
The content language of the message is not
part of KQML, but can be specified by KQML
performatives.
An KQML Example
(QUERY-IF
:content “(Works-for (Person :name John)
(Company :name TILAB))”
:sender RequesterAgent
:receiver EngagerAgent
:language FIPA-SL
:ontology employment-ontology)
An KQML Example(cont’d)
(INFORM
:content “(Works-for (Person :name John)
(Company :name TILAB))”
:sender EngagerAgent
:receiver RequesterAgent
:language FIPA-SL
:ontology employment-ontology)
Categories of Performatives




Basic Query: Evaluate, ask-if, ask-about, askone, ask-all
Multi-response Query: stream-about, stream-all,
eos
Response: reply, sorry
Generic information: tell, achieve, cancel, untell,
unachieve
JADE Agent程式設計最重要的三件事
Agent
Content Language :
Ontology
Agent communication
languages
Agent Behaviour
Agent Behaviour

An agent must be able to carry out several concurrent tasks
in response to different external events. All agent’s tasks are
modeled and can be implemented as Behaviour objects.

基本的behaviour
–
–
–
–
Behaviour:atomic behaviour.
OneShotBehaviour:must be executed only once and cannot
be blocked.
CyclicBehaviour:must be executed forever.
CompositeBehaviour:are made up by composing a number
of other children behaviours.
Agent Behaviour (cont’d)

FIPA defined a set of interaction protocols
–
–
–
Which are tightly scripted sequences of speech
acts, for asking questions, sharing knowledge, and
participating in various types of auctions and
negotiation.
(ex. contract net negotiation protocol、English and
Dutch auctions….)
For defining dialogues between agents.(不同於
echo,而是更進一步定義訊息如何傳送,如何回覆)
JADE以behaviour的方式來implement這些
interaction protocols.
Contract Net Protocol

Tasks allocation(應用:Vehicle Routing Problem)
Bidder
Agent B 1
Bidder
Agent B 2
Announcer
Agent A
‧‧
‧‧
Bidder
Agent Bn
Contract-Net Protocol Support in
Initiator:createCfpContent
JADE
Responder:handleCfpMessage
Not-understd
Responder
handleAccep
tProposalMe
ssage
handleReject
ProposalMes
sage
refuse
cfp
propose
reject
accept
failure
inform
Initiator
Initiator:
handleProposeMessages
handleOtherMessages
Responder
cancel
測試情境

在這個多代理人系統內,存在有兩個Seller
Agents和一個Buyer Agent。 Seller Agents販賣
音樂CD,而Buyer Agent則輔助使用者購買CD。
當使用者在介面上輸入某首歌曲的名稱,Buyer
Agent會broadcast一個CFP (Call for Proposal)
訊息給系統內的Seller Agents,Seller Agents在
收到這個CFP後,會查詢庫存資料庫來判斷這首
歌出現在哪幾片CD內,這片CD是否尚有庫存。
開發環境



Java 2 SDK, Standard Edition, version 1.3.1
(JDK 1.3.1)
JADE 2.5
JESS version 6.0
何謂合適?



Seller Agent評估這個CFP訊息,並提出合適的
Proposal (何謂合適?).
Buyer Agent 評 估 這 些 Proposals , 選 出 合 適 的
Proposals (何謂合適?),並採取相對應的動作.
如果Agent只是做data collection的工作,其實
跟直接搜尋database沒什麼兩樣。我們希望它
能表現出智慧!!原本由人來做決策,改成由
Agent.
Seller Agent

目前,Seller Agent的 knowledge base只有一個
rule (i.e querydb),這個rule會查詢庫存資料庫有
無產品的存貨和相關資訊,這個rule在下一階段仍
會繼續使用,因為畢竟有東西可以賣是先決的條件。

下一步 (Knowledge Engineering)
例如:Buyer Agent在購買衣服時會順便附上使用者
的資料,如身高、體重、職業等,而Seller Agent可
以以它的領域知識,例如如果Buyer的身高、體重成
某種比例,那麼Buyer是一個胖子。如果Buyer是一
個胖子,就不能推薦橫條紋的衣服。
Seller Agent’s Rules
(defrule querydb
?m <- (TrackName ?n)
=>
(queryCDbyTrack ?m)
(retract ?m))
;querydb rule
;’queryCDbyTrack’ is a user-defined function
當 Seller Agent 接收到CFP訊息時,會新增一個Fact :
(assert (TrackName Every_breath_you_take))。
Buyer Agent


我們並不希望Buyer Agent在作購買的決策上
有絕對的自主權,而是希望Buyer Agent站在
決策輔助者的角色上,提供使用者足夠的資訊
來決定是否採取購買的行動。
Data Fusion
–
Buyer Agent不只是蒐集Data,而是更進一步做
Data的整理,來產生有用的information,這些
information是使用者做最終決策的基礎。在系統實
作上,採用針對proposal的各組成因子(如,價格),
提出comments。
Buyer Agent’s Rules
(defrule match-input ;match-input rule
?m <- (input ?c&:(external-addressp ?c))
=>
(assert (cdprice (call ?c getPrice)))
(retract ?m))
----------------------------------------------------(defrule compare-price ;compare-price
rule
?m <- (cdprice ?x)
(test (> ?x 500))
=>
(assert (comment (fetch CD)))
(assert (price2high (str-cat ?x "(***too
expensive)")))
(retract ?m))
(defrule price-comments
;price-comments rule
?m
<(comment
?c&:(externaladdressp ?c))
?n <- (price2high ?p)
=>
(call ?c setPrice ?p)
(retract ?m)
(retract ?n))
References

FIPA:http://www.fipa.org
JADE: http://sharon.cselt.it/projects/jade
JESS: http://herzberg.ca.sandia.gov/jess/

Joseph P. Bigus, Jennifer Bigus, “Constructing Intelligent



Agents Using Java: Professional Developer's Guide,
2/e”, JOHN WILEY & SONS,INC
Danny B. Lance, Mitsuru Oshima, “Programming And
Deploying Java Mobile Agents With Aglets”, ADDISONWESLEY

similar documents