Download Artificial Intelligence Informed or Heuristic Search Heuristic

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Artificial intelligence in video games wikipedia , lookup

Minimax wikipedia , lookup

Embodied cognitive science wikipedia , lookup

Technological singularity wikipedia , lookup

AI winter wikipedia , lookup

Philosophy of artificial intelligence wikipedia , lookup

History of artificial intelligence wikipedia , lookup

Ethics of artificial intelligence wikipedia , lookup

Intelligence explosion wikipedia , lookup

Existential risk from artificial general intelligence wikipedia , lookup

Transcript
Informed or Heuristic Search
Use knowledge about the problem domain
to explore the search space more efficiently
● Domain knowledge is contained in a
heuristic (evaluation) function
●
Artificial Intelligence
Problem-Solving Search: A*
(chapter 4)
CS 4633/6633 Artificial Intelligence
CS 4633/6633 Artificial Intelligence
Heuristic Functions
●
●
●
●
Heuristic: problem-specific knowledge that
reduces expected search effort.
Heuristic functions evaluate the relative desirability
of expanding a node.
Heuristics are often estimates of the distance, or
cost, from the current state to the goal
Time spent evaluating the heuristic function must
be recovered by a reduction in search time.
CS 4633/6633 Artificial Intelligence
Require that h(n) = 0 if n is a goal
state
Best-First Search
1
2
3
1
2
7
8
4
3
4
5
5
6
7
8
Initial State
h(n) = estimated cost of the cheapest
path from the state at node
n to a goal state
CS 4633/6633 Artificial Intelligence
Examples
6
Notation
Goal
function BEST-FIRST-SEARCH(problem, EVAL-FN)
returns a solution sequence
inputs: problem, a problem
EVAL-FN, a heuristic evaluation function
Queueing-Fn ← a function that orders nodes by EVAL-FN
return GENERAL-SEARCH(problem, QUEUEING-FN)
Heuristic Function 1: Number of misplaced tiles
Heuristic Function 2: Total Manhattan distance
CS 4633/6633 Artificial Intelligence
The queue is a priority queue and the frontier (open) node that is
expanded next is the one that seems “best” according to the
evaluation function.
CS 4633/6633 Artificial Intelligence
Greedy Search
Characteristics of Greedy Search
Resembles depth-first search (prefers a
single path until it hits a dead-end.)
● Not optimal. Why?
● Not complete. Why?
● Worst case time complexity O(bm) where m
is the maximum depth of search
● Space complexity same as time complexity.
● Usually run out of space before time.
●
The priority queue is sorted in increasing
order of h(n)
● The frontier node that is thought to be
“closest” to the goal state is always
expanded next
●
CS 4633/6633 Artificial Intelligence
CS 4633/6633 Artificial Intelligence
A* in Relationship to
Other Search Algorithms
A* Search
Minimizes the total path cost
● The priority queue is sorted in increasing
order of this evaluation function:
●
f(n) = g(n) + h(n)
g(n): cost of path from start to node n
h(n): estimate of cost of path from n to goal
f(n): estimated cost of the cheapest solution
through n
●
What if h( ) = 0 for every state?
– Uniform-cost search
What if we make g( ) = 0?
– Greedy search
● A* combines the best properties of uniformcost and greedy search
●
CS 4633/6633 Artificial Intelligence
CS 4633/6633 Artificial Intelligence
A(21)
A* Search
5
1. Start with OPEN containing just the initial state.
2. Until a goal is found or there are no nodes on OPEN do:
(a) Select the node on OPEN w/ the lowest f-value.
(b) Generate its successors.
(c) For each successor do:
i. If it hasn’t been generated before (i.e., it’s not in CLOSED),
evaluate it, add it to OPEN, and record its parent.
ii. If it has been generated before, change the parent if this
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
node to CLOSED list.
CS 4633/6633 Artificial Intelligence
8
3
11
K (12)
3
F(9)
7
L ( 3)
5
S (10)
C (12)
2
M(7)
4
D (18)
4
7
G (9)
H(7)
12
E(13)
4
10
B (20)
7
3
N(5)
O(5)
8
11
I (12)
5
12
P(3)
6
3
Q(10)
4
T(0)
Numbers in parentheses are h(n)
Numbers on edges are operator costs
CS 4633/6633 Artificial Intelligence
J(11)
U (0)
4
R(8)
Admissible Heuristic Functions
Completeness of A*
●
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
the actual cost of the best solution through n.
● A* requires an admissible heuristic to have
the properties of completeness and optimality
●
●
A* expands nodes in increasing order of f.
So it must eventually reach a goal state
unless there are infinitely many nodes with
f(n) < f*, which is possible only if
– there is a node with an infinite branching factor
– there is a path with a finite path cost but an
infinite number of nodes along it.
CS 4633/6633 Artificial Intelligence
CS 4633/6633 Artificial Intelligence
Formal statement of
completeness of A*
Optimality of A*
We want to prove that A* is optimal (i.e., it
will always find the best solution).
● Terminology.
●
A* is complete on locally finite
graphs (graphs with a finite
branching factor) provided there is
some positive constant δ such that
every operator costs at least δ.
– f* is the cost of the optimal solution path
– f* ≥ f(n) because the heuristic is admissible
Will use a proof by contradiction.
● Remember that all goal states have h(n) = 0.
●
CS 4633/6633 Artificial Intelligence
Start
n
G
Optimal goal
state
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
expanded. Assume that G2 is about to be
expanded.
Since h is admissible: f* ≥ f(n)
If n is not chosen for expansion, then
f(n) ≥ f(G2).
Therefore
f* ≥ f(G2)
But, since G2 is a goal state
h(G2) = 0
G2
f(G2) = g(G2)
f* ≥ g(G2)
This contradicts the assumption that G2 is
Suboptimal
suboptimal. Therefore, A* never selects
goal state
a suboptimal goal for expansion.
CS 4633/6633 Artificial Intelligence
CS 4633/6633 Artificial Intelligence
A* is maximally efficient
For a given heuristic function, no optimal
algorithm is guaranteed to do less work.
● Aside from ties in f( ), A* expands every
node necessary for the proof that we’ve
found the shortest path, and no
unnecessary nodes.
●
CS 4633/6633 Artificial Intelligence
Summary of Properties of A*
●
Contour interpretation of A*
Good news: A* search is
– complete
– optimal
– optimally efficient among all such algorithms
» no other search algorithm that extends paths from
the root is guaranteed to open fewer nodes.
●
Complexity of A*
f=16
Goal
Effective branching factor
heuristic error = |h(n) - h*(n)|
● Complexity of search is exponential unless
the heuristic error grows logarithmically in
the path cost
● But heuristic search is usually at least
proportional to the path cost. Therefore,
search complexity is usually exponential.
the average number of successors that
emerge from any node
T = B0 + B1 + B2 + B3 + … + BD
(
B −1
T = total number of nodes generated
D = depth of solution
B = effective branching factor
CS 4633/6633 Artificial Intelligence
Properties of heuristics
Given two admissible heuristics h1 and h2, if h1(n)
≥ h2(n) for all n, then h1 dominates h2 and
creates a more efficient search
Monotone heuristic = The f() value never
decreases along any path.
Monotonicity can be maintained by the pathmax
equation:
f(n’) = max(f(n), g(n’)+h(n’))
CS 4633/6633 Artificial Intelligence
)
D
T = B B −1
CS 4633/6633 Artificial Intelligence
●
f=14
CS 4633/6633 Artificial Intelligence
●
●
f=12
Bad news: number of nodes that must be
opened is still exponential for many
problems. (Space is usually the killer).
CS 4633/6633 Artificial Intelligence
●
f=10
Start
How can we create heuristics?
●
An admissible heuristics can be created from a relaxed
(simplified) model of a problem. An optimal solution to the
relaxed problem is an admissible heuristic for the original
problem.
– number-of-tiles-out-of-place heuristic: the rules of the 8puzzle are relaxed so that a tile can move anywhere
– Manhattan heuristic: the rules of the 8-puzzle are
relaxed so that a tile can move to any adjacent square
– minimal spanning tree heuristic for traveling salesman
problem: problem is relaxed so that a solution can be
any structure that connects all cities
CS 4633/6633 Artificial Intelligence