aose agent-oriented programming. introduction a class of programming language that often embodies...

22
AOSE Agent-Oriented Programming

Upload: dangelo-densley

Post on 01-Apr-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

AOSEAgent-Oriented Programming

Page 2: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Introduction

• A class of programming language that often embodies the various principles proposed by theorists.– Many of these languages draw from work done on agent

architectures.– They couple such architectures with high-level languages that

are derived from the agent theories.

• Concept of Agent-Oriented Programming introduced in 1993 by Yoav Shoham.– Adopts a view of programs that are implemented as a set of

interacting agents.– Inspired by agent theory - agents viewed as mental entities that

employ a set of mental states.– Agents executed on purpose-built interpreters that manipulate

this state in a well-defined way.

Page 3: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

OOP versus AOP (Shoham)

OOP AOP

Basic Unit Object Agent

Parameters describing unconstrained beliefs, commitments,state of basic unit capabilities

Process of Computation message passing and message passing and

response methods response methods

Types of Message unconstrained inform, request, offer

Constrains on Methods none honesty, consistency

Page 4: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

AOP System Requirements

• A complete AOP System includes three primary components:– a restricted formal language with clear syntax and

semantics for describing mental states.

– an interpreted programming language in which to define and program agents, with primitive commands (such as request and inform).

– an ”agentifier”, converting neutral devices into programmable agents.

• Shoham illustrates this through a prototype AOP language, Agent-0.

Page 5: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Mental State

• Actions: represented as facts that must be true when the action is perform.– Rather than stating that the agent performed an action at a time,

we state that the fact that the action was performed at a given time:

• holding(robot, cup)t: the robot is holding the cup at time t.

• Beliefs: beliefs are facts that are temporally specified.– You believe X at a given time where X is a sentence about the

state of the world at a point in time.• Bb

10 likes(a,b)7: b believes at time point 10 that a likes b at time point 7.

• Ba3Bb

10 likes(a,b)7: a believes at time point 3 that b believes at time point 10 that a likes b at time point 7.

Page 6: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Mental State

• Obligations: agents make commitments to one another about a fact holding.– Agents represent decisions about what will happen as

commitments to facts:• OBLa,b

t greets(a,b)t’: a is obliged to b at time t to the fact that a greets b at time t’.

– Encodes the idea of social agreement

• Decisions: represents the personal choices of the agent as to what actions it will perform.– This can be represented as obligation to oneself.

• DECat X =def OBLa,a

t X

Page 7: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Mental State

• Capabilities: which actions the agent is able achieve at a given time.– Defines what actions are achievable when:

• CAPat greets(a,b)t’: at time t, a believes that a is capable of greeting b at time

t’.

– Leads to the notion of ability – that at time t, the agent Is capable of achieving an action at time t:

• ABLEaX =def CAPatime(X)X

Page 8: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Mental State Properties

• internal consistency: that beliefs and obligations are not contradictory– for all a,t {ψ: Ba

t ψ} is consistent

– for all a,t {ψ: OBLa,bt ψ for some b} is consistent

• good faith: the agents only commit to actions they believe they are able to perform– for any a, b, ψ: OBLa,b

t ψ => Bat((ABLEa ψ) ∧ ψ)

• Introspection: agents are aware of their obligations– for any a, b, ψ: OBLa,b

t ψ => Bat OBLa,b

t ψ

– for any a, b, ψ: ~OBLa,bt ψ => Ba

t ~OBLa,bt ψ

Page 9: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Mental State Properties

• persistence of mental state: how the mental state components change over time.– Beliefs persist by default: that is, everything an agent believes

at one time point is still believed at the next time point unless a contradictory fact is learnt.

– Absence of belief persists by default: anything that an agent does not know at a time point is still unknown at the next time point unless it learns the belief.

Page 10: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Mental State Properties

• persistence of mental state: how the mental state components change over time.– Obligations persist by default: an agent continues to honour

its obligations unless the contracting party agrees to the dropping of the obligation or the agent realises that it is not able to fulfill its obligations.

– Decisions persist by default: property is inherited from obligation, but interesting to note that decisions can be dropped unilaterally (they are personal to an agent)

– Capabilities are fixed: what an agent can do at one time point can be done at the next time point subject to associated conditions.

Page 11: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: The Interpreter

Page 12: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Assumptions

• Message Passing:– Agents are addressable by name– Names are location independent– The form of the messages is interpreter dependent– The interpreter controls when the messages are sent

• Clock:– A global clock (scheduler) manages execution of the agent at regular

intervals.– Execution lasts for a fixed amount of time (timegrain)

• Actions:– The agent has a static library of actions that may be invoked by name.

Page 13: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Language Syntax

• Facts:– “Smith is an employee of acme at time t”

• (t (employee smith acme))

– “Jones is NOT an employee of acme at time t”• (NOT (t (employee smith acme)))

• Private Actions:– “kick the ball at time t”

(DO t kick-ball)

