You are on page 1of 13

Artificial Intelligent

Search

Dr Ahmed Al-Arashi

August 2023

1
8/22/2023

Introduction

 How an intelligent agent can decide what


to do by considering the output of various
sequences of actions that it might take.

 Consider
the simplified rood map for
some Yemeni cities Fig. (SR1)

2
8/22/2023

Expert system 1
Introduction
Consider the simplified rood map for some Yemeni cities Fig. (SR1)

3
8/22/2023

Introduction
How to find the road from Sanaa to Taiz?

4
8/22/2023

Expert system 2
Introduction
 Start from initial stat i.e. Sanaa
 Expand Sanaa state i.e. find all successors, which are Amran,
Mahweet, Mareb, Dahmar and Bajel as shown in Fig. (SR2).
 Now which state should be expanded next?
 Next step depends on the search strategy the agent will use.

5
8/22/2023

Search Strategy
In order to reach to a reasonable solution
with in certain time a good search strategy
should be adopted.

Good search strategy should have the


following characteristics:
 It should cause motion.
 It should be systematic.

6
8/22/2023

Expert system 3
Search
Search is a step by step method to solve a search
problem in a specified search space.

In other words, search is a class of techniques for


systematically finding or constructing solutions to
problems.
Example
1. Generate a possible solution.
2. Test the solution.
3. If solution found THEN done ELSE return to
step 1. 7
8/22/2023

Search thru a Problem Space /


State Space
Input:
– Set of states
– Operators
– Start state
– Goal state
Output:
– Path: start  a state satisfying goal test
– [May require shortest path]

Expert system 4
Search evaluation criteria
 Competence: is the strategy guaranteed to
obtain a solution if there is one?
 Time complexity: how long does it take to
find a solution?
 Space complexity: how much memory
does it need to find a solution?
 Optimality: does the strategy find highest
quality solution when there are several
different solutions?
9
8/22/2023

Type of Search
Uninformed/Blind Search
This type of search takes all nodes of tree in a
specific order until it reaches to goal. The order can
be in the breath and the strategy will be called
breadth–first–search, or strategy will be called depth
first search
Informed/Heuristic Search
It uses additional information to guide the search by
using a function to estimate how close a state is to
the goal stat.
10
8/22/2023

Expert system 5
Depth-firset
 When a state is examined
all its children and
descendants are examined
before any siblings.
 It goes deeper until a dead
end is hit or goal is found.
 If dead end is hit the most
recently created state from
which alternative moves
are available are revisited
and new state are created .
Progress to search is shown
in the Fig
11
8/22/2023

Depth-firset
Procedure to implement depth first search using Two
lists waiting end done
 Waiting is the list containing the initial state and done
is empty
 Repeat until waiting is empty or goal state is on the
end of done.
 Remove the first state from waiting and put it at the
end of done, find its successors and put it the
beginning of waiting
Advantage of depth first search
 Requires less memory since only nodes on current
bath are stored.
 By chance it might find solution with out searching
much of the state space 12
8/22/2023

Expert system 6
Depth firset

13
8/22/2023

Breadth firset
 The root is expanded
first.
 Then all the nodes
generated by the root
are expanded next.
 Then their successors.

The Figure to the right


shows the progress at the
search.

14
8/22/2023

Expert system 7
Breadth first
Procedure to implement breadth first search using two
waiting and done.
 Waiting containing the initial state and done is empty.
 Repeat until waiting is empty or goal state is on the
end of done.
 Remove from waiting and put it at the end of done,
find its successors and put it the end of waiting.

Advantage of breadth first search


 It with not get trapped at end of state space path.

15
8/22/2023

Breadth First Search

16
8/22/2023

Expert system 8
Looking to some search problem
1- Traveling Salesman Problem
A salesman has to visit N cities to sale his products. How
can he plan his trip so that all cities are visited.
 Optimal solution is costly to fine as no of solutions for
