Integrating and Engineering
Intelligent Systems
– Agent Programming –
O. Boissier
Univ. Lyon, IMT Mines Saint-Etienne, LaHC UMR CNRS 5516, France
UP AI Practices and Technologies DEFI IA – Winter 2020
UMR • CNRS • 5516 • SAINT-ETIENNEJaCaMo meta-model
Simplified view on JaCaMo meta-model [Boissier et al., 2011]
A seamless integration of three dimensions based on Jason [Bordini et al., 2007],
Cartago [Ricci et al., 2009], Moise [Hübner et al., 2009] meta-models
2
dynamic relationcompositionactcommunicateparticipateAgentAgentGoalBeliefActionOrganisationGroupSchemeRoleGoalOrganisationNormregulatecount-asempowerperceiveConceptDimensioncoordinateEnvironmentWorkspaceOperationEnvironmentArtifactObservablepropertyInteraction*OrganisationGroupSchemeRoleGoalOrganisationNormOrganisationGroupSchemeRoleGoalOrganisationNormPlanManualObservableeventEventOrganisationGroupSchemeRoleGoalOrganisationNormOrganisationGroupSchemeRoleGoalOrganisationNorm*MissionLinkAgent dimension
Simplified Conceptual View (Jason meta-model [Bordini et al., 2007]):
Simple Agent Program:
example bob.asl
example carl.asl
3
compositionAgentAgentGoalBeliefActionConceptDimensionAgentAgentGoalBeliefActionPlanAgentAgentGoalBeliefActionPlanEvent*Agent in JaCaMo: Jason
The foundational language for Jason is AgentSpeak
(cid:73) Originally proposed by Rao [Rao, 1996]
(cid:73) Programming language for BDI agents
(cid:73) Elegant notation, based on logic programming
(cid:73) Inspired by PRS [Georgeff and Lansky, 1987], dMARS
[d’Inverno et al., 1997], and BDI Logics [Rao et al., 1995]
(cid:73) Abstract programming language aimed at theoretical results
4
Jason
A practical implementation of a variant of AgentSpeak
(cid:73) Jason implements the operational semantics of a variant of
AgentSpeak
(cid:73) Has various extensions aimed at a more practical programming
language (e.g. definition of the MAS, communication, ...)
(cid:73) Highly customised to simplify extension and experimentation
(cid:73) Developed by Jomi F. Hübner, Rafael H. Bordini, and others
5
Outline
Agent Abstractions
Agent Dynamics
Other language features
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
6
Main Language Constructs
Beliefs: represent the information available to an agent (e.g.
about the environment or other agents)
Goals: represent states of affairs the agent wants to bring about
Plans: are recipes for action, representing the agent’s know-how
Actions can be internal, external, communicative or
organisational ones
Events: happen as consequence to changes in the agent’s beliefs
or goals
Intentions: plans instantiated to achieve some goal
Note: identifiers starting in upper case denote variables
7
Main Language Constructs and Runtime Structures
Beliefs: represent the information available to an agent (e.g.
about the environment or other agents)
Goals: represent states of affairs the agent wants to bring about
Plans: are recipes for action, representing the agent’s know-how
Actions can be internal, external, communicative or
organisational ones
Runtime structures:
Events: happen as consequence to changes in the agent’s beliefs
or goals
Intentions: plans instantiated to achieve some goal
Note: identifiers starting in upper case denote variables
7
(BDI & Jason) Hello World – agent bob
happy(bob).
!say(hello).
// B
// D
+!say(X) : happy(bob) <-
.print(X ).
// I
beliefs: prolog like (First Order Logic)
8
(BDI & Jason) Hello World – agent bob
happy(bob).
!say(hello).
// B
// D
+!say(X) : happy(bob) <-
.print(X ).
// I
beliefs: prolog like (First Order Logic)
desires: prolog like, with ! prefix
8
(BDI & Jason) Hello World – agent bob
happy(bob).
!say(hello).
// B
// D
+!say(X) : happy(bob) <-
.print(X ).
// I
beliefs: prolog like (First Order Logic)
desires: prolog like, with ! prefix
plans:
(cid:73) define when a desire becomes an intention (cid:59) deliberate
(cid:73) how it is satisfied
(cid:73) are used for practical reasoning (cid:59) means-end
8
(BDI & Jason) Hello World – agent bob
desires from perception – options
+happy(bob) <- !say(hello).
+!say(X) : not today(monday) <- .print(X ).
9
(BDI & Jason) Hello World – agent bob
source of beliefs
+happy(bob)[source(A )]
: someone_who_knows_me_very_well(A )
<- !say(hello).
+!say(X) : not today(monday) <- .print(X ).
10
(BDI & Jason) Hello World – agent bob
plan selection
+happy(H )[source(A )]
: sincere(A ) & .my_name(H )
<- !say(hello).
+happy(H )
: not .my_name(H )
<- !say(i_envy(H )).
+!say(X) : not today(monday) <- .print(X ).
11
(BDI & Jason) Hello World – agent bob
intention revision
+happy(H )[source(A )]
: sincere(A ) & .my_name(H )
<- !say(hello).
+happy(H )
: not .my_name(H )
<- !say(i_envy(H )).
+!say(X) : not today(monday) <- .print(X ); !say(X ).
-happy(H )
: .my_name(H )
<- .drop_intention(say(hello)).
12
(BDI & Jason) Hello World – agent bob
intention revision
+happy(H )[source(A )]
: sincere(A ) & .my_name(H )
<- !say(hello).
+happy(H )
: not .my_name(H )
<- !say(i_envy(H )).
+!say(X) : not today(monday) <- .print(X ); !say(X ).
-happy(H )
: .my_name(H )
<- .drop_intention(say(hello)).
12
(BDI & Jason) Hello World – agent bob
intention revision / Features
(cid:73) we can have several intentions based on the same plans
(cid:59) running concurrently
(cid:73) long term goal running
(cid:59) reaction meanwhile!
13
Beliefs representation
Agent Abstractions
Syntax
Beliefs are represented by annotated literals of first order logic
functor(term1, ..., termn)[annot1, ..., annotm]
Example (belief base of agent Tom)
red(box1)[source(percept)].
friend(bob,alice)[source(bob)].
lier(alice)[source(self),source(bob)].
~lier(bob)[source(self)].
14
Goals representation
Agent Abstractions
Syntax
Goals are represented as beliefs with a prefix:
(cid:73) ! to denote achievement goal (goal to do)
(cid:73) ? to denote test goal (goal to know)
Example (Initial goal of agent Tom)
!write(book).
15
Plans representation
Agent Abstractions
Syntax
An AgentSpeak plan has the following general structure:
triggering_event : context <- body.
where:
(cid:73) triggering_event: events that the plan is meant to handle
(cid:73) context: situations in which the plan can be used
(cid:73) body: course of action to be used to handle the event if the
context is believed to be true at the time a plan is being chosen to
Publicité
handle the event
16
Plans representation – Triggering events
Agent Abstractions
(cid:73) Events happen as consequence to changes in the agent’s beliefs or
goals
(cid:73) An agent reacts to events by executing plans
Syntax
(cid:73) belief addition: +b
(cid:73) belief deletion: -b
(cid:73) achievement-goal addition: +!g
(cid:73) achievement-goal deletion: -!g
(cid:73) test-goal addition: +?g
(cid:73) test-goal deletion): -?g
17
Plans representation – Context
Agent Abstractions
Context is a boolean expression with the following operators:
Syntax
(cid:73) Boolean operators
& (and)
| (or)
not (not)
= (unification)
>, >= (relational)
<, <= (relational)
== (equals)
\ == (different)
(cid:73) Arithmetic operators
+ (sum)
- (subtraction)
- (multiply)
/ (divide)
div (divide – integer)
mod (remainder)
** (power)
18
Plans representation – Body
Agent Abstractions
A plan body may contain:
(cid:73) Belief operators
+ (new belief)
- (dispose belief)
-+ (update belief)
(cid:73) Goal operators
! (new achievement sub-goal)
? (new test sub-goal)
!! (new achievement goal)
(cid:73) External actions defined from artifact operations (see course on
Agent Working Environment)
(cid:73) Internal actions
(cid:73) Unlike actions, internal actions do not change the environment
(cid:73) Encapsulate code to be executed as part of the agent reasoning
cycle
(cid:73) Internal actions can be used for invoking legacy code
(cid:73) Constraints
19
Internal Actions
Agent Abstractions
(cid:73) Internal actions can be defined by the user in Java
libname.action_name(...)
(cid:73) Standard (pre-defined) internal actions in standard library (no
library name):
(cid:73) .print(term1, term2, . . .)
(cid:73) .union(list1, list2, list3)
(cid:73) .my_name(var )
(cid:73) .send(ag,perf ,literal)
(cid:73) .intend(literal)
(cid:73) .drop_intention(literal)
(cid:73) Many others available for: printing, sorting, list/string operations,
manipulating the beliefs/annotations/plan library, creating agents,
waiting/generating events, etc.
20
Plans representation
Agent Abstractions
Example
+rain : time_to_leave(T) & clock.now(H) & H >= T
// new sub-goal
<- !g1;
// new goal
// new test goal
// add mental note
!!g2;
?b(X);
+b1(T-H);
-b2(T-H);
-+b3(T*H);
jia.get(X); // internal action
X > 10;
close(door);// external action
!g3[hard_deadline(3000)].
// remove mental note
// update mental note
// constraint to carry on
// goal with deadline
21
Plans representation
Agent Abstractions
Example
+green_patch(Rock)[source(percept)]
: not battery_charge(low)
<- ?location(Rock,Coordinates);
!at(Coordinates);
!examine(Rock).
+!at(Coords)
: not at(Coords) & safe_path(Coords)
<- move_towards(Coords);
!at(Coords).
+!at(Coords)
: not at(Coords) & not safe_path(Coords)
<- ...
+!at(Coords) : at(Coords).
22
Outline
Agent Abstractions
Agent Dynamics
Other language features
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
23
Agent dynamics
Agent Dynamics
24
SIEventsExternalEventSelectedSEBeliefs toAdd andDeleteRelevantPlansNew PlanPushIntentionUpdatedOSApplicablePlansMeansIntendedEventsExternalPlanLibraryEventsInternalEvents3checkMailIntentionsExecuteIntention...NewNew9BeliefBaseNewIntentionPerceptsactSelectedIntentionIntentionsActionPercepts12BUF10EventsContextCheckEventUnifyBRFBeliefsAgentsendMsgBeliefs8MessagesPlansperceive756ActionsBeliefsSuspended Intentions(Actions and Msgs)....sendSocAcc4MessagesMessagesSMBasic Reasoning cycle
runtime interpreter
(cid:73) perceive the environment and update belief base
(cid:73) process new messages
(cid:73) select event
(cid:73) select relevant plans
(cid:73) select applicable plans
(cid:73) create/update intention
(cid:73) select intention to execute
(cid:73) execute one step of the selected intention
25
Basic Reasoning Cycle
26
SIEventsExternalEventSelectedSEBeliefs toAdd andDeleteRelevantPlansNew PlanPushIntentionUpdatedOSApplicablePlansMeansIntendedEventsExternalPlanLibraryEventsInternalEvents3checkMailIntentionsExecuteIntention...NewNew9BeliefBaseNewIntentionPerceptsactSelectedIntentionIntentionsActionPercepts12BUF10EventsContextCheckEventUnifyBRFBeliefsAgentsendMsgBeliefs8MessagesPlansperceive756ActionsBeliefsSuspended Intentions(Actions and Msgs)....sendSocAcc4MessagesMessagesSMBasic Reasoning Cycle
26
JasonReasoningCycleSIEventsExternalEventSelectedSEBeliefs toAdd andDeleteRelevantPlansNew PlanPushIntentionUpdatedOSApplicablePlansMeansIntendedEventsExternalPlanLibraryEventsInternalEvents3checkMailIntentionsExecuteIntention...NewNew9BeliefBaseNewIntentionPerceptsactSelectedIntentionIntentionsActionPercepts12BUF10EventsContextCheckEventUnifyBRFBeliefsAgentsendMsgBeliefs8MessagesPlansperceive756ActionsBeliefsSuspended Intentions(Actions and Msgs)....sendSocAcc4MessagesMessagesSM26ImachineperceptionIbeliefrevisonIknowledgerepresentationIcommunication,argumentationItrustIsocialpowerBasic Reasoning Cycle
26
JasonReasoningCycleSIEventsExternalEventSelectedSEBeliefs toAdd andDeleteRelevantPlansNew PlanPushIntentionUpdatedOSApplicablePlansMeansIntendedEventsExternalPlanLibraryEventsInternalEvents3checkMailIntentionsExecuteIntention...NewNew9BeliefBaseNewIntentionPerceptsactSelectedIntentionIntentionsActionPercepts12BUF10EventsContextCheckEventUnifyBRFBeliefsAgentsendMsgBeliefs8MessagesPlansperceive756ActionsBeliefsSuspended Intentions(Actions and Msgs)....sendSocAcc4MessagesMessagesSM27IplanningIreasoningIdecisiontheoretictechniquesIlearning(reinforcement)Basic Reasoning Cycle
26
JasonReasoningCycleSIEventsExternalEventSelectedSEBeliefs toAdd andDeleteRelevantPlansNew PlanPushIntentionUpdatedOSApplicablePlansMeansIntendedEventsExternalPlanLibraryEventsInternalEvents3checkMailIntentionsExecuteIntention...NewNew9BeliefBaseNewIntentionPerceptsactSelectedIntentionIntentionsActionPercepts12BUF10EventsContextCheckEventUnifyBRFBeliefsAgentsendMsgBeliefs8MessagesPlansperceive756ActionsBeliefsSuspended Intentions(Actions and Msgs)....sendSocAcc4MessagesMessagesSM28IintentionreconsiderationIschedulingIactiontheoriesBeliefs dynamics
Agent Dynamics
Internal reasoning
The plan operators + and - can be used to add and remove beliefs
annotated with source(self) (mental notes)
+lier(alice); // adds lier(alice)[source(self)]
-lier(john); // removes lier(john)[source(self)]
Perception (from the environment)
Beliefs are automatically updated accordingly to the perception of the
agent (annotated with source(percept))
27
Beliefs dynamics
Agent Dynamics
Communication (from other agents)
When an agent receives a tell (resp. untell) message, the content is a
new belief (annotated with the sender of the message) (resp. belief
corresponding to the content is deleted)
.send(tom,tell,lier(alice)); // sent by bob
// adds lier(alice)[source(bob)] in Tom’s Belief Base
...
.send(tom,untell,lier(alice)); // sent by bob
// removes lier(alice)[source(bob)] from Tom’s Belief Base
28
Goals dynamics
Agent Dynamics
Internal reasoning
The plan operators !, !! and ? are used to add a new goal (annotated
with source(self))
...
// adds new achievement goal !write(book)[source(self)]
!write(book);
// adds new test goal ?publisher(P)[source(self)]
?publisher(P);
...
29
Goals dynamics
Agent Dynamics
Communication of achievement goal
When an agent receives an achieve message, the content is a new
achievement goal (annotated with the sender of the message)
.send(tom,achieve,write(book)); // sent by Bob
// adds new goal write(book)[source(bob)] for Tom
.send(tom,unachieve,write(book)); // sent by Bob
// removes goal write(book)[source(bob)] for Tom
Communication of test goal
When an agent receives an askOne or askAll message, the content is a
new test goal (annotated with the sender of the message)
Publicité
.send(tom,askOne,published(P),Answer); // sent by Bob
// adds new goal ?publisher(P)[source(bob)] for Tom
// the response of Tom will unify with Answer
30
Plans dynamics
Agent Dynamics
The plans that form the plan library of the agent come from
(cid:73) plans added (resp. removed) dynamically by intentions in internal
reasoning:
(cid:73) .add_plan (resp. .remove_plan)
(cid:73) plans added (resp. removed) by communication:
(cid:73) tellHow (resp. untellHow)
Example
.send(bob, askHow, +!goto(_,_)[source(_)], ListOfPlans);
...
.plan_label(Plan,hp); // get a plans based on a plan’s label
.send(A,tellHow,Plan);
.send(bob,tellHow,"+!start :
true <- .println(¨hello¨).").
31
A note about “Control”
Agents can control (manipulate) their own (and influence the others)
(cid:73) beliefs
(cid:73) goals
(cid:73) plan
By doing so they control their behaviour
The developer provides initial values of these elements and thus also
influence the behaviour of the agent
32
Outline
Agent Abstractions
Agent Dynamics
Other language features
Namespaces
Strong Negation
Prolog-like Rules
Plan Annotations & Concurrent Plans
Declarative Goal Patterns
Meta Programming
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
33
Outline
Agent Abstractions
Agent Dynamics
Other language features
Namespaces
Strong Negation
Prolog-like Rules
Plan Annotations & Concurrent Plans
Declarative Goal Patterns
Meta Programming
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
34
Namespace
Other language features
(cid:73) Abstract container in the mind of agent, created to hold a logical
grouping of beliefs, goals, events, plans and actions
(cid:73) Identified by a name, used to prefix (using ::) the elements
belonging to it:
ns1::color(box,blue) // color is in namespace ns1
(cid:73) Two types:
(cid:73) Global namespace: any element associated with the global
namespace can be consulted, changed by any other namespace
(cid:73) Local namespace: elements can only be used by the namespace
(cid:73) (cid:59) possibility of sharing elements by means of a common global
namespace
(cid:73) Namespace can be defined by:
(cid:73) module program of beliefs, goals and plans (i.e. a usual agent
program).
Every agent has one initial module (its initial program) into which
other modules can be loaded
(cid:73) associating observable properties or actions of artifacts
35
Modules and Namespaces
Other language features
36
Namespaces&Modularity51Modules and Namespaces
Other language features
37
Namespaces&Modularity–include(”initiator.asl”,pc)˝–include(”initiator.asl”,tv)˝!pc::startCNP(fix(pc)).!tv::startCNP(fix(tv)).+pc::winner(X)¡-.print(X).52Outline
Agent Abstractions
Agent Dynamics
Other language features
Namespaces
Strong Negation
Prolog-like Rules
Plan Annotations & Concurrent Plans
Declarative Goal Patterns
Meta Programming
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
38
Strong Negation
Other language features
+!leave(home)
: ~raining
<- open(curtains); ...
+!leave(home)
: not raining & not ~raining
<- .send(mum,askOne,raining,Answer,3000); ...
39
Outline
Agent Abstractions
Agent Dynamics
Other language features
Namespaces
Strong Negation
Prolog-like Rules
Plan Annotations & Concurrent Plans
Declarative Goal Patterns
Meta Programming
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
40
Prolog-like Rules in the Belief Base
Other language features
tall(X) :-
woman(X) & height(X, H) & H > 1.70
|
man(X) & height(X, H) & H > 1.80.
likely_color(Obj,C) :-
colour(Obj,C)[degOfCert(D1)] &
not (colour(Obj,_)[degOfCert(D2)] & D2 > D1) &
not ~colour(C,B).
41
Outline
Agent Abstractions
Agent Dynamics
Other language features
Namespaces
Strong Negation
Prolog-like Rules
Plan Annotations & Concurrent Plans
Declarative Goal Patterns
Meta Programming
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
42
Plan Annotations
Other language features
(cid:73) Like beliefs, plans can also have annotations, which go in the plan
label
(cid:73) Annotations contain meta-level information for the plan, which
selection functions can take into consideration
(cid:73) The annotations in an intended plan instance can be changed
dynamically (e.g. to change intention priorities)
(cid:73) There are some pre-defined plan annotations, e.g. to force a
breakpoint at that plan or to make the whole plan execute
atomically
Example (an annotated plan)
@myPlan[chance_of_success(0.3), usual_payoff(0.9),
any_other_property]
+!g(X) : c(t) <- a(X).
43
Concurrent Plans
Other language features
(cid:73) fork-join-and operator |&|
+!ga <- ...; !gb; ....
+!gb <- ...; (!g1 |&| !g2); a1; ... // fork-join-and
// a1 will be executed when !g2 and !g1 will be achieved
(cid:73) fork-join-xor operator |||
+!ga <- ...; !gb; ....
+!gb <- ...; (!g1 ||| !g2); a1; ... // fork-join-xor
// a1 will be executed after !g2 or !g1 are achieved
// when one of !g2 or !g1 is achieved the other is dropped
// in case of some failure
// in case of some failure
-!g1 : true <- !g1.
-!g2 : true <- !g2.
+g1 : true <- .succeed_goal(g1).
+g2 : true <- .succeed_goal(g2).
+f1 : true <- .fail_goal(g1).
+f2 : true <- .fail_goal(g2).
// f1 drop condition for g1
// f2 drop condition for g2
44
Outline
Agent Abstractions
Publicité
Agent Dynamics
Other language features
Namespaces
Strong Negation
Prolog-like Rules
Plan Annotations & Concurrent Plans
Declarative Goal Patterns
Meta Programming
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
45
Declarative Goal Patterns: Achievement goal
Other language features
Example (Example)
+!g : g <- true. // g declarative goal
+!g : c1 <- p1; ?g.
+!g : c2 <- p2; ?g.
...
+!g : cn <- pn; ?g.
+g : true <- .succeed_goal(g).
46
Backtracking Declarative Goal Patterns
Other language features
Example (Example)
+!g : g <- true. // g declarative goal
+!g : c1 <- p1; ?g.
+!g : c2 <- p2; ?g.
...
+!g : cn <- pn; ?g.
+g : true <- .succeed_goal(g).
-!g : true <- !!g.
47
Exclusive Backtracking Declarative Goal Pattern
Other language features
Example (Example)
+!g : g <- true. // g declarative goal
+!g : not p(1,g) & c1 <- +p(1,g); p1; ?g.
+!g : not p(2,g) & c2 <- +p(2,g); p2; ?g.
...
+!g : not p(n,g) & cn <- +p(n,g); pn; ?g.
-?g : true <- !!g.
+g : true <- .abolish(p(_,g); .succeed_goal(g).
48
Failure Handling: Contingency Plans
Other language features
Example (Example)
!g1 // initial goal
+!g1 : true <- !g2(X); .print(“end g1 “,X).
+!g2 : true <- !g3(X); .print(“end g2 “,X).
+!g3 : true <- !g4(X); .print(“end g3 “,X).
+!g4 : true <- !g5(X); .print(“end g4 “,X).
+!g5 : true <- .fail.
-!g3(X) : true <- .print(“in g3 failure”).
49
Failure Handling: Contingency Plans
Other language features
Example (Example)
!g1 // initial goal
+!g1 : true <- !g2(X); .print(“end g1 “,X).
+!g2 : true <- !g3(X); .print(“end g2 “,X).
+!g3 : true <- !g4(X); .print(“end g3 “,X).
+!g4 : true <- !g5(X); .print(“end g4 “,X).
+!g5 : true <- .fail.
-!g3(X) : true <- .print(“in g3 failure”).
saying: in g3 failure
saying: end g2 failure
saying: end g1 failure
49
Failure Handling: Contingency Plans
Other language features
Example (blind commitment to g)
+!g : g. // g is a declarative goal
+!g : ... <- a1; ?g.
+!g : ... <- a2; ?g.
+!g : ... <- a3; ?g.
+!g : true <- !g. // keep trying
-!g : true <- !g. // in case of some failure
+g : true <- .succeed_goal(g).
50
Failure Handling: Contingency Plans
Other language features
Example (single minded commitment)
+!g : g. // g is a declarative goal
+!g : ... <- a1; ?g.
+!g : ... <- a2; ?g.
+!g : ... <- a3; ?g.
+!g : true <- !g. // keep trying
-!g : true <- !g. // in case of some failure
+g : true <- .succeed_goal(g).
+f : true <- .fail_goal(g).
condition for g
// f is the drop
51
Failure Handling: Compiler pre-processing – directives
Other language features
Example (single minded commitment)
{ begin smc(g,f)}
+!g : ... <- a1.
+!g : ... <- a2.
+!g : ... <- a3.
{ end }
52
Outline
Agent Abstractions
Agent Dynamics
Other language features
Namespaces
Strong Negation
Prolog-like Rules
Plan Annotations & Concurrent Plans
Declarative Goal Patterns
Meta Programming
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
53
Meta Programming
Other language features
Example (an agent that asks for plans on demand)
-!G[error(no_relevant)] :
teacher(T)
<- .send(T, askHow, { +!G }, Plans);
.add_plan(Plans);
!G.
in the event of a failure to achieve any goal G due to no relevant
plan, asks a teacher for plans to achieve G and then try G again
(cid:73) The failure event is annotated with the error type, line, source, ...
error(no_relevant) means no plan in the agent’s plan library to
achieve G
(cid:73) { +!G } is the syntax to enclose triggers/plans as terms
54
Outline
Agent Abstractions
Agent Dynamics
Other language features
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
55
Integrating A & A dimensions
56
dynamic relationcompositionAgentAgentGoalBeliefActionConceptDimensionInteractioncommunicateAgentAgentGoalBeliefActionPlanAgentAgentGoalBeliefActionAgentAgentGoalBeliefActionPlanAgentAgentGoalBeliefActionPlanEventCommunicative Actions
Use of the internal action .send with performative verbs and
corresponding content:
(cid:73) tell, untell: to share beliefs,
(cid:73) achieve, unachieve: to delegate achievement goal,
(cid:73) askOne, askAll: to delegate test goal,
(cid:73) askHow: to request plans,
(cid:73) tellHow, untellHow: to share plans.
57
Outline
Agent Abstractions
Agent Dynamics
Other language features
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
58
Jason Customisations
(cid:73) Agent class customisation:
selectMessage, selectEvent, selectOption, selectIntention, buf, brf,
...
(cid:73) Agent architecture customisation:
perceive, act, sendMsg, checkMail, ...
(cid:73) Belief base customisation:
add, remove, contains, ...
(cid:73) Example available with Jason: persistent belief base (in text files, in
data bases, ...)
59
Outline
Agent Abstractions
Agent Dynamics
Other language features
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
60
Jason × Java
Consider a very simple robot with two goals:
(cid:73) when a piece of gold is seen, go to it
(cid:73) when battery is low, go charge it
61
Java code – go to gold
public class Robot extends Thread {
Publicité
boolean seeGold, lowBattery;
public void run() {
while (true) {
while (! seeGold) {
a = randomDirection();
doAction(go(a));
}
while (seeGold) {
a = selectDirection();
doAction(go(a));
}
} }
}
62
Java code – charge battery
public class Robot extends Thread {
boolean seeGold, lowBattery;
public void run() {
while (true) {
while (! seeGold) {
a = randomDirection();
doAction(go(a));
if (lowBattery) charge();
}
while (seeGold) {
a = selectDirection ();
if (lowBattery) charge();
doAction(go(a));
if (lowBattery) charge();
}
} }
}
63
Jason code
direction(gold)
direction(random) :- not see(gold).
:- see(gold).
+!find(gold)
// long term goal
<- ?direction(A);
go(A);
!find(gold).
+battery(low)
<- !charge.
// reactivity
ˆ!charge[state(started)]
// goal meta-events
<- .suspend(find(gold)).
ˆ!charge[state(finished)]
<- .resume(find(gold)).
64
Fibonacci calculator server – “java” version
65
Fibonaccicalculatorserver–“java”versionFibonaccerBobAlicefib(40)fib(3)whiletrueintfib(intn)m=receiveMsg()ifn¡=2ifm==fib(N)return1m.answer(fib(m.getArg(0)))else...returnfib(n-1)+fib(n-2)HowlongwillAlicewait?59Fibonacci calculator server – Akka
66
Fibonaccicalculatorserver–Akka60Fibonacci calculator agent – Jason version
67
Fibonaccicalculatoragent–versionJasonFibonaccerBobAlicefib(40)fib(3)+?fib(1,1).+?fib(2,1).+?fib(N,F)¡-?fib(N-1,A);?fib(N-2,B);F=A+B.HowlongwillAlicewait?61Fibonacci calculator agent – Jason version
68
Fibonaccicalculatorserver–Jason62Jason × Prolog
(cid:73) With the Jason extensions, nice separation of theoretical and
practical reasoning
(cid:73) BDI architecture allows
(cid:73) long-term goals (goal-based behaviour)
(cid:73) reacting to changes in a dynamic environment
(cid:73) handling multiple foci of attention (concurrency)
(cid:73) Acting on an environment and a higher-level conception of a
distributed system
69
Outline
Agent Abstractions
Agent Dynamics
Other language features
Integrating A & A dimensions
Agent Management Infrastructure in JaCaMo
Comparison with other paradigms
Conclusions and wrap-up
70
Some Shortfalls
(cid:73) IDEs and programming tools are still not anywhere near the level
of OO languages
(cid:73) Debugging is a serious issue — much more than “mind tracing” is
needed
(cid:73) Combination with organisational models is very recent — much
work still needed
(cid:73) Principles for using declarative goals in practical programming
problems still not “textbook”
(cid:73) Large applications and real-world experience much needed!
71
Some Trends
(cid:73) Modularity and encapsulation
(cid:73) Debugging MAS is hard: problems of concurrency, simulated
environments, emergent behaviour, mental attitudes
(cid:73) Logics for Agent Programming languages
(cid:73) Further work on combining with interaction, environments, and
organisations
(cid:73) We need to put everything together: rational agents,
environments, organisations, normative systems, reputation
systems, economically inspired techniques, etc.
(cid:59) Multi-Agent Programming
72
Some Related Projects I
(cid:73) Speech-act based communication
Joint work with Renata Vieira, Álvaro Moreira, and Mike
Wooldridge
(cid:73) Cooperative plan exchange
Joint work with Viviana Mascardi, Davide Ancona
(cid:73) Plan Patterns for Declarative Goals
Joint work with M.Wooldridge
(cid:73) Planning (Felipe Meneguzzi and Colleagues)
(cid:73) Web and Mobile Applications (Alessandro Ricci and Colleagues)
(cid:73) Belief Revision
Joint work with Natasha Alechina, Brian Logan, Mark Jago
73
Some Related Projects II
(cid:73) Ontological Reasoning
(cid:73) Joint work with Renata Vieira, Álvaro Moreira
(cid:73) JASDL: joint work with Tom Klapiscak
(cid:73) Goal-Plan Tree Problem (Thangarajah et al.)
Joint work with Tricia Shaw
(cid:73) Trust reasoning (ForTrust project)
(cid:73) Agent verification and model checking
Joint project with M.Fisher, M.Wooldridge, W.Visser, L.Dennis,
B.Farwer
74
Some Related Projects III
(cid:73) Environments, Organisation and Norms
(cid:73) Normative environments
Join work with A.C.Rocha Costa and F.Okuyama
(cid:73) MADeM integration (Francisco Grimaldo Moreno)
(cid:73) Normative integration (Felipe Meneguzzi)
(cid:73) More on jason.sourceforge.net, related projects
75
Summary
(cid:73) AgentSpeak
(cid:73) Logic + BDI
(cid:73) Agent programming language
(cid:73) Jason
(cid:73) AgentSpeak interpreter
(cid:73) Implements the operational semantics of AgentSpeak
(cid:73) Speech-act based communicaiton
(cid:73) Highly customisable
(cid:73) Useful tools
(cid:73) Open source
(cid:73) Open issues
76
Further Resources
(cid:73) http://jason.sourceforge.net
(cid:73) R.H. Bordini, J.F. Hübner, and
M. Wooldrige
Programming Multi-Agent Systems in
AgentSpeak using Jason
John Wiley & Sons, 2007.
77
Bibliography I
Boissier, O., Bordini, R. H., Hübner, J. F., Ricci, A., and Santi, A. (2011).
Multi-agent oriented programming with jacamo.
Science of Computer Programming, pages –.
Bordini, R. H., Hübner, J. F., and Wooldrige, M. (2007).
Programming Multi-Agent Systems in AgentSpeak using Jason.
Wiley Series in Agent Technology. John Wiley & Sons.
d’Inverno, M., Kinny, D., Luck, M., and Wooldridge, M. (1997).
A formal specification of dmars.
In International Workshop on Agent Theories, Architectures, and Languages,
pages 155–176. Springer.
Georgeff, M. P. and Lansky, A. L. (1987).
Reactive reasoning and planning.
In AAAI, volume 87, pages 677–682.
Hübner, J. F., Boissier, O., Kitio, R., and Ricci, A. (2009).
Instrumenting Multi-Agent Organisations with Organisational Artifacts and
Agents.
Journal of Autonomous Agents and Multi-Agent Systems.
78
Bibliography II
Rao, A. S. (1996).
Agentspeak(l): Bdi agents speak out in a logical computable language.
In de Velde, W. V. and Perram, J. W., editors, MAAMAW, volume 1038 of
Lecture Notes in Computer Science, pages 42–55. Springer.
Rao, A. S., Georgeff, M. P., et al. (1995).
Bdi agents: From theory to practice.
In ICMAS, volume 95, pages 312–319.
Ricci, A., Piunti, M., Viroli, M., and Omicini, A. (2009).
Environment programming in CArtAgO.
In Multi-Agent Programming: Languages,Platforms and Applications,Vol.2.
Springer.
79