Agent Oriented Programming Lucas Schroeder 4/10/2007

advertisement
Agent Oriented Programming
Lucas Schroeder
4/10/2007
Outline
Introduction
Definition
Architecture & Language
Example
New Work
Questions
Introduction
Based on the paper
Agent-oriented Programming
By Yoav Shoham (Feb 1992)
Highly Cited (1619) – Google Scholar
Definitions
Agent
“… an entity whose state is viewed as
consisting of mental components such as
beliefs, capabilities, choices, and
commitments.”
This means anything
But what is gained by adopting this viewpoint?
Agent - Example
“It is perfectly coherent to treat a light switch as
a (very cooperative) agent with the capability of
transmitting current at will, who invariably
transmits current when it believes that we want it
transmitted and not otherwise; flicking the switch
is simply our way of communicating our desires.
However, while this is a coherent view, it does
not buy us anything, since we essentially
understand the mechanism sufficiently to have a
simpler, mechanistic description of its behavior.”
Agent Oriented Programming
Agent Oriented Programming (AOP)
Based off of Object Oriented Programming
(OOP)
Original form –
– Individual separate modules communicating with each
other
– Individual ways of handling incoming messages
Fixes the State (called Mental State) of the
modules (called Agents) to consist of
Beliefs
Capabilities
Decisions
AOP Constraints
Mental State components of Agents have
precisely defined syntax
Other real-world counterpart constraints
Can not have two contradictory beliefs at the
same time
Based off of speech act theory
Messages between agent can
Inform
Request
Offer
OOP vs AOP
OOP
AOP
Basic Unit
Object
Agent
Parameters defining
state of basic unit
Unconstrained
Beliefs, commitments,
capabilities, choices…
Process of
computation
Message passing and
response methods
Message passing and
response methods
Types of messages
Unconstrained
Inform, request, offer,
promise, decline…
Constraints on
messages
None
Honesty,
consistency…
AOP Framework
Three main components
Formal language with clear syntax and
semantics for describing mental state
Interpreted language in which to define and
program agents
An “agentifier” to convert neutral devices into
programmable agents
Paper really only addresses the first two
components
Mental State
Decisions (or choices)
Goes on to redefine these as obligations with
decisions merely being regarded as
obligations to oneself
Beliefs
Refer to belief about the state of the world at
a particular time
Capabilities
Can refer to self or other agents
Mental State Language
Language similar to logic languages (LISP,
ProLog, etc…)
In fact implementation in LISP
Time component
holding robot , cup 
t
Robot is holding the cup at time t
Belief
Modal Operator B (Belief)
Bat 
a is an agent
t is a time term
φ is a recursively defined sentence
Example
Ba3 Bb10like(a, b) 7
Means that at time 3 agent a believes that at time 10 agent
b will believe that at time 7 a liked b
Obligation
Modal Operator OBL (Obligation)
OBLta,b
means that at time t agent a is obligated (or
commited) to agent b about φ
Actions are represented as facts thus the agent
is obligated to a fact holding rather than to taking
an action
Decision
Decisions are defined as obligations to oneself
DECat  def OBLta,a
Decisions are something that the agent has
decided to be true
Capability
Modal Operator CAN (Capability)
CAN at 
means that at time t a is capable of φ
5
opendoor 
For Example : CANrobot
8
At time 5 the robot might be able to ensure that the door is
open at time 8 but at time 6 it might not have that capability
any longer
Able
ABLE is the immediate version of CAN
ABLEa def CANatime 
Defining time(φ) to be the outermost time occurring in
it
And therefore
5
5
5




ABLErobotopen door  CANrobotopen door
Mental State Constraints
Internal Consistency
Beliefs & obligations are internally consistent

for any t , a :  :Bat  is consistent
for any t , a :  :OBLta,b for some b is consistent

