Advanced Artificial Intelligence
(Multi-Agent Systems)
3
What is an Agent?
■ An agent is a computer system capable of autonomous
action in some environment in order to meet its design objectives (goals).
4
Planning
■ Finding a sequence of actions that takes agent from
Initial State to Goal State
Initial state: clear(c), on(c,a), ontable(a), clear(b), ontable(b), handempty c a b Goal: on(a,b), on(b,c) c a b c a b a b c a c b c a b
Domain-Independent Planning
Inputs:
■
Domain Action Theory
■
Problem Instance
Description of (initial) state of the world Specification of desired goal behavior
Output: sequence of actions that executed in
initial state satisfy goal
Representation Languages
■
Languages must represent..
States Goals Actions
■
Languages must be
Expressive for ease of representation Flexible for manipulation by algorithms
Example Problem Instance:
Initial State: (on-table A) (on C A) (on-table B) (clear B) (clear C)
Goal: (on A B) (on B C)
A B
C
A
B
C Initial State: Goal:
Example Problem Instance:
STRIPS Representation
Initial State: (and (on-table A) (on C A)
(on-table B) (clear B) (clear C)) Goal: (and (on A B) (on B C))
A B
C
A
B
C Initial State: Goal:
Action Representation:
Propositional STRIPS
Move-C-from-A-to-Table:
preconditions: (on C A) (clear C) effects:
add (on-table C) delete (on C A) add (clear A)
Solution to frame problem: explicit effects are the only changes to the state.
Action Representation:
Propositional STRIPS
Move-C-from-A-to-Table:
preconditions: (and (on C A) (clear C)) effects:
(and (on-table C) (not (on C A))
(clear A))
Solution to frame problem: explicit effects are the only changes to the state.
Different Concerns during Knowledge
Representation
■
Frame problem:
How to specify what does not change
■
Qualification problem
Hard to specify all preconditions
■
Ramification problem
“Classical Planning” Assumptions
■Atomic Time
■Deterministic
■Fully Observable
■Static
■Goals of attainment
Plan Generation:
Search space of world states
Planning as a (graph) search problem
■
Nodes: world states
■
Arcs: actions
■
Solution: path from the initial state to one
state that satisfies the goal
Initial state is fully specified There are many goal states
Progression:
Forward search (I -> G)
ProgWS(state, goals, actions, path)
If state satisfies goals, then return path else a = choose(actions), s.t.
preconditions(a) satisfied in state if no such a, then return failure
else return
ProgWS(apply(a, state), goals, actions, concatenate(path, a))
Progression Example:
I: (on-table A) (on C A) (on-table B) (clear B) (clear C) G: (on A B) (on B C) ■ P(I, G, BlocksWorldActions, ()) ■ P(S1, G, BWA, (move-C-from-A-to-table)) ■ P(S2, G, BWA, (move-C-from-A-to-table, move-B-from-table-to-C)) ■ P(S3, G, BWA, (move-C-from-A-to-table, move-B-from-table-to-C, move-A-from-table-to-B)) G ⊆ S3 => Success! Non-Deterministic Choice!
Regression:
Backward Search (I <- G)
RegWS(init-state, current-goals, actions, path)
If init-state satisfies current-goals, then return path else a =choose (actions), s.t. some effect of a
satisfies one of current-goals
If no such a, then return failure [unachievable*]
If some effect of a contradicts some of current-goals, then return failure [inconsistent state] CG’ = current-goals – effects(a) + preconditions(a) If current-goals ⊂ CG’, then return failure [useless*]
RegWS(init-state, CG’, actions, concatenate(a,path))
Regression Example:
I: (on-table A) (on C A) (on-table B) (clear B) (clear C) G: (on A B) (on B C)
■ R(I, G, BlocksWorldActions, ())
■ R(I, ((clear A) (on-table A) (clear B) (on B C)), BWA,
(move-A-from-table-to-B))
■ R(I, ((clear A) (on-table A) (clear B) (clear C), (on-table B)),
BWA, (move-B-from-table-to-C, move-A-from-table-to-B))
■ R(I, ((on-table A) (clear B) (clear C) (on-table B) (on C A)),
BWA, (move-C-from-A-to-table, move-B-from-table-to-C, move-A-from-table-to-B))
current-goals ⊆ I => Success!
Non-Deterministic Choice!
Regression Example:
I: (on-table A) (on C A) (on-table B) (clear B) (clear C) G: (on A B) (on B C) ■ P(I, G, BlocksWorldActions, ()) ■ P(S1, G, BWA, (move-C-from-A-to-table)) ■ P(S2, G, BWA, (move-C-from-A-to-table, move-B-from-table-to-C)) ■ P(S3, G, BWA, (move-C-from-A-to-table, move-B-from-table-to-C, move-A-from-table-to-B)) G ⊆ S3 => Success! Non-Deterministic Choice!
Plan Generation:
Search space of plans
Partial-Order Planning (POP)
■
Nodes are partial plans
■
Arcs/Transitions are plan refinements
■
Solution is a node (not a path).
Principle of “Least commitment”
■
e.g. do not commit to an order of actions until
Partial Plan Representation
■ Plan = (A, O, L), whereA: set of actions in the plan
O: temporal orderings between actions (a < b) L: causal links linking actions via a literal
■ Causal Link:
Action Ac (consumer) has precondition Q that is established in the plan by Ap (producer).
move-a-from-b-to-table move-c-from-d-to-b
Ap Q Ac
Threats to causal links
Step A
tthreatens link (A
p, Q, A
c) if:
1. A
thas (not Q) as an effect, and
2. A
tcould come between A
pand A
c, i.e.
O ∪ (A
p< A
t< A
c) is consistent
What’s an example of an action that threatens
the link example from the last slide?
Initial Plan
For uniformity, represent initial state and goal with two special actions:
■ A
0:
no preconditions,
initial state as effects,
must be the first step in the plan. ■ A
∞:
no effects
goals as preconditions
POP algorithm
POP((A, O, L), agenda, actions)
If agenda = () then return (A, O, L) Pick (Q, aneed) from agenda
aadd = choose(actions) s.t. Q ∈effects(aadd) If no such action aadd exists, fail.
L’ := L ∪ (aadd, Q, aneed) ; O’ := O ∪ (aadd < aneed) agenda’ := agenda - (Q, aneed)
If aadd is new, then A := A ∪ aadd and
∀P ∈preconditions(aadd), add (P, aadd) to agenda’
For every action at that threatens any causal link (ap, Q, ac) in L’ choose to add at < ap or ac < at to O.
If neither choice is consistent, fail. POP((A’, O’, L’), agenda, actions)
Termination
Action Selection
Update goals
Protect causal links - Demotion: at < ap - Promotion: ac < at
POP
POP is sound and complete
■
POP Plan is a solution if:
All preconditions are supported (by causal links), i.e., no open conditions.
No threats
Consistent temporal ordering
■
By construction, the POP algorithm reaches a
POP example:
Sussman Anomaly
Ain f (on A B) (on B C) A0Work on open precondition (on B C)
A0
(on C A) (on-table A) (on-table B) (clear C) (clear B)
A1: move B from Table to C
(on B C) -(on-table B) -(clear C)
(clear B) (clear C) (on-table B)
(on A B) (on B C)
Ain f
Work on open precondition (on A B)
(on A B) (on B C)
A2: move A from Table to B
(clear A) (clear B) (on-table A) (on A B) -(on-table A) -(clear B)
A0
(on C A) (on-table A) (on-table B) (clear C) (clear B)
A1: move B from Table to C
(on B C) -(on-table B) -(clear C)
(clear B) (clear C) (on-table B)
Ain f
Protect causal links
(on A B) (on B C)
A2: move A from Table to B
(clear A) (clear B) (on-table A) (on A B) -(on-table A) -(clear B)
A0
(on C A) (on-table A) (on-table B) (clear C) (clear B)
A1: move B from Table to C
(on B C) -(on-table B) -(clear C)
(clear B) (clear C) (on-table B)
Ain f (A0, (clear B), A1) theatened by A2 --> Promotion
Work on open precondition (clear A)
(on A B) (on B C)
A2: move A from Table to B
(clear A) (clear B) (on-table A) (on A B) -(on-table A) -(clear B)
A3: move C from A to Table
(clear C) (on C A)
-(on C A) (on-table C) (clear A)
A0
(on C A) (on-table A) (on-table B) (clear C) (clear B)
A1: move B from Table to C
(on B C) -(on-table B) -(clear C)
(clear B) (clear C) (on-table B)
Ain f
Final plan
(on A B) (on B C)
A2: move A from Table to B
(clear A) (clear B) (on-table A) (on A B) -(on-table A) -(clear B)
A3: move C from A to Table
(clear C) (on C A)
-(on C A) (on-table C) (clear A)
A0
(on C A) (on-table A) (on-table B) (clear C) (clear B)
A1: move B from Table to C
(on B C) -(on-table B) -(clear C)
(clear B) (clear C) (on-table B)
Ain f
Basic idea
■
Construct a graph that encodes constraints
on possible plans
■
Use this “planning graph” to constrain search
for a valid plan:
If valid plan exists, it’s a subgraph of the planning graph
■
Planning graph can be built for each problem
Problem handled by GraphPlan
*■
Pure STRIPS operators:
conjunctive preconditions no negated preconditions no conditional effects
no universal effects
■
Finds “shortest parallel plan”
■
Sound, complete and will terminate with
failure if there is no plan.
*Version in [Blum& Furst IJCAI 95, AIJ 97],
Planning graph
■ Directed, leveled graph 2 types of nodes:
■ Proposition: P ■ Action: A
3 types of edges (between levels)
■ Precondition: P -> A ■ Add: A -> P
■ Delete: A -> P
■ Proposition and action levels alternate
■ Action level includes actions whose preconditions are satisfied in previous level plus no-op actions (to solve frame problem).
Planning graph
…
…
…
Constructing the planning graph
■
Level P
1
: all literals from the initial state
■
Add an action in level A
i
if all its preconditions
are present in level P
i■
Add a precondition in level P
i
if it is the effect
of some action in level A
i-1(including no-ops)
■
Maintain a set of exclusion relations to
eliminate incompatible propositions and
actions (thus reducing the graph size)
Mutual Exclusion relations
■
Two actions (or literals) are mutually
exclusive (mutex) at some stage if no valid
plan could contain both.
■
Two actions are mutex if:
Interference: one clobbers others’ effect or precondition
Competing needs: mutex preconditions
■
Two propositions are mutex if:
Mutual Exclusion relations
Inconsistent Effects Inconsistent Support Competing Needs Interference (prec-effect)Dinner Date example
■ Initial Conditions: (and (garbage) (cleanHands) (quiet)) ■ Goal: (and (dinner) (present) (not (garbage))
■ Actions:
Cook :precondition (cleanHands) :effect (dinner)
Wrap :precondition (quiet) :effect (present)
Carry :precondition
:effect (and (not (garbage)) (not (cleanHands)) Dolly :precondition
Observation 1
Propositions monotonically increase
(always carried forward by no-ops)
p ¬q ¬r p q ¬q ¬r p q ¬q r ¬r p q ¬q r ¬r A A B A B
Observation 2
Actions monotonically increase
p ¬q ¬r p q ¬q ¬r p q ¬q r ¬r p q ¬q r ¬r A A B A B
Observation 3
Proposition mutex relationships monotonically decrease
p q r … A p q r … p q r …
Observation 4
Action mutex relationships monotonically decrease
p q … B p q r s … p q r s … A C B C A p q r s … B C A
Observation 5
Planning Graph ‘levels off’.
■
After some time k all levels are identical
■
Because it’s a finite space, the set of literals
never decreases and mutexes don’t
reappear.
Valid plan
A valid plan is a planning graph where:
■
Actions at the same level don’t interfere
■
Each action’s preconditions are made true by
the plan
GraphPlan algorithm
■
Grow the planning graph (PG) until all goals
are reachable and not mutex. (If PG levels off
first, fail)
■
Search the PG for a valid plan
■
If non found, add a level to the PG and try
Searching for a solution plan
■ Backward chain on the planning graph
■ Achieve goals level by level
■ At level k, pick a subset of non-mutex actions to achieve current goals. Their preconditions
become the goals for k-1 level.
■ Build goal subset by picking each goal and choosing an action to add. Use one already selected if possible. Do forward checking on remaining goals (backtrack if can’t pick
Plan Graph Search
If goals are present & non-mutex: Choose action to achieve each goal Add preconditions to next goal set
Termination for unsolvable problems
■ Graphplan records (memoizes) sets ofunsolvable goals:
U(i,t) = unsolvable goals at level i after stage t. ■ More efficient: early backtracking
■ Also provides necessary and sufficient conditions for termination:
Assume plan graph levels off at level n, stage t > n If U(n, t-1) = U(n, t) then we know we’re in a loop and can terminate safely.
Dinner Date example
■ Initial Conditions: (and (garbage) (cleanHands) (quiet)) ■ Goal: (and (dinner) (present) (not (garbage))
■ Actions:
Cook :precondition (cleanHands) :effect (dinner)
Wrap :precondition (quiet) :effect (present)
Carry :precondition
:effect (and (not (garbage)) (not (cleanHands)) Dolly :precondition
58