Está en la página 1de 5

Informed or Heuristic Search

Use knowledge about the problem domain


Artificial Intelligence to explore the search space more efficiently
Domain knowledge is contained in a
heuristic (evaluation) function
A* Search

CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

Heuristic Functions Notation




Heuristic: problem-specific knowledge that


reduces expected search effort. h(n) = estimated cost of the cheapest


Heuristic functions evaluate the relative desirability path from the state at node
of expanding a node. n to a goal state


Heuristics are often estimates of the distance, or


cost, from the current state to the goal
Require that h(n) = 0 if n is a goal


Time spent evaluating the heuristic function must


be recovered by a reduction in search time.
state

CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

Examples Best-first search


Nodes on frontier (or fringe) of search tree
1 2 3 1 2 are stored in open list
7 8 4 3 4 5
6 5 6 7 8
Implement open list as a priority queue in
which nodes are sorted according to some
Initial State Goal heuristic evaluation function
Heuristic Function 1: Number of misplaced tiles The node that is expanded next is the one
Heuristic Function 2: Total Manhattan distance that seems “best” according to the
evaluation function
CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence
Greedy Search
Characteristics of Greedy Search
Resembles depth-first search (prefers a
Korf calls this “pure heuristic search” in his single path until it hits a dead-end.)
survey paper
Not optimal. Why?
The priority queue is sorted in increasing
Not complete. Why?
order of h(n)
Worst case time complexity O(bm) where m
The frontier node that is thought to be
is the maximum depth of search
“closest” to the goal state is always
expanded next Space complexity same as time complexity.
Usually run out of space before time.
CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

A* in Relationship to
A* Search
Other Search Algorithms
Minimizes the total path cost
The priority queue is sorted in increasing What if h( ) = 0 for every state?
order of this evaluation function: – Uniform-cost search (Dijkstra’s algorithm)
f(n) = g(n) + h(n)
What if we make g( ) = 0?
g(n): cost of path from start to node n
– Greedy search
h(n): estimate of cost of path from n to goal
f(n): estimated cost of the cheapest solution
A* combines the best properties of uniform-
through n cost and greedy search

CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

A* graph search A(21)

1. Start with OPEN containing just the initial state. 5 4


10
2. Until a goal is found or there are no nodes on OPEN do: B (20) C (12) D (18)
8 12 4 7
(a) Select the node on OPEN w/ the lowest f-value. 8 11
(b) Generate its successors. E(13) F(9) G (9) H(7) I (12) J(11)

(c) For each successor do: 3 11 7 2 7 3 5 12 3 4

i. If it hasn’t been generated before (i.e., it’s not in CLOSED), K (12) L ( 3) M(7) N(5) O(5) P(3) Q(10) R(8)
evaluate it, add it to OPEN, and record its parent. 3 5 4 6 4
ii. If it has been generated before, change the parent if this S (10) T(0) U (0)
new path is better than the previous one. In that case,
update the cost of getting to this node and to any
successors that this node may already have. Then add Numbers in parentheses are h(n)
node to CLOSED list. Numbers on edges are operator costs
CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence
Contour interpretation of A* Admissible Heuristic Functions
If h(n) never overestimates the cost to reach
a goal it is called an admissible heuristic.
If h is admissible, f(n) never overestimates
Start f=10 f=12 f=14 f=16 Goal the actual cost of the best solution through n.
A* requires an admissible heuristic to have
the properties of completeness and optimality

CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

Formal statement of
Completeness of A* completeness of A*
A* expands nodes in increasing order of f.
So it must eventually reach a goal state A* is complete on locally finite
unless there are infinitely many nodes with graphs (graphs with a finite
f(n) < f*, which is possible only if branching factor) provided there is
– there is a node with an infinite branching factor some positive constant δ such that
– there is a path with a finite path cost but an every operator costs at least δ.
infinite number of nodes along it.

CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

Let G be an optimal goal state and G2 be


a suboptimal goal state. Assume that n is
on the optimal path to g and has not been
Optimality of A* Start
expanded. Assume that G2 is about to be
expanded.
We want to prove that A* is optimal (i.e., it Since h is admissible: f* ≥ f(n)
will always find the best solution). If n is not chosen for expansion, then
f(n) ≥ f(G2).
Terminology. n Therefore
– f* is the cost of the optimal solution path f* ≥ f(G2)

– f* ≥ f(n) because the heuristic is admissible But, since G2 is a goal state