Good Faith
Agents only commit to what they believe themselves
capable of and only if they really mean it
for any t , a, b,  : OBLta,b  Bat  ABLEa    
Introspection
Agents have total introspective capabilities and are
aware of their obligations
for any t , a, b,  : OBLta,b  Bat OBLta,b
for any t , a, b,  : OBLta,b  Bat OBLta,b
Persistence of Mental State
Beliefs persist by default
The absence of beliefs also persists by
default
Obligations by their nature also persist
until revoked
Either by completion, release by obligatory
party, or loss of capability to fulfill obligation
Generic Agent Interpreter
Agent behavior
Two step loop
Read the current messages, update mental state
Execute the commitments for the current time
(possibly resulting in further belief change)
This loop is initiated at regular intervals set by
the interpreter ‘clock’ using an internal
timegrain value
Agent Interpreter Flow Diagram
AGENT-0
Simple AOP language and its interpreter
Proof of concept developed to support the
framework
Very simplistic
Fact statements are atomic objective
statements and can not contain conjunction or
disjunction
AGENT-0 Language
Actions
May be Private or Communicative
May be Conditional or Unconditional
Private Actions
May or may not involve I/O
Communicative Actions
Always involve I/O
Are uniform and common across all agents
Actions
Private action
DO
t
p  action
Inform action
INFORM
t a
fact 
WHERE
Request action
REQUEST
t a action
Unrequest action
UNREQUEST
Refrain action
REFRAIN
t a action
action
t – time point
a – agent name
p-action – private action
fact – fact statement
action – any action statement
Conditional Actions
Conditional actions are triggered by one
condition – a mental condition
Mental condition: a logical combination of mental
patterns
Mental pattern is one of two items:
B
fact  or OBL aaction
Syntax for Conditional Action
IF
mntlcond action
Example
IF Btemployee
smith acmeINFORM
t a temployee smith acme
if at time t you believe that at time t' smith is an employee of
acme, then at time t inform agent a of that fact
Mental Conditions
May contain logical connectors
AND, OR, & NOT
Example
REQUEST
REQUEST
REQUEST
t b
t b
t b
IF B, fact  INFORM t  1 a fact 
IF B NOT fact  INFORM t  1 a NOT fact 
IF NOT BW fact  INFORM t  1 a NOT BW
BW is " believe whether" defined as t
BW
a
p  t
B
a
p  t
B
a
NOT
This is example of a query about another agents
belief about a particular fact
fact 
p
Variables
Language syntax has support for variables
denoted by a ? Prefix
IF NOT OBL
? x
REFRAIN
dance dance
Variables are scoped locally until the first NOT
operator (or the entire statement in the absence of
such a connector)
Can use universally quantified variables which are prefixed
with ?! and are always scoped throughout the entire formula
Commitments (Obligations)
Commitments rules are dictated in agent
design
Commitments are made when both mental
conditions and message conditions are met
Message Conditions
Logical combination of Message Patterns
(From Type Content)
Example
– (AND (a REQUEST (DO t walk)) (NOT (?x REQUEST
(DO t chew-gum))))
Commitment Rules
Syntax
(COMMIT msgcond mntlcond (agent action)*)
* denotes zero or more times
Example
(COMMIT (?a REQUEST ?action) (B (now
(myfriend ?a))) (?a ?action ))
Example Implementation
Scenario (Air Travel Booking)
March
P to C: Please inform me what flights you have from San Francisco to New
York on April 18.
C to P: Flight #354 departs at 08:30, flight #293 departs at 10:00, flight #441
departs at noon . . . .
P to C: Please book me on #354.
C to P: That is sold out.
P to C: Please book me on #293.
C to P: That is confirmed; your reservation number is 112358.
P to C: Please book me also on #441.
C to P: That conflicts with #293: I am not allowed to double book a
passenger.
P to C: Please get permission to do so.
C to S: I request permission for the following double booking: ...
S to C: Permission denied.
C to P: Sorry, I cannot get approval.
April 18, at the airport
P to C: My name is P; I have a reservation for flight 293.
C to P: Here is your boarding pass.
AGENT-0 Implementation
Use of macro definitions
(issue_bp pass flightnum time) → (IF (AND (B
((- time h) (present pass))) (B (time (flight
?from ?to flightnum)))) (DO time-h
(physical_issue_bp pass flightnum time)))
where :
– h = one hour
– physical_issue_bp = private action to physically issue
boarding pass
AGENT-0 Implementation (Cont)
(query_which t asker askee q) → (REQUEST t
askee (IF (B q) (INFORM (+ t i) asker q)))
query_which requests only a positive answer; if q
contains a universally-quantified variable then
query_which requests to be informed of all instances
of the answer to the query q
(query_whether t asker askee q) → (REQUEST t
askee (IF (B q) (INFORM (+ t I) asker q)))
(REQUEST t askee (IF (B (NOT q)) (INFORM (+
t i) asker (NOT q))))
query_whether expects either a confirmation or a
disconfirmation of a fact
AGENT-0 Implementation (Cont)
Capabilities Assignments
((issue_bp ?a ?flight ?time) true)
If it is time to issue a boarding pass then possess
the ability to do so
((DO ?time (update_remaining_seats ?timel
?flight_number ?additional_seats)) (B (?time
(remaining_seats ?timel ?flight_number
?current_seats))))
update_remaining_seat = is a private action which
changes the belief regarding remaining_seats
Update the current number of seats for a particular
flight
AGENT-0 Implementation (Cont)
Commitment Rules
(COMMIT (?pass REQUEST (IF (B,?p) (INFORM ?t
?pass ?p))) true ?pass (IF (B,?p) (INFORM ?t ?pass
?p)))
Respond to requests for information about flight availability
(COMMIT (?cust REQUEST (issue_bp ?pass ?flight
?time)) (AND (B (?time (remaining_seats ?flight ?n)))
(?n>O) (NOT ((CMT ?anyone) (issue_bp ?pass
?anyflight ?time)))) (myself (DO (+ now 1)
(update_remaining_seats ?time ?flight -I))) (?cust
(issue_bp ?pass ?flight ?time)))
Respond to requests to issue a boarding pass for a flight
AGENT-0 Implementation (Cont)
That gives the complete implementation
for the airline agent from the previous
example
Customer implementation not detailed
Supervisor implementation not detailed
AGENT-0 Implementation (Cont)
agent
action
smith
(query_which imarch/l:O0 smith airline (18april/?!time (flight sf ny,?!num)))
airline
(INFORM imarch/2:00 smith (18april/8:30 (flight sf ny #354)))
airline
(INFORM imarch/2:00 smith (18april/lO:O0 (flight sf ny #293)))
airline
(INFORM imarch/2:00 smith (18april/ ...
smith
(REQUEST imarch/3:00 airline (issue_bp smith #354 18april/8:30))
smith
(query_whether imarch/4:00 smith airline ((CMT smith) (issue_bp smith #354
18april/8:30)))
airline
(INFORM imarch/5:00 smith (NOT ((CMT smith) (issue_bp smith #354 18april/8:30))))
smith
(REQUEST imarch/6:00 airline (issue_bp smith #293 18april/lO:O0))
smith
(query_whether imarch/7:O0 smith airline ((CMT smith) (issue_bp smith #293
18april/lO:O0)))
airline
(INFORM imarch/8:00 smith ((CMT smith) (issue_bp smith #293 18april/lO:O0)))
…
smith
(INFORM 18april/9:00 airline (present smith))
airline
(DO 18april/9:00 (issue_bp smith #293 18april/lO:O0))
New Work
Many follow-on works that expand on the
AOP proposed by Shoham
Agent-Oriented Programming: A Practical
Evaluation by David Parks (1997)
JADE (Java Agent Development
Framework)
Utilizes many of the notions put forth by
Shoham
Questions
Questions?
Download