Sei sulla pagina 1di 35

Introduction to AI

AAPP002-4-2 Ver 1.0

Intro to Informed Search


Topic & Structure of The Lesson

• Introduction to Informed Search

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 2 of 35


Learning Outcomes

• At the end of this topic, You should be


able to
• Introduction to Informed Search
• Heuristic search
• Generate and test
• Best First Search

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 3 of 35


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:

• Heuristics
• Greedy search search
• Best first search

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 4 of 35


Introduction to informed search

• The search space of a problem: Number of possible


states in the search.

• Searching large search spaces is inefficient using


uninformed methods.

• Solution: Additional domain knowledge about the


problem

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 5 of 35


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

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 6 of 35


Heuristics

Heuristics are educated guesses, intuitive


judgments or simply common sense.

A heuristic adds to the decrease of search in a


problem-solving activity.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 7 of 35


Heuristic search

• 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 Searching

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 8 of 35


Heuristic search

• We define a heuristic function h(n):


– Is computed from the state at node n
– Uses domain-specific information in some way

• Heuristics can estimate the “goodness” of a particular


node (or state) n:
– How close is n to a goal node?
– What might be the minimal cost path from n to a
goal node?

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 9 of 35


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
AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 10 of 35
Generate-and-Test

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.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 11 of 35


Generate-and-Test

• Acceptable for simple problems.


• Inefficient for problems with large space.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 12 of 35


Generate-and-Test

• Exhaustive generate-and-test.
• Heuristic generate-and-test: not consider
paths that seem unlikely to lead to a
solution.
• Plan generate-test:
- Create a list of candidates.
- Apply generate-and-test to that list.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 13 of 35


Generate-and-Test

Example: coloured blocks


“Arrange four 6-sided cubes in a row, with
each side of
each cube painted one of four colours, such
that on all four
sides of the row one block face of each
colour is showing.”

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 14 of 35


Generate-and-Test

Example: coloured blocks

Heuristic: if there are more red faces than


other colours
then, when placing a block with several red
faces, use few
of them as possible as outside faces.

15
AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 15 of 35
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.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 16 of 35


Algorithm

• Start with List = [initial state]

• While List not empty do:


• (a) Remove the best node from the List.

• (b) If it is the goal node then return with success.


Otherwise find its successors.

• (c) Assign the successor nodes a score using the


evaluation function and add the scored nodes to List.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 17 of 35


Search tree illustrating best first
search
A : 10

B:5 C:3

D:4 E:2 F:6

G:0

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 18 of 35


Best First Search: Example
A Open
B 4 D 6 closed
C 4

E 5 F 6 G 4 H 3 I 6 J 4

K 7 L 8 M 5 N 4 O 2 P 3 Q 7 R 4

Note: P is the goal


S 6 T 1
H.W: Repeat the same example when T is the goal.
AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 19 of 35
Best-First Search

• OPEN: nodes that have been generated,


but have not examined.
This is organized as a priority queue.

• CLOSED: nodes that have already been


examined.
Whenever a new node is generated, check
whether it has been generated before.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 20 of 35


Rations for evaluation function

• Good evaluation function: cut down the amount


of search
• Should not be expensive

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 21 of 35


Termination conditions

• Instead of terminating when a path is found, terminate


when the shortest incomplete path is longer than the
shortest complete path.

• In most problems of practical interest, the entire search


space graph will be too large to be explicitly represented
in a computer memory.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 22 of 35


Results of Best-First search

• It is not guaranteed to find an optimal solution, but


normally it finds some solution faster than any other
methods.
• The performance varies directly with the accuracy of the
heuristic evaluation function.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 23 of 35


Greedy best-first search

• Greedy search is the best-first search strategy, with a


simple evaluation function of f(n) = h(n).

• It relies only on the heuristic to select what is currently


believed to be closest to the goal state.

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 24 of 35


AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 25 of 35
Out-and-about in Symbolania (1)

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 26 of 35


Greedy Search in Symbolania (1)

• E to A
• h(E)=39
• h(D)=25 h(F)=47
• h(A)=0 h(C)=20 h(E)=39 h(F)=47
• -> Path = EDA
AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 27 of 35
Greedy Search in Symbolania (2)

• F to A
• h(F)=47
• h(D)=25 h(E)=39 h(G)=65
• h(A)=0 h(C)=20 h(E)=39 h(E)=39 h(F)=47 h(G)=65
• -> Path = FDA (optimal path is FEDA)
• Greedy search is not optimal
AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 28 of 35
Greedy Search in Symbolania (3)

• H to A
• h(H)=61
• h(I)=50 h(G)=65
• h(H)=61 h(G)=65
• h(I)=50 h(G)=65
• ...
• Greedy search is not complete

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 29 of 35


Results

• Results of Greedy search algorithm may not be optimal,


but is often efficient .

• Greedy Search is generally faster than the uninformed


methods
– It has more knowledge about the problem domain!

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 30 of 35


Limitations of Greedy Search

• Resembles DFS in that it tends to follow a path that is initially


good, and thus:
– Not complete (could chase an infinite path or get
caught in cycles if no open/closed lists)
– Not optimal (a better solution could exist through an
expensive node)

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 31 of 35


Quick Review Question

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 32 of 35


Summary of Main Teaching Points

• The search techniques apply to a search


tree which contains all the different
permutations or choices possible when
starting from one state and trying to reach
a ‘goal’ state

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 33 of 35


Question and Answer Session

Q&A

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 34 of 35


What we will cover next

• Hill Climbing

AAPP002-4—2 Introduction to Artificial Intelligence Informed Search Slides 35 of 35

Potrebbero piacerti anche