Ai Sesi11 Planning
-
Upload
deny-cen-lung -
Category
Documents
-
view
15 -
download
0
Transcript of Ai Sesi11 Planning
4/18/2011
IF-UTAMA 1
Jurusan Teknik Informatika – Universitas Widyatama
IF-UTAMA 1IF-UTAMA 1
Planning
Pertemuan : 11
Dosen Pembina :
Sriyani Violina
Danang Junaedi
IF-UTAMA 2IF-UTAMA 2
• Deskripsi
• Introduction
• Hierarchical Planning
• Sensorless Planning
• Conditional Planning
• Execution Monitoring and Replanning
• Continous Planner
• State of the world (STRIPS language)
• The Block World– Goal stack Planning (GSP)
Overview
IF-UTAMA 3IF-UTAMA 3
• Pertemuan ini mempelajari bagaimana
memecahkan suatu masalah dengan teknik
planning.
• Metode planning yang dibahas pada
pertemuan ini adalah Goal Stack Planning
(GSP)
Deskripsi Introduction
• We studied how to take actions in the world
(search)
• We studied how to represent objects, relations,
etc. (logic)
• Now we will combine the two!
4IF-UTAMA
4/18/2011
IF-UTAMA 2
IF-UTAMA 5
Introduction
• Problem-solving is a search through a state space.
• Planning is the process of computing several steps
of a problem-solving procedure before executing
them.
• Planning = problem sloving in advance.
• Planning is important if solutions cannot be undone.
• If the universe is not predictable, then a plan can fail
⇒⇒⇒⇒ dynamic plan revision.
Hierarchical Planning
• Hierarchical Task Network(HTN)
– At each “level,” only a small number of
individual planning actions, then descend to
lower levels to “solve these” for real.
– At higher levels, the planner ignores “internal
effects” of decompositions. But these have to be
resolved at some level…
6IF-UTAMA
HTN Sample
• Construction Domain:
– Actions:
• Buy Land: Money � Land
• Get Load: Good Credit � Money
• Get Permit: Land � Permit
• Hire Builder: � Contract
• Construction: Permit ∧ Contract � House Built
• Pay Builder: Money ∧ House Built � House
• …
7IF-UTAMA
HTN Sample (cont)
• Macro Action in Library:
– Build House:
8IF-UTAMA
4/18/2011
IF-UTAMA 3
HTN Sample (cont)
9IF-UTAMA
HTN Sample (cont)
10IF-UTAMA
HTN Cons and Pros
• What’s Bad?
– Recursion?
– Sub Task Sharing:
• Enjoy honey moon in Hawaii and raise a family.
• Library:
– Enjoy Honey moon in Hawaaii: Get Married , Go to Hawaii.
– Raise Family: Get Married, Have two children.
• What’s Good:
– Almost all real applications are HTN + some thing else.
– It’s a heuristic to decrease the branching factor by a great
level.
11IF-UTAMA
NonDeterministic Domains
• What if we don’t know all about situations
and effects.
• E.g.
– Init: A table and a chair of unknown colors.
– Goal: A table and a chair of the same colors.
– Condition: Painting may have flaws.
12IF-UTAMA
4/18/2011
IF-UTAMA 4
Sensorless Planning
• We don’t know all beforehand and we can’t
find it out, even when it is done.
– Plan so that to reach the goal state, regardless of
everything. (Coercion)
– Not always possible.
13IF-UTAMA
Conditional Planning
• We can check the state ahead, then perform
the pre-planned program.
– Sense Actions
– Conditional Branches
14IF-UTAMA
Conditional Planning in
Fully Observable Domains
• Vacuum World:
– Left: AtRight � AtLeft ∧ ¬AtRight
– Left: AtRight �
(AtLeft ∧ ¬AtRight)∨ (¬AtLeft ∧ AtRight)
– Suck: when AtLeft�CleanLeft
when AtRight�CleanRight
– Left: when AtLeft� ¬CleanLeft
when AtRight�AtLeft ¬AtRight
15IF-UTAMA
Notation Expantion:
• Expanding Plan Notation:
– If (state) Then (…) else (…)
– If (AtLeft∧CleanLeft ∧CleanRight) Then {}
else Suck.
16IF-UTAMA
4/18/2011
IF-UTAMA 5
State Space:
17IF-UTAMA
Conditional Planner:
18IF-UTAMA
Unavoidable Loops in Conditional
Planner
• New Notation:
– Instead of just Left : while (AtRight) Left
19IF-UTAMA
Partially Observable Domains
20IF-UTAMA
4/18/2011
IF-UTAMA 6
Partially Observable Domains
• Easiest Approach:
– Assume set of current states and the next state
sets are created, quite similar to non-
deterministic actions case.
21IF-UTAMA
Execution Monitoring and Replanning
• Check if the plan is going on is pre-decided?
If not, replan based on current situation.
• Action Monitoring:
• See if current state is as it was supposed, if not, find a
solution to return it to what it was (repair).
22IF-UTAMA
Execution Monitoring & Replanning
• Plan Monitoring:
– See if the previous plan is still wise?
– Serendipity!
– A precondition of future actions has failed and
can not be recovered.
23IF-UTAMA
Execution Monitoring in Partially
Observable Domains
• Things may fail and we don’t know.
• Sensing actions may be required
– And they may need extra-planning.
• We may stuck in futile attempts:
– The electronic key is incorrect, but we think it
might be due to incorrect pushing in.
24IF-UTAMA
4/18/2011
IF-UTAMA 7
Continues Planner
• Keep planning, sensing and executing…
– Which is not unlikely, such as maintenance
planning, auto-pilot, plant control, …
25IF-UTAMA
Continuous Planner
• POP + …
– Missing Goal:
• A new goal has erupted. Just add it.
– Open precondition:
• An action has lost its support links. Add a new causal
link.
– Causal Conflicts:
• A causal link is suddenly threatened. Choose an
appropriate ordering.
26IF-UTAMA
Continuous Planner
• POP + …
– Unsupported Link:
• A link from start to something has suddenly last its
true value. Remove it.
– Redundant Action:
• An action no more produces something needed.
Remove it.
27IF-UTAMA
State of the world (STRIPS language)
• State of the world = conjunction of positive, ground,
function-free literals
• At(Home) AND IsAt(Umbrella, Home) AND
CanBeCarried(Umbrella) AND IsUmbrella(Umbrella) AND
HandEmpty AND Dry
• Not OK as part of the state:
– NOT(At(Home)) (negative)
– At(x) (not ground)
– At(Bedroom(Home)) (uses the function Bedroom)
• Any literal not mentioned is assumed false
– Other languages make different assumptions, e.g., negative literals
part of state, unmentioned literals unknown
IF-UTAMA 28
4/18/2011
IF-UTAMA 8
An action: TakeObject
• TakeObject(location, x)
• Preconditions:
– HandEmpty
– CanBeCarried(x)
– At(location)
– IsAt(x, location)
• Effects (“NOT something” means that that
something should be removed from state):
– Holding(x)
– NOT(HandEmpty)
– NOT(IsAt(x, location))
29IF-UTAMA
Another action
• WalkWithUmbrella(location1, location2,
umbr)
• Preconditions:
– At(location1)
– Holding(umbr)
– IsUmbrella(umbr)
• Effects:
– At(location2)
– NOT(At(location1))
30IF-UTAMA
Yet another action
• WalkWithoutUmbrella(location1,
location2)
• Preconditions:
– At(location1)
• Effects:
– At(location2)
– NOT(At(location1))
– NOT(Dry)
31IF-UTAMA
A goal and a plan
• Goal: At(Work) AND Dry
• Recall initial state:
– At(Home) AND IsAt(Umbrella, Home) AND
CanBeCarried(Umbrella) AND IsUmbrella(Umbrella) AND
HandEmpty AND Dry
• TakeObject(Home, Umbrella)
– At(Home) AND CanBeCarried(Umbrella) AND
IsUmbrella(Umbrella) AND Dry AND Holding(Umbrella)
• WalkWithUmbrella(Home, Work, Umbrella)
– At(Work) AND CanBeCarried(Umbrella) AND
IsUmbrella(Umbrella) AND Dry AND Holding(Umbrella)
32IF-UTAMA
4/18/2011
IF-UTAMA 9
Planning to write a paper• Suppose your goal is to be a co-author on an AI paper with both
theorems and experiments, within a year
LearnAbout(x,y)
Preconditions: HasTimeForStudy(x)
Effects: Knows(x,y),
NOT(HasTimeForStudy(x))
HaveNewIdea(x)
Preconditions: Knows(x,AI),
Creative(x)
Effects: Idea, Contributed(x)
ProveTheorems(x)
Preconditions: Knows(x,AI),
Knows(x,Math), Idea
Effect: Theorems, Contributed(x)
PerformExperiments(x)
Preconditions: Knows(x,AI),
Knows(x,Coding), Idea
Effect: Experiments, Contributed(x)
WritePaper(x)
Preconditions: Knows(x,AI),
Knows(x,Writing), Idea,
Theorems, Experiments
Effect: Paper, Contributed(x)
Goal: Paper AND Contributed(You)
FindExistingOpenProblem(x)
Preconditions: Knows(x,AI)
Effects: Idea
Name a few things that are
missing/unrealistic… 33IF-UTAMA
Some start states
• Start1: HasTimeForStudy(You) AND Knows(You,Math) AND
Knows(You,Coding) AND Knows(You,Writing)
• Start2: HasTimeForStudy(You) AND Creative(You) AND
Knows(Advisor,AI) AND Knows(Advisor,Math) AND
Knows(Advisor,Coding) AND Knows(Advisor,Writing)
(Good luck with that plan…)
• Start3: Knows(You,AI) AND Knows(You,Coding) AND
Knows(OfficeMate,Math) AND HasTimeForStudy(OfficeMate) AND
Knows(Advisor,AI) AND Knows(Advisor,Writing)
• Start4: HasTimeForStudy(You) AND Knows(Advisor,AI) AND
Knows(Advisor,Math) AND Knows(Advisor,Coding) AND
Knows(Advisor,Writing)
We’ll use these as examples…
34IF-UTAMA
Forward state-space search (progression
planning)• Successors: all states that can be reached with an action
whose preconditions are satisfied in current state
At(Home)
IsAt(Umbrella, Home)
CanBeCarried(Umbrella)
IsUmbrella(Umbrella)
HandEmpty
Dry
At(Home)
Holding(Umbrella)
CanBeCarried(Umbrella)
IsUmbrella(Umbrella)
Dry
TakeObject(Home, Umbrella)
At(Work)
IsAt(Umbrella, Home)
CanBeCarried(Umbrella)
IsUmbrella(Umbrella)
HandEmpty
WalkWithoutUm
brella(Home,
Work)
WalkWithUmbrella(
Home, Work,
Umbrella)
At(Work)
Holding(Umbrella)
CanBeCarried(Umbrella)
IsUmbrella(Umbrella)
Dry
WalkWithout
Umbrella(Wor
k, Home)
At(Home)
IsAt(Umbrella, Home)
CanBeCarried(Umbrella)
IsUmbrella(Umbrella)
HandEmpty
GOAL!
WalkWithoutUmbrella(
Home, Umbrella) (!)
WalkWithoutUm
brella(Home,
Work)
35IF-UTAMA
Backward state-space search (regression
planning)
• Predecessors: for every action that accomplishes one of the
literals (and does not undo another literal), remove that
literal and add all the preconditions
At(location1)
At(location2)
IsAt(umbr, location2)
CanBeCarried(umbr)
IsUmbrella(umbr)
HandEmpty
Dry
At(location1)
Holding(umbr)
IsUmbrella(umbr)
Dry
TakeObject(location2, umbr)
This is accomplished in the
start state, by substituting
location1=location2=Home,
umbr=Umbrella
WalkWithUmbrella(
location1, Work,
umbr)At(Work)
Dry
GOAL
WalkWithUmbrella(location2, location1)
WalkWithoutUmbrella can never be used, because it undoes Dry
(this is good) 36IF-UTAMA
4/18/2011
IF-UTAMA 10
Heuristics for state-space search
• Cost of a plan: (usually) number of actions
• Heuristic 1: plan for each subgoal (literal) separately, sum
costs of plans
– Does this ever underestimate? Overestimate?
• Heuristic 2: solve a relaxed planning problem in which
actions never delete literals (empty-delete-list heuristic)
– Does this ever underestimate? Overestimate?
– Very effective, even though requires solution to (easy) planning
problem
• Progression planners with empty-delete-list heuristic
perform well
37IF-UTAMA 38
The Blocks World
AB C Dstart AC DBgoalPlanning = generating a sequence of
actions to achieve the goal from the start
IF-UTAMA
39
The Blocks World
Actions:
• UNSTACK(A, B) : angkat balok A yang menempel
di atas balok B
• STACK(A, B) : simpan balok A di atas balok B
• PICKUP(A) : angkat balok A dari atas meja
• PUTDOWN(A) : simpan balok A di permukaan
meja
• MOVE(A,B,C): simpan balok A di atas balok C
• MOVETOTABLE(A,B) : simpan balok A yang
menempel di atas balok B ke atas permukaan meja
IF-UTAMA 40
The Blocks World
Conditions and results:
• ON(A, B) : balok a menempel di atas balok B
• ONTABLE(A) : balok A berada di permukaan meja
• CLEAR(A) : tidak ada balok yang menempel di atas
balok A
• HOLDING(A) : lengan robot sedang memegang
balok A
• ARMEMPTY: lengan robot tidak sedang memegan
balok
IF-UTAMA
4/18/2011
IF-UTAMA 11
41
The Blocks World
Specification of actions:
• PRECONDITION (P): list of predicates that must be true for an operator to be applied.
• ADD (A): list of new predicates that an operator causes to become true.
• DELETE(D): list of old predicates that an operator causes to become false.
• Predicates not in ADD nor DELETE are unaffacted.
IF-UTAMA
The Blocks World
Specification of actions:
STACK(x, y):
P: CLEAR(y) ∧∧∧∧ HOLDING(x)
D: CLEAR(y) ∧∧∧∧ HOLDING(x)
A: ARMEMPTY ∧∧∧∧ ON(x, y)
UNSTACK(x, y):
P: ON(x, y) ∧∧∧∧ CLEAR(x) ∧∧∧∧ ARMEMPTY
D: ON(x, y) ∧∧∧∧ ARMEMPTY
A: HOLDING(x) ∧∧∧∧ CLEAR(y)
42IF-UTAMA
The Blocks World
Specification of actions:
PICKUP(x):
P: CLEAR(x) ∧∧∧∧ ONTABLE(x) ∧∧∧∧ ARMEMPTY
D: ONTABLE(x) ∧∧∧∧ ARMEMPTY
A: HOLDING(x)
PUTDOWN(x):
P: HOLDING(x)
D: HOLDING(x)
A: ONTABLE(x) ∧∧∧∧ ARMEMPTY
43IF-UTAMA
The Blocks World
Specification of actions:
MOVE(x,y,z):
P: ON(x,y), CLEAR(x), CLEAR(z)
D: ON(x,y) ∧∧∧∧ CLEAR(Z)
A: ON(x,z), CLEAR(y), NOT(ON(x,y)), NOT(CLEAR(z))
MOVETOTABLE(x,y):
P: ON(x,y), CLEAR(x)
D: ON(x,y)
A: ONTABLE(x) ∧∧∧∧ ONTABLE(y) ∧∧∧∧CLEAR(y) ∧∧∧∧NOT(ON(x,y))
44IF-UTAMA
4/18/2011
IF-UTAMA 12
45
The Blocks World
AB ON(B, A) ∧∧∧∧ONTABLE(A) ∧∧∧∧ONTABLE(C) ∧∧∧∧ONTABLE(D) ∧∧∧∧ARMEMPTY C Dstart: AC ON(C, A) ∧∧∧∧ON(B, D) ∧∧∧∧ONTABLE(A) ∧∧∧∧ONTABLE(D) ∧∧∧∧DBgoal:
IF-UTAMA 46
Goal Stack Planning
GoalsOperators to satisfy the Goals Current situationSpecification of Operators/ActionsStack Database
+
IF-UTAMA
47
Goal Stack Planning
Push the original goal to the stack. Repeat until the
stack is empty:
– If stack top is a compound goal, push its unsatisfied
subgoals to the stack.
– If stack top is a single unsatisfied goal, replace it by an
operator that makes it satisfied and push the operator’s
precondition to the stack.
– If stack top is an operator, pop it from the stack, execute
it and change the database by the operation’s affects.
– If stack top is a satisfied goal, pop it from the stack.
IF-UTAMA 48
Goal Stack Planning
AB ON(B, A) ∧∧∧∧ONTABLE(A) ∧∧∧∧ONTABLE(C) ∧∧∧∧ONTABLE(D) ∧∧∧∧ARMEMPTY C Dstart: AC ON(C, A) ∧∧∧∧ON(B, D) ∧∧∧∧ONTABLE(A) ∧∧∧∧ONTABLE(D) ∧∧∧∧DBgoal:
IF-UTAMA
4/18/2011
IF-UTAMA 13
49
Goal Stack PlanningON(C, A) ON(B, D) ON(C, A) ∧∧∧∧ ON(B, D) ∧∧∧∧ OTADCLEAR(A)HOLDING(C)CLEAR(A) ∧∧∧∧ HOLDING(C)STACK(C, A)ON(B, D)ON(C, A) ∧∧∧∧ ON(B, D) ∧∧∧∧ OTADON(B, A) OTACDARMEMPTY ON(B, A) OTACDARMEMPTY
Stack DatabaseIF-UTAMA
Note:
OTAD = ONTABLE(A)∧∧∧∧
ONTABLE(D)
1
2
50
Goal Stack PlanningON(B,A)CLEAR(B)ARMEMPTYON(B,A) ∧∧∧∧CLEAR(B) ∧∧∧∧ARMEMPTYUNSTACK(B,A)HOLDING(C)CLEAR(A) ∧∧∧∧ HOLDING(C)STACK(C, A)ON(B, D)ON(C, A) ∧∧∧∧ ON(B, D) ∧∧∧∧ OTADOTACDHOLDING(B)Stack Database
IF-UTAMA
3 1.UNSTACK(B,A)Planning :
51
Goal Stack PlanningHOLDING(C)CLEAR(A) ∧∧∧∧ HOLDING(C)STACK(C, A)ON(B, D)ON(C, A) ∧∧∧∧ ON(B, D) ∧∧∧∧ OTAD OTACDHOLDING(B)Stack Database
IF-UTAMA
4
OTCCLEAR(C)ARMEMPTYOTC ∧∧∧∧ CLEAR(C) ∧∧∧∧ ARMEMPTYPICKUP(C)HOLDING(C)CLEAR(A) ∧∧∧∧ HOLDING(C)STACK(C, A)ON(B, D)ON(C, A) ∧∧∧∧ ON(B, D) ∧∧∧∧ OTADOTACDHOLDING(B)5
1.UNSTACK(B,A)Planning :1.UNSTACK(B,A)Planning :
52
Goal Stack PlanningCLEAR(D)HOLDING(B)CLEAR(D)∧∧∧∧ HOLDING(B)STACK(B,D)OTC ∧∧∧∧ CLEAR(C) ∧∧∧∧ ARMEMPTYPICKUP(C)HOLDING(C)CLEAR(A) ∧∧∧∧ HOLDING(C)STACK(C, A)ON(B, D)ON(C, A) ∧∧∧∧ ON(B, D) ∧∧∧∧ OTADOTACDON(B,D)ARMEMPTYStack Database
IF-UTAMA
6 1.UNSTACK(B,A)2.STACK(B,D)Planning:
4/18/2011
IF-UTAMA 14
53
Goal Stack PlanningOTC ∧∧∧∧ CLEAR(C) ∧∧∧∧ ARMEMPTYPICKUP(C)HOLDING(C)CLEAR(A) ∧∧∧∧ HOLDING(C)STACK(C, A)ON(B, D)ON(C, A) ∧∧∧∧ ON(B, D) ∧∧∧∧ OTADOTADON(B,D)HOLDING(C)Stack Database
IF-UTAMA
7 1.UNSTACK(B,A)2.STACK(B,D)3.PICKUP(C)Planning :HOLDING(C)CLEAR(A) ∧∧∧∧ HOLDING(C)STACK(C, A)ON(B, D)ON(C, A) ∧∧∧∧ ON(B, D) ∧∧∧∧ OTAD OTADON(B,D)ON(C,A)ARMEMPTY8 1.UNSTACK(B,A)2.STACK(B,D)3.PICKUP(C)4.STACK(C,A)Planning :54
Goal Stack Planning
ACON(C, A) ∧∧∧∧ONTABLE(A) ∧∧∧∧ONTABLE(B) ∧∧∧∧ARMEMPTY Bstart: AON(A, B) ∧∧∧∧ON(B, C) CBgoal:Sussman Anomaly (1975)IF-UTAMA
55
Goal Stack Planning1. UNSTACK(C, A) 2. PUTDOWN(C) 3. PICKUP(A)4. STACK(A, B)5. UNSTACK(A, B)6. PUTDOWN(A)7. PICKUP(B)8. STACK(B, C)9. PICKUP(A)10. STACK(A, B)Plan
IF-UTAMA 56
Goal Stack Planning1. UNSTACK(C, A) 2. PUTDOWN(C) 3. PICKUP(A)4. STACK(A, B)5. UNSTACK(A, B)6. PUTDOWN(A)7. PICKUP(B)8. STACK(B, C)9. PICKUP(A)10. STACK(A, B)Plan
IF-UTAMA
4/18/2011
IF-UTAMA 15
IF-UTAMA 57
Studi Kasus/Tugas
1. Jabarkan proses GSP untuk slide 54 sehingga
menghasilkan planning pada slide 55
2. Jelaskan secara singkata. Teknik planning prinsipnya hapir sama dengan searching, apa
perbedaanya?Untuk kasus-kasus tertentu kenapa planning
cenderung lebih baik dibanding searching?
b. Kapan dan kenapa sebaiknya kita memilih planning dibanding
searching?
IF-UTAMA 58IF-UTAMA 58
Referensi
1. Suyanto.2007.”Artificial Intelligence” .Informatika. Bandung
2. Ramin Halavati.-. “An Introduction to Artificial Intelligence Chapter 12 – Planning and Acting in Real World[online]”.url : -. Tanggal Akses : 11 April 2011
3. -.-.” Planning[online]” url:-.Tanggal Akses: 11 April 2011
4. Vincent Conitzer.-.” CPS 270: Artificial IntelligencePlanning[online]” url:http://www.cs.duke.edu/courses/fall08/cps270/.Tanggal Akses: 11 April 2011
5. Dan sumber-sumber lain yang terkait