blind search N!
 Acceptable solution may be found applying the
following
 Select any city to start from

 Visit the nearest city to the current city which has


not been visited
 Repeat 2 until all city are visited.
17
8/22/2023

Looking to some search problem


2- Puzzle Problem
In an eight digit 9 empty tiles puzzle has certain
initial stat and it is required to reach certain goal
stat. how can it be done?
 Optimal solution can take 9! = 362880
 Different Arrangements may be trailed.
 Search can be improved using the following
 Checking number of tails in the wrong position

 Checking the sum of distances of the tile from


their goal position.
18
8/22/2023

Expert system 9
Looking to some search problem
3- Book finding problem
If a book is lost in in a house with N rooms. How
normally people search the house to find the lost
book.

 Blind search for a lost book in a house with N rooms


may take long time (start from the first room moving
in a straight line forth and back).
 Search may be improved using the following.
 Select only rooms when reading has been done

 Start with the places where most of the reading


has been done. 19
8/22/2023

Looking to some search problem


Findings
From the three previous problems, It could be
concluded that:
 Most of the people would use additional information to
reduce search space.
 It does not guarantee the solution but it works.
 Exact solution is not always needed but an acceptable
one will be ok.
 It is faster than blind/unguided search.
 It leads to deeper understanding of the problem.
20
8/22/2023

Expert system 10
Heuristic Search
 It is the search strategy that use any sort of
information to guide the search.
 It is also know as guided search, directed
search or informed search.
 Knowledge about the knowledge, when
available, is used to guide the search.
 Heuristic Search is much faster than blind
search.
 In this type of search exact solution is not
always guaranteed.
21
8/22/2023

Heuristic Search
 There are number Heuristic Search methods,
we will look at the following ones:
(I) Hill climbing search
(a) Simple hill climbing search
(b) Steepest-ascent Hill climbing
(II) Best first search method
 Any Heuristic Search would need an algorithm
that have two “Functions”
1- Generate: It Generates a solution
2- Evaluate: It Evaluates the solution
22
8/22/2023

Expert system 11
(I) Hill climbing search
It is a depth first search method with evaluation
function that can decide which direction to move
in the search space we can look at two forms of
hill climbing search method Which are:
(a) Simple hill climbing search
In this search method the first better successor is
considered.
(b) Steepest-ascent Hill climbing
In this method all the successors are checked before
making a move the most promising one is select.
23
8/22/2023

(a) Simple hill climbing search Algorithm


Algorithm
 Evaluate initial state if goal stop, otherwise make
the initial state the current state.
 Repeat until all nodes one examined or solution is
found
 Select a successor that has not been visited.
 Evaluate the successor

– If it is a goal state stop .


– If not goal state but better then current ,then
make it current state.
– If not goal stat end not better then current
state, then repeat. 24
8/22/2023

Expert system 12
(b) Steepest-ascent Hill climbing Algorithm
1-Evaluate the initial stat. If a goal state stop. Else make it
the current state.
2-Repeat until solution is fond or all nodes are examined.
2. 1. generated successors of the current state and
select a successor. Make it temporary state.
2.2.evaluate all other successors of the current state one
by one
 if the successor is a goal state stop.

 if not the goal state then compare it with the temp


successor
 If better then temp. successor make it temp successor
and repeat 2.2
 If not better leave it and repeat 2.2

2.3. make temp. Successor current state. 25


8/22/2023

(II) Best first search method


In best first search use the available knowledge to direct
the search . it differs from hill climbing search in that it
is not limited to the children or a node but the most
promising successor all the nodes in the waiting list.
Algorithm
1-Evaluate initial state , if it is a goal state stop. Otherwise
put it in waiting list
2-Repeat until solution found or all nodes have been
examined.
 Assess on the states in waiting and remove the
most promising , generate it is successors and put
then in waiting
26
8/22/2023

Expert system 13

You might also like