Lecture Notes 1: BDI Agent Model
BDI model based on Micheal Bratman's theory of human practical reasoning.
Applied to programming, this means we act as if a computer program has mental states, i.e. beliefs, desires and intentions. This is a different style than declarative programming, and can help solve certain problems.
BDI in Jason
JASON programs contain agents that operate or cooperate together in an environment. The JASON language roughly maps beliefs, desires and intentions in the following manner.
- Beliefs: represented as internal variables
- Internal variables, e.g.
fridgeTemp: a belief about the temperature of the fridge - Desires: represented as goals
- Optional to achieve these goals
- Intentions: when an agent commits to a goal
- Source can be external (other agent) or internal (desire, necessary to achieve another intention).
- If intenentions require other intentions, many subgoals may be formulated recursively.
Folk psychology
In philosophy, BDI is a framework for describing people's behavior.
In agent-based programming these principles is not only used to describe, but also to define the behavior of an agent.
This approach has two distinct advantages:
- A non-technical way to talk about complex systems
- It is a post-declarative programming paradigm
- Ok, what type of problem is this useful for then?
Practical Reasoning and Complexity
Practical reasoning: go from 'passive' data structures to actions.
JASON uses AgentSpeak. AgentSpeak implemented meands-ends reasoning, which is a form of planning.
Planning from a BDI perspective:
- Goals and intentions: what the agent wants to achieve
- Agent's current beliefs about state of the environment
- An agent has some actions available to achieve goals and intentions.
So what is required is a plan with actions to achieve goals.
A good plan is a plan that changes the environment in such a way that the goal is achieved.
Planning algorithms are often computationally intractable. There are various ways to reduce complexity, but AgentSpeak circumvents the issue by letting the progrmamer design partial plans offline, to reduce the space of possible plans.
This reduces the task of the agent to selecting partial plans.
Therefore, some intelligence on the side of the programmer is still required. Too bad!
Computational model
A main loop with components:
- perceive the world and update its beliefs
- which of the intentions are to be achieved (first**
- find a plan with means-end reasoning
- execute the plan, potentially changing the environment
Issues with this naive approach
All these issues are caused by environment changes during plan execution.
- Agents stay committed to intentions even if they become unachievable after environment changes
- Agents keep executing a plan, even if in the meantime another intention becomes more important
- Agents keep executing a plan even when the environment renders that plan useless
Q: can you think of an example where this implemenation's issues become clear?
How AgentSpeak deals with these issues.
Three main variables in improved loop:
- B: agent beliefs
- D: agent desires (avialable options)
- I: agent intentions (committed to)
After a plan is made, an inner loop is initiated in which there are options to review intentions or escape a plan.
- An agent will update beliefs about the environment in this inner loop, and will reconsider intentions (commits) if the environment changes
- Check if the current plan is sound w.r.t. the updated beliefs about the environment.
- If the plan is not sound, a new plan is made.
This thus solves the identified issues.
Pre-made partial plans
Pre-made partial plans contain three components:
- Goal: a post-condition of the plan.
- Context: pre-condition of the plan; required environment
- Body: sequence of things to do
- Can be actions
- But also be goals. In that case:
- Plans are suspended at the point of a goal until that goal is achieved.
Agent control loop
- Startup: all intentions pushed onto intention stack
- Agent searches plan library for plans that have the intention as a post condition
- Only plans whose contexts (i.e. required environment) are valid become options.
- Selecting plans based on utility numbers.
Agent Communication: Speech-act theory
AgentSpeak does not support communication, but JASON does.
The JASON architecture implements speech-act theory for communication.
Language is a form of action: the decision to speak is a decision to change the state of the world. Speaking might change the mental state of addressees.
Speech acts has a type and content (propositional statement):
- Representatives: inform
- Directives: get the hearer to act
- Commisives: commit the speaker to some action. "I will do X"
- Expressives: express a mental state
- Declarations: change the social sphere. "Declare you husband and wife"
Note that a speech act is therefore not a direct way to change the environment. Instead, speech acts change beliefs of other agents. This does not yet determine the actions of that other agent: that is up to that agent, according to its plans and beliefs etc.
Notes from lecture 1
BDI analogy with Objects and Classes in OO-languages.
Agents are reactive
Key difference of BDI w.r.t earlier frameworks: drop intentions and desires when appropriate.
AgentSpeak
AgentSpeak concepts are close to BDI terms:
- Beliefs
publisher(wiley): belief that wiley is publisher / functor(atom)- Info available about environment and other agents
- Goals
- More or less desires
!write(book)--> desire?publisher(P)--> test goal, find out whether belief is the case
- Plans
- More or less intentions?
triggering_event: context <- body.- His explanation seems to be: triggering_event is what we want to ... achieve?
Four architecture components:
- Belief Base
- Not the state of the environment; belief about environment can be wrong.
- Plan Library
- Recipee for achieving goal within particular context
- Set of Events
- Set of Intentions
Left lecture because it was bad.
Lecture Notes 2: The JASON Agent Programming Language
Beliefs
Representation of the world, that may be wrong. Expressed through predicates.
married(brad,pete)
Basic constructs
- Atom, always starts with lowercase, e.g.
brad - numbers
- strings
- variables, always start with uppercase, e.g.
Food - Uninstantiated, bound through unification
- Scope of (bound) variable is usually the plan in which it occurs
- structure: functor + arguments.
- Can be nested
- student("John Williams", s954375, favoriteColor(blue), courses( [ classicalMusic, history, bscThesis]))
- lists
- Can be unified with [Head|tail] notation
Beliefs are predicates. But predicates can be used in two ways.
- As a belief
- As a fact: evaluated to be true or false, given the beliefs of the agent.
As a fact, predicates have a special use. They can be used as a part of plans, i.e. to break off a plan if a fact is not true.
Annotations
Annotations provide extra detail. Within this course, we only use annotations to provide the source of a belief.
Three sources:
- Perception
color(cube,red)- Communication
color(cube,green)[source(bob)]- Mental notes
color(cube,green)[source(self)]- remember(tell(bob,color(cube,red)))[source(self)]
Negation
Two types of negation:
notX: weak negation- The agent cannot infer X
- Has a specific use: express in plans that the agent should not belief something.
- Can be used provide conditions for the validity of a plan: do this unless you know X is the case.
~X: strong negation- The agent explicitly beliefs that X is false
So what does not ~color(cube,purple) represent?
"The agent does not believe that 'the color of the cube is purple' is false"
Rules
Collect predicates under a rule:
rule(X,Y) :- pred1(X,Z) & X == Z
Goals
- Declarative goal
- Programmer states the goal, agent has to figure out how to achieve items
- Procedural goal
- Similar to traditional function/method call
In AgentSpeak implemented as:
- Achievement goals
!own(house)agent will try to find action plans to follow- Test goals:
?bank_balance(BB)agent will try to infer the goal from agen't belief base
Plans
triggering event
: context
<- body.
The body is a candidate when
- the triggering event happens in the environment,
- and the context is a logical consequence of the agent's beliefs
So the triggering of an event is not a guarantee that it will be executed!
Triggering events
- +belief : belief addition
- -belief : belief deletion
- +!goal : achievement goal addition
- -!goal : achievement goal deletion
- +?goal : test goal addition
- -?goal : test goal deletion
Belief events are updated after sensing the environment or receiving a representative communication (that informs).
Goal events are updated after initial goals, consequences of plan execution, or when receiving goals through communication (directive communication: prompting for action).
Context
Literals in contexts:
- x The agent believes x is true
- ~x the agent believes x is false
- not x The agent does not believe x is true
- not ~x The agent does not believe x is false
- true: empty context
Logical operators: &, | .
Body
Six options, separated by semicolons.
- (external) actions
move_to(X,Y)- achievement goals
!own_house(X)- test goals
?care(SIBLING)- mental notes
wet(grass)[source(self)]- internal actions
.print("Hello world!")- Is the dot accidental?
- expressions
X>Y
Insights:
- External actions do not guarantee any effect in the world
- Actions are also formulae and thus have a truth value. True upon success.
- Upon failure of a plan (when an action fails) a failure event is triggered.
- External actions take time and suspend their parent plan. Other goals may be purpued in the meantime for non-suspended plans.
- Achievement goals always block their plan until success, but suspending behavior can be overridden with
!! - You can think of achievement goals as sub goals.
Stayed at page 7, Lecture notes 2.