h(G2) = 0
Will use a proof by contradiction. G G2 f(G2) = g(G2)
f* ≥ g(G2)
Remember that all goal states have h(n) = 0. This contradicts the assumption that G2 is
Optimal goal Suboptimal
suboptimal. Therefore, A* never selects
state goal state
a suboptimal goal for expansion.
CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence
A* is maximally efficient Properties of heuristics


The efficiency of A* depends on the quality of the


For a given heuristic function, no optimal heuristic that guides the search
algorithm is guaranteed to do less work. 

Given two admissible heuristics h1 and h2, if h1(n)


≥ h2(n) for all n, then h1 dominates h2
Aside from ties in f( ), A* expands every – If h1 dominates h2, then A* guided by h1 expands fewer
node necessary for the proof that we’ve nodes (and so is more efficient) than A* guided by h2
found the shortest path, and no


Consistent (monotone) heuristic


– the f() value never decreases along any path.
unnecessary nodes. – use of a consistent heuristic improves the efficiency of
A* graph search because it ensures that once you
expand a node, you never have to re-expand it due to
finding a better path to that node

CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

How can we create heuristics? Summary of Properties of A*




An admissible heuristic can be created from a relaxed Good news: A* search is


(simplified) model of a problem. An optimal solution to the
relaxed problem is an admissible heuristic for the original – complete
problem.
– optimal
– number-of-tiles-out-of-place heuristic: the rules of the 8-
puzzle are relaxed so that a tile can move anywhere – optimally efficient among all such algorithms
– Manhattan heuristic: the rules of the 8-puzzle are » no other search algorithm that extends paths from
relaxed so that a tile can move to any adjacent square the root is guaranteed to open fewer nodes.
– minimal spanning tree heuristic for traveling salesman
problem: problem is relaxed so that a solution can be Bad news: number of nodes that must be
any structure that connects all cities opened is still exponential for many
problems. (Space is usually the killer).
CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

Problem Size Memory Bounded Search


8-puzzle: approximately 1.3 x 106 states In most heuristic searches, we run out of
15-puzzle: approximately 1013 states memory before we run out of time.
Rubik’s cube: approximately 4 x 1019 states Several search techniques have been
developed recently to address this issue.
24-puzzle: approximately 1025 states
We will consider one of these, IDA*
chess: approximately 10120 states
(iterative-deepening A*), which is a heuristic
Except for the 8-puzzle, the search graphs extension of DFID (depth-first iterative
for these problems are too large to store in deepening)
memory
CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence
Iterative Deepening A* (IDA*)


Iterative-deepening depth-first search with an Properties of IDA*


f-cost bound instead of a depth bound IDA* is complete and optimal under the


Beginning with an f-bound equal to the f-value same conditions as A*


of the initial state, perform a depth-first search Space requirement
bounded by the f-bound instead of a depth – proportional to longest path explored (bd)
bound.
Time complexity: depends on heuristic


Unless the goal is found, increase the f-bound


to the lowest f-value found in the previous Trick for speeding up IDA*: expand node
search that exceeds the previous f-bound, and successors in increasing order of their
restart the depth first search. heuristic values (called “node ordering”)
CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

A(21)
IDA* Complication
5 4


When the heuristic is different for every state, the


10
B (20) C (12) D (18)
number of new nodes included in the DFS with
8 12 4 7 8 11
each new limit is 1!
E(13) F(9) G (9) H(7) I (12) J(11)


We can increase the f-cost by a fixed amount ε on


3 11 7 2 7 3 5 12 3 4 each iteration. This makes the total number of
K (12) L ( 3) M(7) N(5) O(5) P(3) Q(10) R(8) iterations proportional to 1/ε, but the first solution
3 5 4 6 4 found is no longer guaranteed to be optimal.
S (10) T(0) U (0) 

However, the first solution found will not differ from


the optimal solution by more than a factor of ε.
Numbers in parentheses are h(n) 

And continuing the last depth-first search until it


Numbers on edges are operator costs finishes will eventually find an optimal solution.
CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

Similarities between path-finding


search and game-playing search Real-Time A* (RTA*)
There are several techniques that are useful


Interleaves search and execution


in both game-playing search and path- 

Does a partial search, takes what seems to be


finding search the best move, then repeats the partial search
Iterative deepening is one example to find the following move (this is inspired by
game-tree search)
Another example is interleaving search and
execution, that is, performing an incomplete


Not guaranteed to find an optimal path, but can


find a good path more quickly
search before selecting a move 

Attempts to minimize the sum of search and


Real-time A* search (RTA*) is an example execution costs
of this for path-finding search
CS 4633/6633 Artificial Intelligence CS 4633/6633 Artificial Intelligence

También podría gustarte