Download presentation
Presentation is loading. Please wait.
Published byPercival Wade Modified over 10 years ago
1
Introduction to AgentSpeak and Jason for Programming Multi-agent Systems (2) Dr Fuhua (Oscar) Lin SCIS Athabasca University June 19, 2009
2
The Procedural Reasoning System 5/16/2015Athabasca University2 Beliefs Intentions Plan library Desires Interpreter Sensor input Action output
3
Introduction Jason is a fully-fledged interpreter for an extended version of AgentSpeak, a BDI agent- oriented logic programming language, and is implemented in Java. Using SACI or JADE, a multi-agent system can be distributed over a network effortlessly. 5/16/20153Athabasca University
4
Saci (Simple Agent Communication Infrastructure) is a tool that facilitates the task of programming communication among distributed agents. The main features provided by Saci are an API to manipulate KQML messages like composing, sending and receiving and tools to provide useful services in a distributed environment like – agent name service, – directory service, – remote launching, – communication debug, to name a few. 5/16/20154Athabasca University
5
MAS Configuration File Simple way of defining a multi-agent system MAS my_system { infrastructure: Jade environment: MyEnv ExecuctionControl: … agents: ag1; ag2; ag3; } 5/16/20155Athabasca University
6
MAS Definition (Cont.) Infrastructure options: Centralized, Saci, Jade Easy to define the host where agents and the environment will run If the file name with the code is unusual agents: ag1 at host1.dur.ac.uk; agents: ag1 file1; 5/16/20156Athabasca University
7
When should I Use the SACI or JADE Infrastructure? The centralized infrastructure does not support: – Execution of the agents at distributed hosts, and – Interoperability with non-Jason agents If you need any of these features, you should choose the SACI or JADE infrastructures or implement/plug a new infrastructure for/into Jason yourself). 5/16/20157Athabasca University
8
Execution Modes 5/16/2015Athabasca University8 1 2 3 AsynchronousSynchronous 1 2 3 Debug
9
Jason Reasoning Cycle 5/16/20159Athabasca University
10
Jason Reasoning Cycle 5/16/201510Athabasca University
11
Jason Reasoning Cycle 5/16/201511Athabasca University
12
Belief Annotations Annotated predicate: ps(t1, …, tn) [a1, …, am] where ai are first order terms All predicates in the belief base have a special annotation source(si) where si belongs to {self, percept} or AgId 5/16/201512Athabasca University
13
Example of Annotations An agent’s belief base with a user-defined doc annotation (degree of certainty --- doc) blue(box1)[source(ag1)] red(box1)[source(percept)] colourblind(ag1)[source(self), doc(0.7)] lier(ag1)[source(self), doc(0.2)] 5/16/201513Athabasca University
14
Plan Annotations Plan labels also can have annotations (e.g. to specify meta-level information) Selection functions (Java) can use such information in plan/intention selection Possible to change those annotations dynamically (e.g., to update priorities) Annotations go in the plan label 5/16/201514Athabasca University
15
Annotated Plan Example @aPlan[ chance_of_success(0.3), usual_payoff(0.9), any_other_property] +!g(X) : c(t) <- a(X). 5/16/201515Athabasca University
16
Handling Plan Failure Goal-deletion events were syntactically defined, but no semantics We use them for a plan failure handling mechanism (probably not what they were meant for) Handling plan failure is very important as agents are situated in dynamic environments A form of “contingency ( 机动 ) plan”, possibly to “clean up” before attempting another plan 5/16/201516Athabasca University
17
Contingency Plan Example To create an agent that is blindly committed to goal g: +!g : g <- true +!g : … <- … ?g … -!g : true <- !g 5/16/201517Athabasca University
18
Internal Actions Unlike actions, internal actions do not change the environment Code to be executed as part of the agent reasoning cycle AgentSpeak is meant as a high-level language for the agent’s practical reasoning Internal actions can be used for invoking legacy code elegantly 5/16/201518Athabasca University
19
Internal Actions (Cont.) Libraries of user-defined internal actions lib_name.action_name(...) Pre-defined internal actions have an empty library name Internal action for communication.send(r,ilf,pc) where ilf ∈ {tell, untell, achieve, unachieve, askOne, askAll, askHow, tellHow, untellHow} 5/16/201519Athabasca University
20
Internal Actions (Cont.) Examples of BDI-related internal actions:.desire(literal).intend(literal).drop_desires(literal).drop_intentions(literal) Many others available for: printing, list/string operations, manipulating the beliefs/annotations/plan library, creating agents, waiting/generation events, etc. 5/16/201520Athabasca University
21
A Jason Plan +green_patch(Rock) : ~battery_charge(low) &.desire(at(_)) <-.drop_desires(at(_)); dip.get_coords(Rock, Coords); !at(Coords); !examine(Rock). 5/16/201521Athabasca University
22
AgentSpeak X Prolog With the Jason extensions, nice separation of theoretical and practical reasoning BDI architecture allows – long-term goals (goal-based behavior) – reacting to changes in a dynamic environment – handling multiple foci of attention (concurrency) Acting on an environment and a higher-level conception of a distributed system Direct integration with Java 5/16/201522Athabasca University
23
Agent Customization Users can customize the Agent class to define the selection functions, social relations for communication, and belief update and revision (buf and brf) – selectMessage() – selectEvent() – selectOption() – selectIntention() – socAcc() – buf() – brf() 5/16/201523Athabasca University
24
Overall Agent Architecture Users customize the AgentArch class to change the way the agent interacts with the infrastructure: perception, action, and communication Helps switching between simulation for testing and real deployment – perceive() – act() – sendMsg() – broadcast() – checkMail() 5/16/201524Athabasca University
25
Belief Base Customization Logical belief base might not be appropriate for large applications Jason has an alternative belief base combined with a database Users can create other customization – add() – remove() – contain() – getRelevant() 5/16/201525Athabasca University
26
Customized MAS MAS Custom { agents: a1 agentClass MyAg agentBaseClass MyAgArch beliefBaseClass Jason.bb.JDBCPersistentBB( “org.hsqldb.jdbcDriver”, “jdbc:hsqldb:bookstore”, … ”[count_exec(1, tablece)]”); } 5/16/201526Athabasca University
27
An Example Jason is available Open Source under GNU LGPL at: http://jason.sf.nethttp://jason.sf.net 5/16/201527Athabasca University
28
An Agent-based Auction Game (Simplified) Goal Overview Diagram 5/16/201528Athabasca University
29
System Overview Diagram 5/16/201529Athabasca University
30
auction.mas2j // creates an MAS called auction MAS auction { infrastructure: Centralised agents: ag1; ag2; ag3; auctioneer agentArchClass AuctioneerGUI; } 5/16/201530Athabasca University
31
Agent overview diagram: Agent Auctioneer 5/16/201531Athabasca University
32
auctioneer.asl // this agent starts the auction and identify the winner /* beliefs and rules */ all_bids_received(N) :-.count(place_bid(N,_),3). /* plans */ +!start_auction(N) : true // this goal is created by the GUI of the agent <- -+auction(N); -+winner(N, noone, 0);.broadcast(tell, auction(N)). // receive bid and check for new winner @pb1[atomic] +place_bid(N,V)[source(S)] : auction(N) & winner(N,CurWin,CurVl) & V > CurVl <- -winner(N,CurWin,CurVl); +winner(N,S,V);.print("New winner is ",S, " with value ",V); !check_end(N). @pb2[atomic] +place_bid(N,_) : true <- !check_end(N). +!check_end(N) : all_bids_received(N) & winner(N,W,Vl) <-.print("Winner is ",W," with ", Vl); show_winner(N,W); // show it in the GUI.broadcast(tell, winner(W));.abolish(place_bid(N,_)). +!check_end(_). 5/16/201532Athabasca University
33
Agent overview diagram: Agent ag1 5/16/201533Athabasca University
34
ag1.asl // this agent always bids 6 +auction(N)[source(S)] : true <-.send(S, tell, place_bid(N,6)). 5/16/201534Athabasca University
35
Agent overview diagram: Agent ag2 5/16/201535Athabasca University
36
ag2.asl // This agent usually bids 4, when it has an alliance with ag3, it bids 0 default_bid_value(4). ally(ag3). +auction(N)[source(S)] : not alliance <- ?default_bid_value(B);.send(S, tell, place_bid(N,B)). +auction(N)[source(S)] : alliance <-.send(S, tell, place_bid(N,0)). // alliance proposal from another agent +alliance[source(A)] :.my_name(I) & ally(A) <-.print("Alliance proposed by ", A); ?default_bid_value(B);.send(A,tell,bid(I,B));.send(A,tell,alliance(A,I)). 5/16/201536Athabasca University
37
Agent overview diagram: Agent ag3 5/16/201537Athabasca University
38
ag3.asl // this agent bids 3, if it looses 3 auctions, it proposes an alliance to ag2 and therefore it bids 7 (3 from itself + 4 from ag2) default_bid_value(3). ally(ag2). threshold(3). +auction(N)[source(S)] : (threshold(T) & N < T) | (.my_name(I) & winner(I) & ally(A) & not alliance(I,A)) <- !bid_normally(S,N). +auction(N)[source(S)] :.my_name(I) & not winner(I) & ally(A) & not alliance(I,A) <- !alliance(A); !bid_normally(S,N). @palliance +auction(N)[source(S)] : alliance(_,A) <- ?default_bid_value(B); ?bid(A,C);.send(S, tell, place_bid(N,B+C)). +!bid_normally(S,N) : true <- ?default_bid_value(B);.send(S, tell, place_bid(N,B)). @prop_alliance[breakpoint] +!alliance(A) : true <-.send(A,tell,alliance). 5/16/201538Athabasca University
39
Protocol auction Nameauction Description Included messagesnew auction: auctioneer agent --> ag1, ag2, ag3, bid: ag1 --> auctioneer agent, bid: ag2 --> auctioneer agent, bid: ag3 --> auctioneer agent, winner announcement: auctioneer agent --> ag1, ag2, ag3 Scenarios Agents auctioneer agent, ag1, ag2, ag3 5/16/201539Athabasca University
40
Protocol alliance Namealliance Description Included messages alliance proposal: ag3 ag2, alliance accepted: ag2 ag3 Scenarios Agents ag1, ag2 5/16/201540Athabasca University
41
console [auctioneer] New winner is ag1 with value 6 [auctioneer] Winner is ag1 with 6 [auctioneer] New winner is ag3 with value 3 [auctioneer] New winner is ag1 with value 6 [auctioneer] Winner is ag1 with 6 [auctioneer] New winner is ag2 with value 4 [ag2] Alliance proposed by ag3 [auctioneer] New winner is ag1 with value 6 [auctioneer] Winner is ag1 with 6 [auctioneer] New winner is ag1 with value 6 [auctioneer] New winner is ag3 with value 7 [auctioneer] Winner is ag3 with 7 5/16/201541Athabasca University
42
5/16/201542Athabasca University
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.