Professional Documents
Culture Documents
Search
Dr Ahmed Al-Arashi
August 2023
1
8/22/2023
Introduction
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.
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.
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.
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.
15
8/22/2023
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
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.
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
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.
Expert system 13