Title: Heuristic Search cs475 lecture note supplement for CS570 by Jin Hyung Kim Computer Science Departmen
1Heuristic Searchcs475 lecture note(supplement
for CS570)by Jin Hyung KimComputer Science
DepartmentKAIST
2Search 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
3Example of Representation
4Graph 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
5State Space Representation
- Basic Components
- set of states s
- set of operators o s -gt s
- control strategy c sn -gt o
- State space graph
- State -gt node
- operator -gt arc
- Four tuple representation
- N, A, S, GD, solution path
6Examples of SSR
- TIC_TAC_TOE
- n2-1 Puzzle
- Traveling salesperson problem (TSP)
7Strategies 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
- ltlt Commutative gtgt
- Revocable
- An alternative chosen, others reserve
8Implementing 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
9Breadth-First Search Algorithm
yes
Expand n. Put successors at the end of
OPEN pointers back to n
yes
10Breadth-First Search Example
What is in OPEN when node 6 expanded ? How many
nodes should have been expanded to find the goal ?
11Depth-First Search Algorithm
yes
yes
12Depth-First Search Example
What is in OPEN when node 6 expanded ? How many
nodes should have been expanded to find the goal ?
13Comparison 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 ?
14Iterative Deepening
- Compromise of BFS and DFS
- Save on Storage, guarantee shortest path
- Additional node expansion is negligible
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
15Uniform 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
16Uniform Cost Search Algorithm
yes
yes
n goal ?
17More 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 ?
18And/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
19And/Or graph examples
- Tower of Hanoi Puzzle
- Algebraic Problem solving integration probelm
- language parsing
- Game tree
20Searching 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
21Searching 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
22Solution Graph
- Subgraph of 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
23Use of Heuristics
24Tic-tac-toe
x
x
x
2 win
3 win
4 win
25Use of Heuristics
1
2
3
3
2
1
8
4
4
8
5
6
5
6
7
7
3
2
3
8
2
2
3
8
1
1
4
4
4
1
8
6
7
7
5
6
7
5
5
6
a
c
b
26Road Map Problem
s
g
27Best First Search Algorithm( for tree search)
yes
yes
n goal ?
28Algorithm 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
29Algorithm A
- Algorithm A becomes A if h(n) lt h(n)
- Algorithm A is admissible
- 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) gt C implies that n is not on optimal path
- A terminate in finite graph
30Best First Search Algorithm (extention for graph
search)
yes
Fail
yes
n goal ?
Expand n. calculate f(.) of successor Put
successors to OPEN pointers back to n
31Modification 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
32Monotonicity
- 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
33Examples of Admissible Heuristics
- 8 puzzle heuristic
- 8 queen problem, Tic-tac-toe
- Air distance heuristic
- Traveling Salesperson Problem
- Mechanical generation of Heuristics
- Solution with less constrained problems
34More Informedness
- For two admissible heuristic h1 and h2, h2 is
more informed than h1 if - h1(n) h2(n) for all n
h(n)
h1(n)
h2(n)
0
35Iterative 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
36Iterative Deepening A Search Algorithm ( for
tree search)
set threshold as h(s)
yes
threshold min( f(.) , threshold )
yes
n goal ?
Expand n. calculate f(.) of successor if f(suc) lt
threshold then Put successors to OPEN if
pointers back to n
37Performance 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
38Game 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) -
39MiniMax 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
40MiniMax 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) -
411
-1
X
X
1
X
O
O
-2
6 - 5
X
X
X
O
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
42Alpha-Beta Procedure
- Improvement of MiniMax Procedure
- combining search procedure evaluation
max
S
A
B
C
1
-2
-1
0
1
43Alpha-Beta Procedure
- When we have BUV(A) -1, we know
- BUV(S) gt -1 (LowerBound ?-value)
- When we have BUV(C) -2, we know
- BUV(B) lt -2 (UpperBound ?-value)
- Final 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
44Alpha-Beta Procedure
- Rules of Discontinuing Search
- Any MIN node having ?-value lt ?-value of any MAX
anscester (?-cutoff) - Any MAX node having ?-value lt ?-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
45Control and Implementation of State Space Search
- Recursion-based Search
- Pattern-Directed Search
- Production System
46Recursion-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
47Pattern Directed Search
- Use Unification for checking goal satisfaction
- Recursive search
- Lugers book page 157
48Production 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
49Production 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
50Working 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
51Recognize-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
52Control of Production System
- Data Driven vs Goal Driven
- Forward vs Backward Search
- Bidrectional Search
53Implementation
- OPS5
- Originally written in LISP
- Most popular production system
- Forward chaining system
- CLIPS
- C version of OPS5
- Most portable (available in PC)