Sie sind auf Seite 1von 27

Introduction to AI

AAPP002-4-2 Ver 1.0

Informed Search _ Hill Climbing


Topic & Structure of The Lesson

• Informed Search_hill climbing search

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 2 of 27


Learning Outcomes

• At the end of this topic, You should be


able to
• Informed Search
• Hill climbing
• A* Search

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 3 of 27


Key Terms You Must Be Able To
Use
• If you have mastered this topic, you should be able to use the
following terms correctly in your assignments and exams:

• Hill Climbing

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 4 of 27


Hill climbing

• Always head towards the best successor


node.

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 5 of 27


Algorithm

• Start : current state = initial state


• Loop: Until current-state = goal-state or there is no
change in the current state do
(a) get the successors of current state and use the
evaluation function to assign a score to each
successor.
(b) if one of the successors has a better score than
current-state then set the new current state to the
successor with the best score.

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 6 of 27


Hill Climbing

• Algorithm does not attempt to exhaustively try every


node and path.

• If loops in the search space then using hill climbing you


should not encounter them.

• Terminates when there are no successors of the current


state which are better than the current state itself.

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 7 of 27


Limitations of Hill climbing

• Local maxima:
• Points which are better than the surrounding state but
which are not the solution.
• Solution:
– Altering or extending algorithm a bit.
– Use limited backtracking
– Weaken the restriction that the next state has to be better by
looking ahead a bit in the search. (may be the next but one state
should be better than the current one)
• Hill climbing is good for only limited class of problems.

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 8 of 27


Steepest-Ascent Hill Climbing

• A variation on simple hill climbing.


• Instead of moving to the first state that is
better, move to the best possible state that
is one move away.
• The order of operators does not matter.

• Not just climbing to a better state, climbing


up the steepest slope.
9
AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 9 of 27
Example

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 10 of 27


Example Problem II
(Discrete)

The Traveling Salesman Problem


(TSP)
A salesman spends his time visiting n
cities. In one tour he visits each city
just once, and finishes up where he
started. In what order should he visit
them to minimize the distance
traveled?

A B C
A 0 12 34 ...
B 12 0 76 ...
C 34 76 0 ...
... ... ... ... ...

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 11 of 27


• Problem: depending on initial state, can
get stuck in local maxima

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 12 of 27


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.

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 13 of 27


Limitations of Hill Climbing

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

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 14 of 27


Limitations of Hill Climbing
Ridge
The orientation of the high region, compared
to the set of available moves, makes it
impossible to climb up.
However, two moves executed serially may
increase the height.

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 15 of 27


Solutions to limitations

– Altering or extending algorithm a bit.

– Use limited backtracking

– Weaken the restriction that the next state has to be


better by looking ahead a bit in the search. (may be
the next but one state should be better than the
current one)

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 16 of 27


Simulated Annealing
• Named after a metal-casting technique
–molten metal is gradually annealed
–gradual temperature decrease results in a low
energy structure
–analogous to a lost cost solution
• Purpose - to avoid the problem of local minima
• Propose steps in random directions
• Accept moves which lower cost and some which
increase it

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 17 of 27


Simulated Annealing

• Based on physical process of annealing a metal to get


the best (minimal energy) state.

• Hill climbing with a twist:


– allow some moves downhill (to worse states)
– start out allowing large downhill moves (to much
worse states) and gradually allow only small downhill
moves.

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 18 of 27


Simulated Annealing (cont.)

• The search initially jumps around a lot,


exploring many regions of the state space.

• The jumping is gradually reduced and the


search becomes a simple hill climb
(search for local optimum).

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 19 of 27


Simulated Annealing

6
2 4
3 5
1

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 20 of 27


Two Player Game: Max and Min

• To reach a promising ending state

• Problem:
Max must reach a terminal state with as high a utility
as possible regardless of Min’s moves

• Max must develop a strategy that determines best


possible move for each move Min makes.

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 21 of 27


Min Max Algorithm

Determines optimum strategy for Max:

• Generate entire search tree.


• Apply utility function to terminal states.
• Use utility value of current layer to determine utility of
each node for the upper layer.
• Continue when root node is reached.
• Maximizes the utility for Max based on the assumption
that Min will attempt to Minimize this utility.

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 22 of 27


Example

3 2 2

3 12 8 2 4 6 14 5 2

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 23 of 27


Quick Review Question

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 24 of 27


Summary of Main Teaching Points

• Hill-climbing algorithms keep only a single


state in memory, but can get stuck on local
optima

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 25 of 27


Question and Answer Session

Q&A

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 26 of 27


What we will cover next

• A* search

AAPP002-4-2 Introduction to Artificial Intelligence Informed Search Slide 27 of 27

Das könnte Ihnen auch gefallen