Page 14: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Language Syntax

• Communicative Actions:– “Inform a of a fact at time t”

• (INFORM t a fact)

– “(Un-)Request that a perform an action at time t”• (REQUEST t a action)• (UNREQUEST t a action)

– “Don’t perform this action”• (REFRAIN action)

– “Request at time 1 that a updates the database at time 10”• (REQUEST 1 a (DO 10 update-database))

– “Request at time 1 that a requests at time 5 that b informs at time 10 c of a fact”• (REQUEST 1 a (REQUEST 5 b (INFORM 10 c fact)))

Page 15: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Language Syntax

• Conditional Actions:– “Only do the action if some mental condition holds”

• (IF mntlcond action)

– “If the agent believes that smith is an employee of acme at time t’ then tell a this at time t”• (IF (B (t’ (employee smith acme)))

(INFORM t a (t’ (employee smith acme))))

– “Request at time t that b informs at time t+1 c of a fact only if b beliefs the fact to hold”• (REQUEST t b (IF (B fact) (INFORM t+1 a fact)))

– “If the agent sees the ball at time t and the agent is committed to shooting a time t then perform shoot”• (IF (AND (t sees-ball) (CMT shoot)) (DO t shoot))

Page 16: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Language Syntax

• Commitment Rules:– “If a given message condition is satisfied and a given mental

condition is satisfied, commit to zero or more action(s) on behalf of some agent(s)”• (COMMIT msgcond mntlcond (agent action)*)

– “If an agent sends a request for an action and you believe that a is now a friend then commit to the action”• (COMMIT (?a REQUEST ?action)

(B (now (myfriend ?a)))

(?a ?action))

– Here ? denotes a variable.

Page 17: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Agent-0: Language Syntax

• Commitments (Obligations):– A list of agent name and action pairs

• (agent action)

– Can be queried using the the following templates:• ((CMT agent) time action) / ((CMT agent) action)

• Capabilities:– Associate conditions with primitive actions to stop incompatible

actions being attempted:• (action mntlcond)

– “Perform the rotate wheelbase action only if you are not committed to servicing the wheelbase at that time”• ((!?time (rotate wheelbase ?degree))

(NOT ((CMT ?x) ?!time (service wheelbase))))

Page 18: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Example: Airline Booking System

• “Issue boarding passes precisely one hour before departure; no seat assignments”– (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)))

• “Ask an askee to tell you if it believes some fact q, and return all matching facts”– (query_which t asker askee q) =>

(REQUEST t askee (IF (B q) (INFORM (+ t 1) asker q)))

• “Ask an askee to tell you whether or not it believes some fact q, and return all matching facts”– (query_which t asker askee q) =>

(REQUEST t askee (IF (B q) (INFORM (+ t 1) asker q)))

Page 19: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Example: Airline Booking System

• “Issue boarding passes precisely one hour before departure; no seat assignments”– (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)))

• “Ask an askee to tell you if it believes some fact q, and return all matching facts”– (query_which t asker askee q) =>

(REQUEST t askee (IF (B q) (INFORM (+ t 1) asker q)))

• “Ask an askee to tell you whether or not it believes some fact q, and return all matching facts”– (query_whether t asker askee q) =>

(REQUEST t askee (IF (B q) (INFORM (+ t 1) asker q)))

(REQUEST t askee (IF (B (NOT q)) (INFORM (+ t 1) asker (NOT q))))

Page 20: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Example: Airline Booking System

• Capability: There are no constrains on issuing a boarding pass– ((issue_bp ?a ?flight ?time) true)

• Capability: The update remaining seats can only be carried out if the agent believes that there are seats available– ((DO ?time (update_remaining_seats ?time1

?flight_number ?additional_seats))

(B ?time (remaining_seats ?time1

?flight_number ?current_seats))))

Page 21: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Example: Airline Booking System

• Commitment Rules:– (COMMIT (?pass REQUEST (IF (B ?p) (INFORM ?t ?pass ?p)))

true

(?pass (IF (B ?p) (INFORM ?t ?pass ?p))))

– (COMMIT (?cust REQUEST (issue_bp ?pass ?flight ?time))

(AND (B (?time (remaining_seats ?flight ?n)))

(?n > 0)

(NOT ((CMT ?anyone) (issue_bp ?pass

?anyflight ?time))))

(myself (DO (+ now 1) (update_remaining_seats

?time ?flight -1)))

(?cust (issue_bp ?pass ?flight ?time)))

Page 22: AOSE Agent-Oriented Programming. Introduction A class of programming language that often embodies the various principles proposed by theorists. –Many

Conclusions

• Agent-0 demonstrates how agents can be programmed as mental entities

• Contains a relatively small set of constructs but is VERY difficult to understand programs– Nesting of actions powerful but can cause confusion– Undone by the fact the the agent must have a commitment rule to

handle each incoming message.

• No tool support– Agent program is a text file (no syntax checker / code verifier)– Debugging supported through output to the console