automated planning and scheduling · state space graph the trucking example again: consider the fdr...
TRANSCRIPT
![Page 1: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/1.jpg)
INSTITUTE OF THEORETICAL INFORMATICS
Automated Planning and SchedulingLecture 3
Tomas Balyo, Dominik Schreiber | November 8, 2018
KIT – University of the State of Baden-Wuerttemberg and
National Laboratory of the Helmholtz Association
www.kit.edu
![Page 2: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/2.jpg)
Contents
State Space Search AlgorithmsState Space Properties
Combinatorial Explosion
Forward SearchBlind: DFS, BFS, Dijkstra’s algorithmHeuristic: BestFistSearch, A*, Enforced Hill Climbing
Backwards Search
Bi-Directional Search
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 2/28
![Page 3: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/3.jpg)
State Space Graph
The trucking example again:
A B C A B C
Consider the FDRLet us represent each world state as XYZ where
X ∈ {A,B,C} is the truck locationY ,Z ∈ {A,B,C,T} are the locations of the packages
initial state: AAB, goal: *CCAll possible states: 3 ∗ 4 ∗ 4 = 48
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 3/28
![Page 4: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/4.jpg)
State Space Graph
Planning: find a path from AAB to CCC
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 4/28
![Page 5: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/5.jpg)
State Space Graph
So planning is just path-finding :-)We can use standard path search algorithms
Breadth-first searchDepth-first searchDijkstra’s algorithm...
BUT...
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 5/28
![Page 6: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/6.jpg)
State Space Graph
So planning is just path-finding :-)We can use standard path search algorithms
Breadth-first searchDepth-first searchDijkstra’s algorithm...
BUT...
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 5/28
![Page 7: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/7.jpg)
Example – All Paths in a grid
https://youtu.be/Q4gTV4r0zRs
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 6/28
![Page 8: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/8.jpg)
Example – Rubik’s Cube
3x3x3 Cube
4.3x1019 combinations
a standard cube has a side length 5.7 cm, if you assemble 4.3x1019
standard cubes into a huge cube it would have a side of 200 Km.
4x4x4 Cube
7.4x1045 combinations
the huge cube side would be 0.1 Light years
5x5x5 Cube
2.8x1074 combinations
the huge cube side would be 10 million Light years (our own galaxy +70 nearest galaxies would fit in that cube).
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 7/28
![Page 9: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/9.jpg)
Example – Rubik’s Cube
3x3x3 Cube
4.3x1019 combinations
a standard cube has a side length 5.7 cm, if you assemble 4.3x1019
standard cubes into a huge cube it would have a side of 200 Km.
4x4x4 Cube
7.4x1045 combinations
the huge cube side would be 0.1 Light years
5x5x5 Cube
2.8x1074 combinations
the huge cube side would be 10 million Light years (our own galaxy +70 nearest galaxies would fit in that cube).
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 7/28
![Page 10: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/10.jpg)
Example – Rubik’s Cube
3x3x3 Cube
4.3x1019 combinations
a standard cube has a side length 5.7 cm, if you assemble 4.3x1019
standard cubes into a huge cube it would have a side of 200 Km.
4x4x4 Cube
7.4x1045 combinations
the huge cube side would be 0.1 Light years
5x5x5 Cube
2.8x1074 combinations
the huge cube side would be 10 million Light years (our own galaxy +70 nearest galaxies would fit in that cube).
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 7/28
![Page 11: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/11.jpg)
State Space Graph
So planning is just path-finding :-)We can use standard path search algorithms
Breadth-first searchDepth-first searchDijkstra’s algorithm...
BUTThe graph is astronomically huge
Does not fit in the memory
We will generate it on the go
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 8/28
![Page 12: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/12.jpg)
Depth-First Search
function DFS(State s) {
if (goal(s)) return True
foreach (Action a in applicable(s)) {
if (DFS(apply(s,a)) return True
}
return False
}
The function DFS(init) will return True if a plan existsDemo at https://www.movingai.com/SAS/EXP/
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 9/28
![Page 13: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/13.jpg)
DFS Properties
Advantages:
linear time complexity (in found plan size)
can find long plans fast (if we are lucky)
easy to implement
Disadvantages:May get into loops
we can remember and then avoid visited states, increases memorycomplexity (linear in visited states).Still exponential time complexity
May find very inefficient plans
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 10/28
![Page 14: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/14.jpg)
Breath-First Search
function BFS(State init) {
Queue<State> sq = {init}
while (sq not empty) {
s = sq.dequeue()
if (goal(s)) return True
foreach (Action a in applicable(s)) {
sq.enqueue(apply(s,a))
}
}
return False
}
The function BFS(init) will return True if a plan exists
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 11/28
![Page 15: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/15.jpg)
BFS Properties
Advantages:
finds optimal plans (in number of actions)
sound and complete
Disadvantages:
Exponential time and space complexity (in plan length)
No amount of luck will help us if the shortest plan is long
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 12/28
![Page 16: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/16.jpg)
Dijkstra’s Algorithm
If we action cost and want optimal plans we can use Dijkstra’s algorithm:
function Dijkstra(State init) {
PriorityQueue<State, int> sq
sq.add(init, 0)
while (sq not empty) {
s,costOfs = sq.getMin() // smallest cost to init
if (goal(s)) return Plan
foreach (Action a in applicable(s)) {
sq.add(apply(s,a), costOfs + cost(a))
}
}
return False
}
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 13/28
![Page 17: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/17.jpg)
Dijkstra Properties
Advantages:
finds optimal plans
sound and complete
Disadvantages:
Exponential time and space complexity (in plan length)
Demo: https://www.movingai.com/SAS/ASG/
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 14/28
![Page 18: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/18.jpg)
Heuristics
The previous algorithms are unusuable for planning in most cases
They are too uninformed (blind)
HeuristicA heuristic function f : S → R estimates the cost of a plan from states ∈ S to the nearest goal state.
Admissible HeuristicLet f be a heuristic and o(s) be the cost of the optimal plan from s to thenearest goal state. We say that f is an Admissible heuristic if∀s ∈ S : f (s) ≤ o(s)
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 15/28
![Page 19: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/19.jpg)
Heuristics
The previous algorithms are unusuable for planning in most cases
They are too uninformed (blind)
HeuristicA heuristic function f : S → R estimates the cost of a plan from states ∈ S to the nearest goal state.
Admissible HeuristicLet f be a heuristic and o(s) be the cost of the optimal plan from s to thenearest goal state. We say that f is an Admissible heuristic if∀s ∈ S : f (s) ≤ o(s)
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 15/28
![Page 20: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/20.jpg)
Greedy Best First Search
function GreedyBestFS(State s) {
if (goal(s)) return True
A = actions with unvisited apply(s,a)
sort(A) // according to h(apply(s,a))
foreach (Action a in A) {
if (GreedyBestFS(apply(s,a)) return True
}
return False
}
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 16/28
![Page 21: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/21.jpg)
Greedy Best First Search Properties
GBFS chooses the action with the lowest heuristics value first
Very fast on simple domains given a good heuristic
May produce very inefficient plans
Does not work well on complex domains
Implement with visited state filtering to avoid cycles
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 17/28
![Page 22: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/22.jpg)
Best First Search
function BestFS(State init) {
PriorityQueue<State, int> sq
sq.add(init, heuristic(s))
while (sq not empty) {
s = sq.getMin() // smallest heuristic value
if (goal(s)) return Plan
foreach (Action a in applicable(s)) {
sq.add(apply(s,a), heuristic(apply(s,a))
}
}
return False
}
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 18/28
![Page 23: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/23.jpg)
Best First Search Properties
Similar to Breadth First Search and Dijkstra’s algorithm
Keeps a queue of open nodes and expands the one with bestheuristic value
Needs a lot of memory if the heuristic has plateaus
Does not find optimal plans
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 19/28
![Page 24: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/24.jpg)
A*
function A*(State init) {
PriorityQueue<State, int> sq
sq.add(init, 0 + h(s))
while (sq not empty) {
s, costOfs = sq.getMin() // smallest value
if (goal(s)) return Plan
foreach (Action a in applicable(s)) {
sq.add(apply(s,a), costOfs + cost(a) + h(apply(s,a))
}
}
return False
}
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 20/28
![Page 25: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/25.jpg)
A* Properties
A combination of Dijkstra’s algorithm and BestFSExpands a node with minimal f (s) = g(s) + h(s) value
g(s) the distance to initial state (like in Dijkstra)h(s) the heuristic value
If the heuristic is admissible then A* is optimal
A* is optimally efficient (expands the minimal amount nodesnecessary to find the optimal solution)
A* is the most popular ”A.I. Algorithm” ever
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 21/28
![Page 26: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/26.jpg)
Enforced Hill Climbing
EHC is a combination of Greedy Best First Search and Best FirstSearch
It runs like GBFS until a plateau is reached (all applicable actionslead to states with same heuristic value)
then it switches to Best First Search (breadth first style) until a betterstate is reached
EHC search usually consists of prolonged periods of exhaustivesearch (BFS) connected by relatively short periods of heuristicdescent.
Invented by Joerg Hoffmann in 2005 for the planner FF
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 22/28
![Page 27: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/27.jpg)
Backwards Search
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 23/28
![Page 28: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/28.jpg)
Backwards Search
Basic Idea:
We search from goal towards the initial state
Relevant actions for a set of atoms = actions with relevant effects
Starting with the goal conditions we choose one of the relevantactions and “un-apply” it to reach the next state
Repeat until the initial state is reached
How to “un-apply” an action a in a partial state s (in PDR)?
remove effects of a from s
add preconditions of a to s
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 24/28
![Page 29: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/29.jpg)
Backward Search for Trucks
The trucking example again:
A B C A B C
Let us represent each world state as XYZ whereX ∈ {A,B,C} is the truck locationY ,Z ∈ {A,B,C,T} are the locations of the packages
initial state: AAB, goal: *CCFind a path from *CC to AAB
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 25/28
![Page 30: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/30.jpg)
Backward Search
Still requires search because many actions may be relevant
For some domains the branching factor may be smaller whensearching backwards
Same search algorithm as for forward search may used
Similar heuristics can be designed
It is possible to reformulate a problem such that forward searchsimulates backwards search
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 26/28
![Page 31: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/31.jpg)
Bi-Directional Search
Basic Idea
Search simultaneously from both initial state and goal and meet inthe middle
Maintain 2 collections of open nodes
Use heuristics to guide the searchTheoretically faster than both backwards and forwards search
let the b the branching factor and d the plan lengthforward and backward search (BFS) would expand O(bd) nodesBi-Directional Search would only expand O(bd/2)
Demo: https://www.movingai.com/SAS/NBS/
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 27/28
![Page 32: Automated Planning and Scheduling · State Space Graph The trucking example again: Consider the FDR Let us represent each world state as XYZ where X 2fA;B Cgis the truck location](https://reader034.vdocuments.us/reader034/viewer/2022042301/5ecc5f349d54c3180f38930e/html5/thumbnails/32.jpg)
The End
Next Week: Heuristics for state space search
Tomas Balyo, Dominik Schreiber – Planning and Scheduling November 8, 2018 28/28