Lecture-3.1 Heuristic Search
Lecture-3.1 Heuristic Search
Search
Implementation:
Order the nodes in fringe increasing order of cost.
initial state
Greedy Best‐First Search
• f(n) = h(n) : Expand node that appears to be
closest to the goal
Greedy Best‐First Tree Search Example
• Go from Arad to Bucharest
• f(n) = hSLD(n) = straight‐line distance from
n.STATE to Bucharest h (n)
SLD
234
Greedy Best‐First Tree Search Example
h (n)
Greedy Best‐First Tree Search Example
h (n)
Greedy Best‐First Tree Search Example
h (n)
h=176
h=193
Greedy Best‐First Tree Search Example
h (n)
Greedy Best‐First Tree Search Example
Optimal solution
Properties of greedy best-first search
Complete? No – can get stuck in loops, e.g., Iasi
Neamt Iasi Neamt
• Complete in finite space with repeated-state
checking
• Time? O(bm), but a good heuristic can give
dramatic improvement
• Space? O(bm) -- keeps all nodes in memory
• Optimal? No
Figure 2 is an example of a route finding problem. S is the starting state, G is the goal state.
Figure 2
Let us run the greedy search algorithm for the graph given in Figure 2.
The straight line distance heuristic estimates for the nodes are shown
in Figure
Figure 3
Step 1: S is expanded. Its children are A and D.
h(n)
A* search example
h(n)
A* search example
h(n)
h(n)
h(n)
Solution is optimal!
is this a coincidence?
f-bound ôf(S)
• Algorithm:
– WHILE (goal is not reached) DO
• f-bound ôf-limitted_search(f-bound)
– Perform f-limited search with f-bound
(See next slide)
IDA* Algorithm
Problem
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
IDA* Search
Why do we use IDA*?
6
SMA* By Example
SMA* By Example
SMA* By Example
Hill Climbing Search
Hill Climbing is heuristic search used for mathematical optimization
problems in the field of Artificial Intelligence .
Given a large set of inputs and a good heuristic function, it tries to find a
sufficiently good solution to the problem. This solution may not be the
global optimal maximum.
7
9
Hill Climbing
• It is simply a loop that continually moves in the direction of increasing value
that is uphil.
• It terminates when it reaches a peak where no neighbor has a higher value.
• Example: unfamiliar city, no map, you want to get downtown
• You simply aim for the tall buildings
• The algorithm does not maintain a search tree, so the data structure for the
current node need only record the state and the value of the objective
function.
• Does not look ahead beyond the immediate neighbors of the current state.
• Trying to find the top of Mount Everest in a thick fog while suffering from
amnesia
Features of Hill Climbing
Greedy approach: Hill-climbing algorithm search moves in the direction which optimizes the
cost.
No backtracking: It does not backtrack the search space, as it does not remember the previous
states.
(c) if the SUCC is better than current state, then set current state to
SUCC
Advantages of Hill Climbing
It can be used in continuous as well as discrete
domains.
Problems of Hill-climbing search
• Both basic & steepest-ascent hill climbing may
fail to find a solution
• Either algo may terminate not by finding a
goal state but by getting to a state from which
no better states can be generated.
• This will happen if the program reached either
a local maximum, a plateau, or a ridge
Local maximum
2.Skip- Make a big jump in some direction to try to get a new section of the search
space.
-this is particularly good way of dealing with plateaus
-if the only rules available describe single small steps, apply several times in the same
direction
• Heuristic function +1
Local: +1
+1
-add 1 point for every +1
block that is resting on +1
thing it is supposed to be +1
resting on. +1
-1
• Hill climbing will halt +1
+1
-because all these states +1 +1
+1 +1 +1
have lower scores +1 +1 +1
than the current state +1 +1 +1
+1 -1 +1 +1 -1 +1
-the process has -1 +1 -1 -1
reached a local
Score= 6-2=4 Score= 6-2=4
maximum that is not Score= 6-2=4
p ( x ) e kT
e /e e 1 for small T
kT
In (b), each state is rated by the evaluation function or (in C;A terminology) the fitness
function.
A fitness function should return higher values for better states, so, for the 8-queens problem we
use the number of non attacking pairs of queens, which has a value of 28 for a solution.
The values of the four states are 24, 23, 20, and 11. I in this particular variant of the genetic
algorithm, ithe probability of being chosen for reproducing is directly proportional to the
fitness score, and the percentages are shown next to the raw score
In (c), a random choice of two pairs is selected for reproduction, in accordance with the
probabilities in (b). Notice that one individual is selected twice and one not at all.
For each pair to be mated, a crossover point is randomly chosen from the positions in the string.
In Figure 4.15 the crossover points are after the third digit in the first pair and after the fifth digit
in the second pair
In (d), the offspring themselves are created by crossing over the parent strings at the
crossover point. For example, the first child of the first pair gets the first three digits from the
first parent and the remaining digits from the second parent, whereas the second child gets the
129
first three digits from the second parent and the rest from the first parent
When to Use Genetic Algorithms ?
GAs are not good for all kinds of problems. They’re best for problems where there is
a clear way to evaluate fitness. If your search space is not well constrained or your
evaluation process is computationally expensive, GAs may not find solutions in a
sane amount of time. In my experience, they’re most helpful when there is a decent
algorithm in place, but the “knobs” just need to be tweaked.
Limitations of GA