Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 19

Department of Computer Sciences

College of Computers & Information Technology

501481-3 Summer 2022

Artificial Intelligence
Chapter 5: Searching the
Knowledge Space –Informed Search

1
Introduction
• We have seen uninformed search methods
that systematically explore the state space and
find the goal
– They are typically too inefficient to do so in practice.
• Informed search methods use problem
specific knowledge (heuristic function) :
– to improve average search performance,
– and may be more efficient
Heuristic Search
• Heuristic Search:
Heuristic search use domain-specific knowledge
to traverse the search space.
This contrasts with blind search techniques that
use “brute force” methods to scan the
alternative nodes without any regard to
domain knowledge.

ES-Spring 2018, H.M.


Heuristics
• A heuristic is a rule of thumb that may help
solve a given problem. It serves as an aid to
learning, discovery, or problem-solving by trial
and error methods.

• Heuristics take problem knowledge into


consideration to help guide the search within
the domain.

Lecture 5: Informed search Artificial Intelligence 4


Hill-Climbing Search
STEEPEST
ASCENT

Hill-climbing algorithm (steepest ascent) is a loop that


continually moves in the direction of increasing value— that
is, uphill. It terminates when it reaches a “peak” where no
local neighbour has a higher value.
ES-Spring 2018, H.M.
Using Hill-Climbing to solve
the 8-Puzzle Problem

Simple Hill-Climbing Algorithm


- Perform Depth First Search, but,
- Select the child state with the
best heuristic value, h(n), and
make it the current state.
- Loop until a solution is found, or
there are no other nodes left in
the path.

ES-Spring 2018, H.M.


Stage ONE

Basic search problem could be stated as:


– Given [S, s, O, G] where:
• S is the set of states (implicitly specified).
• s is the initial state.
• O is the set of state transition operators
(actions).
• G is the set of goal state(s).
– Purpose: to find a sequence of state
transitions heading from s to a goal
state G.

ES-Spring 2018, H.M.


The Generated Search Space
3
A
U L R D
4 4 5 5
B C D E

L R
3 5
F G Steepest Descent
Local Minima
D
2
H
R D

I J
G

ES-Spring 2018, H.M.


The Generated Search Space
3
A
U L R D
5 5 4 4
B C D E

L R
6 4
F G Steepest Ascent
Local Maxima
D
7
H
R D

I J
G

ES-Spring 2018, H.M.


G

ES-Spring 2018, H.M.


Drawbacks of Hill-Climbing Search
Stuck at Local Maxima: Peak is not the highest point inn the space

To solve the
problem, we
introduce
RANDOMNESS
ES-Spring 2018, H.M.
Best-First Search
• In Best-First search, the search space is evaluated according
to a heuristic function.
• Nodes yet to be evaluated are kept on an OPEN list and
those that have already been evaluated are stored on a
CLOSED list.
• The OPEN list is represented as a priority queue, such that
unvisited nodes can be de-queued in order of their
evaluation function.
• The evaluation function f(n) is made up of two parts, which
are the heuristic function h(n) and the estimated cost g(n),
where:
f (n) = g(n)+h(n)
ES-Spring 2018, H.M.
Best-First Search

ES-Spring 2018, H.M.


Using Best-First Search
to solve the 8-Puzzle Problem

ES-Spring 2018, H.M.


Best-First Search &
the N-Queens Problem

•Let’s now discuss the Best-First


search algorithm in the context of a
large search space.

•The N-queens problem is a search


problem where the desired result is
an N by N board with N queens such
that no queen threatens another. 4-queens Problem
For this board, 4x4, in each of the 4x4 board
horizontal, vertical, and diagonal
rows, no queen is able to capture
another.
ES-Spring 2018, H.M.
Best-First Search &
the N-Queens Problem

Given a state (the board


configuration), we can identify
the child states for this board
by creating a new board for
each of the possible queen
position changes, given
horizontal movement only. This
board configuration can result
in six new child states (a single movement
queen change position in
threat
each).

ES-Spring 2018, H.M.


Best-First Search &
the 4-Queens Problem

ES-Spring 2018, H.M.


Best First Search & the N-Queens Problem

•Note that since we maintain a closed list, board


configurations that have already been evaluated
are not generated, resulting in a small tree and
more efficient search.
•For the heuristic, we’ll use the node’s depth in
the tree for h(n), and the number of conflicts
(number of queens that could capture another)
for g(n).
Best-First Search Challenge
4-Queens Problem

ES-Spring 2018, H.M.

You might also like