Sei sulla pagina 1di 31

INT4204

INTELLIGENT SYSTEMS
INFORMED SEARCH
SLIDE 2 OF 9 2
SLIDE ‹#› OF 9 3
Heuristics
To do this, we use heuristics (informed guesses)
Heuristic means “serving to aid discovery”
Can find solutions more efficiently than can an uninformed search
The Heuristic is any device that is often effective but will not
guarantee work in every case
Try to explore the promising paths before the less promising path.
Evaluation function: scores a node in the search tree according to
how close to the target state it seems to be(will just be a guess but
should b helpful)
Heuristic search
Example: 8 Puzzle

1 2 3 1 2 3
7 8 4 8 4
6 5 7 6 5
Heuristic search
1 2 3 GOAL 1 2 3
8 4 7 8 4
7 6 5 6 5
up
left right

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

Which move is best?


Heuristic search
What heuristic(s) can we use to decide which 8-
puzzle move is “best” (worth considering first).
Number of tiles in the correct position.
Number of tiles in the incorrect position.
Manhattan Distance
Heuristic search
Number of tiles in the correct position.
◦ The higher the number the better.
◦ Easy to compute (fast and takes little memory).
◦ Probably the simplest possible heuristic.
Heuristic search
Number of tiles in the incorrect position.
◦ This can also be considered a lower bound on the number of moves from a
solution!
◦ The “best” move is the one with the lowest number returned by the
heuristic.
Number of tiles in the incorrect position

1 2 3
Current
State 4 5 6
7 8 N N N
• The number
of misplaced N N N
1 2 3
tiles (not Goal N Y
including the State 4 5 6
blank) 7 8

In this case, only “8” is misplaced, so the heuristic


function evaluates to 1.
In other words, the heuristic is telling us, that it thinks a
solution might be available in just 1 more move.

Notation: h(n) h(current state) = 1


SLIDE 10 OF 9
Manhattan Distance
Count how far away (how many tile movements)
each tile is from it’s correct position.
Sum up this count over all the tiles.
This is another estimate on the number of moves
away from a solution.
Manhattan Distance
3 2 8 3 3
Current
State 4 5 6 2 spaces
7 1
• The Manhattan
Distance (not 8
including the 1 2 3
blank) Goal 3 spaces
State 4 5 6
8
7 8
1
In this case, only the “3”, “8” and “1” tiles are
misplaced, by 2, 3, and 3 squares respectively, so 3 spaces
the heuristic function evaluates to 8. 1
In other words, the heuristic is telling us, that it thinks
a solution is available in just 8 more moves. Total 8

Notation: h(n) h(current state) = 8


Heuristic search
algorithms
Generate and Test
Best first search
Greedy search
Hill climbing
Simulated annealing
Min-Max algorithm
Algorithm A search
Admissible hueristics
A* search
Generate-and-Test
Acceptable for simple problems.
Inefficient for problems with large space.
Algorithm
1. Generate a possible solution.
2. Test to see if this is actually a solution.
3. Quit if a solution has been found.
Otherwise, return to step 1.

14
Generate-and-Test
Example - Traveling Salesman
Problem (TSP)
• Traveler needs to visit n cities.
• Know the distance between each pair of cities.
• Want to know the shortest route that visits all the cities
once.
• n=80 will take millions of years to solve exhaustively!

SLIDE 15 OF 9
Generate-and-Test
TSP Example
From A to C

ABC =
ADC =

A B
ABDC =
6 ADBC
AC =

1 2
5 3

D 4 C
Best-first search
Uses a list of nodes that are to be further explored.
Always removes the best node from the list i.e. the one
with the best score.
The successors of the best node will be evaluated and will
be added to the list.
Uses a priority queue rather than a stack or simple queue.
This can be achieved by applying appropriate Heuristic
function to each of them.
Best-first search
Heuristic function: f(n) = h(n) 
where,
h(n) - estimated straight line distance from node n to goal
To implement the graph search procedure ,we will need to
use two list of nodes.
OPEN- nodes that have been generated but have not been
visited yet
Closed - nodes that have been already visited
SLIDE 19 OF 9 19
Best-first search
Example

SLIDE 20 OF 9 20
Best-first search
Example

SLIDE 21 OF 9 21
Best-first search
Example

Total cost: 1+3+1=5

SLIDE 22 OF 9 22
Hill Climbing
Very simple idea: Start from some state s,
Move to a neighbor t with better score. Repeat.
Question: what’s a neighbor?
◦ You have to define that!
◦ The neighborhood of a state is the set of neighbors
◦ Also called ‘move set’
Hill Climbing
Example: N-queen (one queen per column). One possibility
◦ Pick the right-most most-conflicting column;
◦ Move the queen in that column vertically to a different location
Hill Climbing
Basic idea: always head towards a state which is better than
the current one.
Example: if you are at town A and you can get to town B and town C
(and your target is town D) then you should make a move IF town B
or C appear nearer to town D than town A does.

Hill climbing terminates when there are no successors of


the current state which are better than the current state
itself. If a solution is found, it is found for a very short time
and with minimum memory requirements.
However it is not guaranteed that a solution will be found -
the local maxima problem.
Algorithm
Limitations of Hill Climbing
Local Maximum
A state that is better than all of its neighbours, but not better
than some other states far away
or
Points which are better than the surrounding state but which are
not the solution.
Limitations of Hill Climbing

Plateau
A flat area of the search space in which all neighbouring states have the same
value.
Limitations of Hill Climbing

Ridge
It is a special kind of local maximum.
It is an area of the search space which is higher than the surrounding areas
and that itself has a slope.
We cannot travel the ridge by single moves as the orientation of the high
region compared to the set of available moves makes it impossible.
Solution to the problem
◦ Trying different paths at the same time is a solution. We can apply two or more rules
before doing the test. This corresponds to moving in several directions at once.
Variation of Simple Hill Climbing
Steepest-Ascent Hill climbing : It first examines all the neighboring nodes and
then selects the node closest to the solution state as next node.
Stochastic hill climbing : It does not examine all the neighboring nodes before
deciding which node to select. It just selects a neighboring node at random,
and decides (based on the amount of improvement in that neighbor) whether
to move to that neighbor or to examine another.
First-choice hill climbing: Generates successors randomly until one is
generated that is better than current state. This is a good strategy when a state
may have hundreds or thousands of successor states.
Random-restart Hill-climbing: If you don’t succeed the first time, try, try again.
If the first hill-climbing attempt doesn’t work, try again and again and again!
That is, generate random initial states and perform hill-climbing again and
again.

31

Potrebbero piacerti anche