# Heuristic Search cs475 lecture note (

### Pages to are hidden for

"Heuristic Search cs475 lecture note ("

```					 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
 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-1Puzzle
 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
 Depth-First Search (backtracking)

 Uniform Cost Search

 Informed   or Heuristic Search

start

put s in OPEN

yes
OPEN empty ?                Fail

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

yes
any succesor = goal             Success
?

1

2            3       4

5           6                    8    9
7

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

Remove the first node of OPEN                Depth(n) =
and put it in CLOSE (call it n)              Depth Bound

Expand n.
Put successors at the beginning of OPEN
pointers back to n

yes
any succesor = goal            Success
?
Depth-First Search Example

1

2            3       4

5           6                    8    9
7

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
 Saveon Storage, guarantee shortest path
 Additional node expansion is negligible
Uniform Cost Search
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
OPEN empty ?                  Fail

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
 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   of Solvable
 Terminal    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
 Searchterminate when start node is
labeled either solvable or unsolvable
Solution Graph
 Subgraphof solvable nodes
demonstrating start node solvable
 called   strategy in game
 Search   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       x       x           o       o   o x
o                   o       x   x
o
Tic-tac-toe
 Most-Win   Heuristics

x                      x

x

3 win                 2 win
4 win
Use of Heuristics
 8-Puzzel

2   3           1 2 3
1 8 4           8   4
7 6 5           7 6 5

2 3   2 8 3   2 3
1 8 4   1   4   1 8 4
7 6 5   7 6 5   7 6 5

a         b      c

s

g
Best First Search Algorithm( for tree 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
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)

 can   you prove it ?
 If       
h(n) 0, A* algorithm becomes uniform cost
algorithm
 Uniform    cost algorithm is admissible
 If 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)
 n)
cost(ni, j
and h(goal) = 0

Examples of
 8 puzzle heuristic
 8 queen problem, Tic-tac-toe
 Air distance heuristic
 Traveling Salesperson Problem

 Mechanical       generation of Heuristics
 Solution   with less constrained problems
 Fortwo admissible heuristic h1 and h2,

h1(n)     h2(n) for all n

0        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
 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     threshold =
OPEN empty ?                  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   Branching Factor (B)
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
 Static    Evaluation Funtion e   
 Measure the Worth?of a tip node

 if p is win for MAX, then e(p) =
 if p is win for MIN, then e(p) = -
MiniMax Procedure
 Selectthe 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 p is a win for X, e(p) = 
 if p is a win for O, e(p) = -

1

-1    X
X
1

X
O

-2                         O
6-5
X                                                                      X              O X
X                                      X
O                                                                  5-4                 6-4
O   X
5-5
6-5
O
X
5-5                                    O
O       O                          O
X       X                       O
X                                  X             X O

4-5
5-6          5-5         5-6           5-5       4-6
Alpha-Beta Procedure
 Improvement          of MiniMax Procedure
 combining        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)   >= -1   (LowerBound: -value)
 When    we have BUV(C) = -2, we know
 BUV(B)   <= -2   (UpperBound: -value)
 Finalvalue 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
 Any MIN node having -value <= -value of any
MAX anscester (-cutoff)
 Any MAX node having -value <= -value of any
MIN anscester (-cutoff)
 -value   computation during search
 -value 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);
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      Memory
 also   called Short-term memory
 Recognize-act      cycle
 also   called control structure, engine
Production Rules
 Production
 conditionpart 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
written in LISP
 Originally
 Most popular production system
 Forward chaining system

 CLIPS
C version of OPS5
 Most portable (available in PC)

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 336 posted: 1/22/2010 language: English pages: 53