An Introduction to Artificial Intelligence CE 40417
-
Upload
ruth-haley -
Category
Documents
-
view
33 -
download
0
description
Transcript of An Introduction to Artificial Intelligence CE 40417
An Introduction to Artificial Intelligence
CE 40417Chapter 11 – Planning
Ramin Halavati ([email protected])
In which we see how an agent can take advantage of a problem to construct complex plans of actions.
What is p
lan
nin
g
1. We have some Operators.
2. We have a Current state.
3. We have a Goal State.
4. We want to know:
How to arrange the How to arrange the operators to reach the operators to reach the Goal State from Current Goal State from Current State.State.
Air C
arg
o T
ran
sfer E
xam
ple
• What’s in Domain:– We have a set of airports as SFO,JFK, ...– We have a set of cargos as C1, C2, …– We have some airplanes as P1, P2, …
• State:– Plans and Cargos are at specific airports
and we want to change the positions.
• Actions:– Load (Cargo, Plane, Airport)– Fly (Plane, Airport1, Airport2)– Unload (Cargo, Plane, Airport)
Blo
cks World
Exam
ple
• Domain Objects:– A set of blocks and a table.
• States:– Blocks are stacked on each other and
the table and we want to change their positions.
• Actions:– PickUp( Block ), – PutDown( Block)– Unstack( Block, Block)– Stack( Block, Block )
A
C
B
A
C
B
Dom
ain
Defin
ition E
xam
ple
1
AIR CARGO TRANPORT DOMAIN:
• Objects:– SFO , JFK, C1 , C2 , P1 , P2.
• Predicates:– At( C1, SFO )– In( C1, P2 )– Plane( P1)– Cargo(C1)
• Actions:– …
Dom
ain
Defin
ition
Ex.1
(con
t.)
• Actions:– Name, – Parameters, – Preconditions, – Effects.
– LOAD( c, p , a )• Prec.:
At(c,a), At(p,a), Cargo(c),Plane(p),Airport(a).• Effects:
~At(c,a), In(c,p)
Dom
ain
Defin
ition E
x.1
(co
nt.)
• Actions:
– UNLOAD( c, p , a )• Prec.:
In(c,p), At(p,a), Cargo(c),Plane(p),Airport(a).• Effects:
At(c,a), ~In(c,p)
– FLY( p , a1, a2 )• Prec.:
At(p,a1) Plane(p),Airport(a1) ,Airport(a2).• Effects:
~At(p,a1), At(p,a2)
Dom
ain
Defin
ition E
xam
ple
2
BLOCKS WORLD DOMAIN
• Objects:– A, B, C, … (the blocks) & the ROBOT.
• Predicates:– On( x , y ).– OnTable( x ).– Holding( x ).– HandEmpty.– Clear( x ).– OnTable( x ).– Block( x ).
Dom
ain
Defin
ition
Ex.2
(con
t.)
• Actions:– UnStack( x , y ):
• Prec:On(x,y), HandEmpty, Clear( x ).
• Effects:~On(x,y), Holding(x), ~Clear(x), Clear(y).
– Stack( x,y ):• Prec:
Holding(x), Clear(y)• Effects:
On(x,y), HandEmpty, ~Holding(x), Clear( x ), ~Clear(y).
NOTE: Nothing about what is block and what’s not.
Y
X
Dom
ain
Defin
ition
Ex.2
(con
t.)
• Actions:– PickUp( x ):
• Prec:HandEmpty, Clear( x ), OnTable( x ).
• Effects:Holding(x), ~Clear(x), ~OnTable( x ).
– PutDown( x ):• Prec:
Holding(x).• Effects:
OnTable( x ), HandEmpty, Clear( x ).
Pro
pble
m D
efinitio
n E
x.2
• PROBLEM DEFINITION:– Initial State:
On(C,A), Clear(C), ~Clear(A),OnTable(A), Clear(B), OnTable(B),HandEmpty.
– Goal State:HandEmpty,Clear(A),On(A,B),On(B,C),OnTable(C).
A
C
B
A
C
B
Sim
ple
st App
roach
• It’s all about SEARCH.– States:
As described before.
– Next State Generator:Which actions are applicable, apply every one
of em.
– Path Cost:One for each action.
– Goal Test:Has goal state reached?
CAB
CBA
ABC
BAC
ACB
BCA
A B
C
B C
A
A C
BA B
C
A C
B
B C
A
A B C
Initialstate
Goal
Sim
ple
st App
roach
• Progression (Forward Search):– Start from Initial State, move forward
till you reach goal state.
A
C
B
A
C
B A
C B
A
C
B
A
C
BAC B A
C
BA
C
B
. . .
NOTE: Backtracking is mandatory.
Sim
ple
st App
roach
• Regression (Backward Search):– Put Goal State’s predicates in Agenda.– Recursively fetch an item from agenda
• Find something to satisfy it.• Remove all its effects from agenda.• Add all its preconditions to agenda.
Regre
ssion
Exam
ple
On(A,B), On(B,C), OnTable(C)1. Pick Goal: On(A,B)
2. Choose Action: Stack(A,B)
3. Add actions preconditions to agenda and remove its effects from it.
On(B,C), OnTable(C), Holding(A), Clear(B).
1. Pick Goal: Holding(A)
2. Choose Action: PickUp(A).
3. ...
On(B,C), OnTable(C), Clear(B), HandEmpty, OnTable(A)
...
Pure
Search
App
roach
es
• Heuristics:– Using Relaxed Domain Definition:
• Assume actions have no precondition.• Assume actions have no negative effects.• …• (They are all admissible).
– Sub-Goal Independence Assumption• Assuming each goal can be achieved with a
sub-plan, regardless of other necessities.• (Not necessarily admissible, depends on the
domain).
Sim
ple
st App
roach
• What’s wrong with Search?
– Branching Factor may be too big.
– The search space is reversible, resulting in infinite loops and repeated states.
– Simple Search is the least that we can do.
Partia
l Ord
er P
lannin
g
PARTIAL ORDER PLANNING
Partia
l Ord
er P
lannin
g
• We do not need to start from the beginning of plan and march to end.
• Some steps, facts, etc. are more important, we can decide on them ahead.
• We can impose least possible commitments during the task.
END :
On(A,B)
On(B,C)
OnTable(C)
START:
On(C,A)
OnTable(A)
OnTable(B)
Clear(C)
Clear(A)
Holding(A)
Clear(B)
On(A,B)
H.E.
Clear(A)
STACK(A,B)
Holding(B)
Clear(C)
On(B,C)
H.E.
Clear(B)
STACK(B,C)
AC
B A
CB
Note: Not all results of each action is mentioned.
OnTable(B)
H.E.
Holding(B)
~Clear(B)
~OnTable(B)
PickUp(B)
Ord
erin
g
Partia
l Ord
er P
lannin
g
• Assume an action called START.– No precondition.– All ‘Initial State’ as its effects.
• Assume an action called END.– All ‘Goal State’ as its precondition.– No Effect.
Partia
l Ord
er P
lannin
g
• Partial Plan is a (A,O,L,Agenda) where:
– A: set of actions in the plan• Initially {Start, End}
– O: temporal orderings between actions• Initially {Start<End}
– Agenda: open preconditions that need to be satisfied along with the action which needs them.
• Initially all preconditions of End such as {(BeHome,End),(HaveMoney,End)}.
Partia
l Ord
er P
lannin
g
• L: The set of Causal Links– Initially Empty.– Causal Link:
Action A2 has precondition Q that is established in the plan by action A1.
A1 A2Q
Clear(B)Unstack(C,B) Putdown(A,B)
Partia
l Ord
er P
lannin
g
• Example:
– A ={Start, Stack(B,C), End}
– O ={Start<End, Stack(B,C)<End}
– L ={(Stack(B,C),On(B,C),End)}
– Agenda={(On(A,B),End), (OnTable(C),End), (Holding(B),Stack(B,C), (Clear(C),Stack(B,C)}.
END:
On(A,B)
On(B,C)
OnTable(C)
START:
On(C,A)
OnTable(A)
OnTable(B)
Clear(C)
Clear(A)
Holding(B)
Clear(C)
On(B,C)
H.E.
Clear(B)
STACK(B,C)
Partia
l Ord
er P
lannin
g
• A causal link (A1, Q, A2) represents the assertion that the role of A1 is to establish proposition Q for A2. This tells future search steps to “protect” Q in the interval between A1 and A2.
• Action B threatens causal link (A1, Q, A2) if:
1. B has Q as a delete effect, and
2. B could come between A1 and A2, i.e.
O (A1 < B < A2) is consistent.
• For example: PutDown(C,B) is a threat for:
Unstack(C,B) PutDown(A,B)Clear(B)
Finally
, PO
P’s C
ode.
POP(<A,O,L>, agenda)
2. Goal selection: Let <Q,Aneed> be a pair on the agenda
3. Action selection: Let Aadd = choose an action that adds Qif no such action exists, then return failure
Let L’= L {Aadd → Aneed}, and let O’ = O {Aadd < Aneed}.If Aadd is newly instantiated, then A’ = A {Aadd} and
O’ = O {A0 < Aadd < A} (otherwise, let A’ = A)4. Updating of goal set: Let agenda’ = agenda -{<Q,Aneed>}.If Aadd is newly instantiated, then for each conjunction, Qi,
of its precondition, add <Qi,Aadd> to agenda’5. Causal link protection: For every action At that might
threaten a causal link Ap → Ac, add a consistentordering constraint, either
(a) Demotion: Add At < Ap to O’(b) Promotion: Add Ac < At to O’ (c) Inequality constraintsIf neither constraint is consistent, then return failure6. Recursive invocation: POP((<A’,O’,L’>, agenda’)
1. Termination: If agenda is empty return <A,O,L>
Q
p
Last P
OP N
ote
s.
• Using Variables:– You need not add UnStack(A,B) when
you need Clear(B). Just add Unstack(x,B) and add binding as a next step.
• Heuristics:– What to do in ChooseGoal and
ChooseAction?
Pla
nnin
g G
rap
h
• Main Idea:– To construct a graph of possible
outcomes.
…
…
…
Din
ner D
ate
Dom
ain
• 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
:effect (and (not (garbage)) (not (quiet)))
Din
ner D
ate
Gra
ph
Mutu
al E
xclu
sion
Cla
sses
Inconsistent Effects
Inconsistent SupportCompeting Needs
Interference (Prec-Effect)
Obse
rvatio
n 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
Obse
rvatio
n 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
Obse
rvatio
n 3
Proposition Mutex relationships monotonically decrease
p
q
r
…
A
p
q
r
…
p
q
r
…
Obse
rvatio
n 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
Obse
rvatio
n 5
(Su
m U
p)
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.
Gra
ph P
lan A
lgorith
m
Graph Plan 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 again
Search
for a
solu
tion p
lan
Search
for a
solu
tion p
lan
• 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 non-mutex action)
Just A
noth
er P
lann
ing
Ap
pro
ach
Planning By Logic (SAT-Plan):
1. Convert the planning problem into a logic problem.
2. Solve the logic problem.
SA
T P
lan
Exam
ple
INITIAL STATE:At(P1,SFO)0 AT(C1,JFK)0 Plane(P1) Cargo(C1) Airport(SFO) Airport(JFK).
RULES:At(x,y)t FLY(x,y,z)t Airplane(x) Airport(y) Airport(z)
At(x,z)t+1 At(x,y)t+1
…
GOAL STATE:AT(C1,SFO)x
Su
m U
p
• POP: Most human-like.
• Graph Plan: Winner of planning contests.
• SAT Plan: Widely used in real problem as:– Hardcode logic solvers.– Mathematics and Optimization.
• Note: Combinations are also used.
EX
ER
CIS
ES &
Pro
jects
Implement either POP or Graph-Plan.
As Exercise:
On a hard-coded domain without variable-
instantiating.
– Send To: [email protected]
– Subject: AIEX-C11
As Project:
Read the domain as PDDL, have variable
instantiation, and all.