Heuristic Search cs475 lecture note by Jin Hyung Kim
Download
Report
Transcript Heuristic Search cs475 lecture note by Jin Hyung Kim
Heuristic Search
cs475 lecture note
(supplement for CS570)
by Jin Hyung Kim
Computer Science Department
KAIST
Search Algorithm
Guarantee
to find a solution ?
always terminate ?
Guarantee the solution to be optimal
Complexity - time and space
How can the complexity be reduced ?
How can utilize representation language ?
State Space Search
Example of Representation
Euler
Path
Graph Theory
Graph
consists of
A set of nodes : may be infinite
A set of arcs(links)
Directed
graph, underlying graph, tree
Notations
node,
start node(root), leaf (tip node), root,
path, ancestor, descendant, child(children,
son), parent(father), cycle, DAG, connected,
locally finite graph, node expansion
State Space Representation
Basic
Components
set of states {s}
set of operators { o : s -> s }
control strategy { c: sn -> o }
State space graph
State -> node
operator -> arc
Four tuple representation
[N, A, S, GD], solution path
Examples of SSR
TIC_TAC_TOE
n2-1
Puzzle
Traveling salesperson problem (TSP)
Strategies of SS Search
Data-Driven
vs. Goal Driven(model-driven)
Forward chaining / Backward chaining
Irrevocable strategy vs. revocable
Irrevocable:
Most popular in Human problem solving
No shift of attention to suspended alternatives
End up with local-maxima
<<
Commutative >>
Revocable
An
alternative chosen, others reserve
Implementing Graph Search
Revocable
strategy
Uninformed
search
Search
does not depend on the nature of
solution
Systematic Search Method
Breadth-First Search
Depth-First Search (backtracking)
Uniform Cost Search
Informed
or Heuristic Search
Breadth-First Search Algorithm
start
put s in OPEN
yes
Fail
OPEN empty ?
Remove the first node of OPEN
and put it in CLOSE (call it n)
Expand n.
Put successors at the end of OPEN
pointers back to n
any succesor = goal
?
yes
Success
Breadth-First Search Example
1
3
2
5
6
4
7
8
9
What is in OPEN when node 6 expanded ?
How many nodes should have been expanded to find the goal ?
Depth-First Search Algorithm
start
put s in OPEN
yes
OPEN empty ?
Fail
Depth(n) =
Depth Bound
Remove the first node of OPEN
and put it in CLOSE (call it n)
Expand n.
Put successors at the beginning of OPEN
pointers back to n
yes
any succesor = goal
?
Success
Depth-First Search Example
1
3
2
5
6
4
7
8
9
What is in OPEN when node 6 expanded ?
How many nodes should have been expanded to find the goal ?
Comparison of BFS and DFS
BFS
always terminate if goal exist
cf. DFS on locally finite infinite tree
Gurantee
shortest path to goal - BFS
Space requirement
BFS
- Exponential
DFS - Linear,
keep children of a single node
Which is better ? BFS or DFS ?
Iterative Deepening
Compromise
of BFS and DFS
proc Iterative_Deeping_Search(Root)
begin
Success := 0;
for (depth_bound := 1; depth_bound++; Success == 1)
{
depth_first_search(Root, depth_bound);
if goal found, Success := 1;
}
end
Save
on Storage, guarantee shortest path
Additional node expansion is negligible
Uniform Cost Search
A
Genaralized version of Breadth-First
Search
C(ni,
nj) = cost of going from ni to nj
G(n) =(tentative minimal) cost of a path
from s to n.
Guarantee
to find the minimum cost
path
Dijkstra Algorithm
Uniform Cost Search Algorithm
start
put s in OPEN, set g(s) = 0
yes
Fail
OPEN empty ?
Remove the node of OPEN whose g(.) value is smallest
and put it in CLOSE (call it n)
n = goal
?
yes
Success
Expand n. calculate g(.) of successor
Put successors to OPEN
pointers back to n
More on Uniform cost Search
How do you modify UCS of previous
page for searching a goal on graph ?
Can you apply the iterative deepening
idea to the uniform cost search ?
And/Or Graph
Devide a problem into subproblems
and solve them individually
divide
and conquer
And/Or
Graph
Node:
subproblems
Links: And Link, Or Link
And
: connect parent and subproblems
Or : represents alternatives
And/Or graph examples
Tower
of Hanoi Puzzle
Algebraic Problem solving : integration
probelm
language parsing
Game tree
Searching And/Or Graph
Objective
of Search
To
show whether start node is Solvable?
or Unsolvable ?
Definition
Terminal
of Solvable
node is solvable
A non-terminal OR node is solvable if at
least one of its successor is solvable
A non-terminal AND node is solvable iff
all of its successors are solvable
Searching And/Or Graph
Definition
of UnSolvable
Non-Terminal
node with no successor is
unsolvable
A non-terminal OR node is unsolvable iff
all of its successors are unsolvable
A non-terminal AND node is unsolvable if
at least one of its successors is unsolvable
Search
terminate when start node is
labeled either solvable or unsolvable
Solution Graph
Subgraph
of solvable nodes
demonstrating start node solvable
called
Search
strategy in game
procedure
1. Whenever a terminal generated, apply
solve-labeling to see start node solvable
2. Whenever a terminal generated, apply
unsolve-labeling to see start node
unsolvable
Use of Heuristics
Tic-tac-toe
x
x
x
x o
x
o x
o
x
x
o
o
o
x
o
x
o x
Tic-tac-toe
Most-Win
Heuristics
x
x
x
3 win
4 win
2 win
Use of Heuristics
8-Puzzel
3
2
1 8 4
1 2 3
8
4
7 6 5
7 6 5
2 3
1 8 4
7 6 5
2 8 3
1
4
7 6 5
2 3
1 8 4
7 6 5
a
b
c
Road Map Problem
s
g
Best First Search Algorithm( for tree search)
start
put s in OPEN, compute f(s)
yes
Fail
OPEN empty ?
Remove the node of OPEN whose f(.) value is smallest
and put it in CLOSE (call it n)
n = goal
?
yes
Success
Expand n. calculate f(.) of successor
Put successors to OPEN
pointers back to n
Algorithm A
Best-First
Algoorithm with f(n) = g(n) + h(n)
where g(n) : cost of n from start to node n
h(n) : heuristic estimate of the cost
from n to a goal
Algorithm
is admissible if it terminate with optimal
solution
What if f(n) = f*(n) where f*(n) = g*(n) + h*(n)
where g*(n) = shortest cost to n
h*(n) = shortest actual cost from n to goal
Algorithm A*
Algorithm
A becomes A* if h(n) <= h*(n)
Algorithm A* is admissible
can
you prove it ?
h(n) 0,
A* algorithm becomes uniform cost
algorithm
If
Uniform
If
cost algorithm is admissible
n* is on optimal path, f*(n*) = C*
f*(n) > C* implies that n is not on optimal path
A* terminate in finite graph
Best First Search Algorithm (extention for graph search)
start
put s in OPEN, compute f(s)
yes
OPEN empty ?
Fail
Remove the node of OPEN whose f(.) value is smallest
and put it in CLOSE (call it n)
n = goal
?
yes
Success
Expand n. calculate f(.) of successor
Put successors to OPEN
pointers back to n
Modification for Graph Search
Expand n.
For suc in Successor(n) do
compute f(suc)
if suc is in OPEN or CLOSE
then
set f(suc) to smaller
put suc OPEN if not already in
redirect pointer
else
put suc to OPEN
pointers back to n
Monotonicity
A
heuristic function is monotone if
for all states ni and nj suc(ni)
h(ni) - h(nj)
cost(ni,nj)
and h(goal) = 0
Monotone
heuristic is admissible
Examples of
Admissible Heuristics
8 puzzle heuristic
8 queen problem, Tic-tac-toe
Air distance heuristic
Traveling Salesperson Problem
Mechanical
Solution
generation of Heuristics
with less constrained problems
More Informedness
For
two admissible heuristic h1 and h2,
h2 is more informed than h1 if
h1(n)
0
h2(n) for all n
h1(n)
h2(n)
h*(n)
Iterative Deeping A*
Modification of A*
use
threshold as depth bound
increase threshold as mininum of f(.) of
previous cycle
Still
admissible
same order of node expansion
Storage Efficient - practical
Iterative Deepening A* Search Algorithm ( for tree search)
start
set threshold as h(s)
put s in OPEN, compute f(s)
yes
OPEN empty ?
threshold =
min( f(.) , threshold )
Remove the node of OPEN whose f(.) value is smallest
and put it in CLOSE (call it n)
n = goal
?
yes
Success
Expand n. calculate f(.) of successor
if f(suc) < threshold then
Put successors to OPEN if
pointers back to n
Performance Measure
Penetrance
how
search algorithm focus on goal rather
than wander off in irrelevant directions
P=L/T
Effective
B
Branching Factor (B)
+ B2 + B3 + ..... + BL = T
less dependent on L
Game Tree Search
Game
Tree = Special case of AND/OR
Graph
Objective of Game tree Search
To
find good first move
Measure the Worth?of a tip node
Static
if
Evaluation Funtion e
p is win for MAX, then e(p) =
if p is win for MIN, then e(p) = -
MiniMax Procedure
Select
the maximum worth alternative
Under Assumption of that the opponent
do his best
Back-Up Value(BUV)
1. At tip node p, BUV is e(p)
2. At AND node, BUV is max. of BUV of
children
3. At OR node, BUV is min. of BUV of
children
MiniMax for Tic-Tac-Toe
Two
player, X and O, X play first
Static Evaluation function
If
p is not a winning position
e(p) = (#complete rows, coluumns, or diagonal
that are still open for X) - (#complete rows,
coluumns, or diagonal that are still open for O)
If
e(p) =
p is a win for X,
if p is a win for O, e(p) = -
1
-1
X
X
1
X
O
6-5
O
-2
X
X
O X
5-4
6-4
X
O
5-5
X
O
X
6-5
O
5-5
X
O
O
O
X
X
O
X
O
X
X O
4-5
5-6
5-5
5-6
5-5
4-6
Alpha-Beta Procedure
Improvement
combining
of MiniMax Procedure
search procedure & evaluation
max
S
A
B
C
1
0
-1
1
-2
Alpha-Beta Procedure
When
we have BUV(A) = -1, we know
BUV(S)
When
(LowerBound: -value)
we have BUV(C) = -2, we know
BUV(B)
Final
>= -1
<= -2
(UpperBound: -value)
value of B never exceed current value of
S. We can prune the other children of B.
-value of MAX never decrease
-value of MIN never decrease
Alpha-Beta Procedure
Rules
of Discontinuing Search
MIN node having -value <= -value of any
MAX anscester (-cutoff)
Any MAX node having -value <= -value of any
MIN anscester (-cutoff)
Any
-value
-value
computation during search
of MAX is set to largest final BUV of its
successor
-value of MIN is set to smallest final BUV of its
successor
Control and Implementation of
State Space Search
Recursion-based
Search
Pattern-Directed Search
Production System
Recursion-based Search
Function depthsearch(current_state);
begin
if current_state is a goal then return(success);
add current_state to CLOSED
while current_state has unexamined children
begin
child:= next unexamined child;
if child not member of closed
then if depthsearch(child) = sucess
then return(sucess)
end
return(fail)
end
Pattern Directed Search
Use
Unification for checking goal
satisfaction
Recursive search
Luger’s book page 157
Production System
Model
of Search and Human Problem Solving
Heavily used in AI (Expert) system
Production System components
Production rules (or production)
also
called Long-term memory
Working
also
Memory
called Short-term memory
Recognize-act
also
cycle
called control structure, engine
Production Rules
Production
condition
part and action part
premise and conclusion
LHS and RHS
Condition Part - pattern matching
Action
Part - problem solving step
Single chunk of knowledge
Good for representing Judgmental knowledge
Working Memory
Description
of Current state of World
Description will be matched against
condition part of production to select
problem solving action
Modified by problem solving action
Recognize-Act cycle
Inference
Engine
data in WM is matched against condition part
of every production rules
collect all matching productions as conflict set
subset of conflict set is selected (by confilct
resolution) and the selected productions are
fired.
Action of the fired production may modify
WM
Control of Production System
Data
Driven vs Goal Driven
Forward vs Backward Search
Bidrectional Search
Implementation
OPS5
Originally
written in LISP
Most popular production system
Forward chaining system
CLIPS
C
version of OPS5
Most portable (available in PC)