Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views56 pages

Lect # 4 Search Methodology - Blind Search

The document discusses various concepts related to search spaces in Artificial Intelligence, including definitions of states, initial states, goal states, and the formulation of problems as search problems. It explains different search methodologies such as blind search and heuristic search, along with examples like the Missionaries and Cannibals problem and the Traveling Salesman problem. Additionally, it covers performance metrics for search algorithms, including completeness, optimality, and complexity.

Uploaded by

Karim Sherif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views56 pages

Lect # 4 Search Methodology - Blind Search

The document discusses various concepts related to search spaces in Artificial Intelligence, including definitions of states, initial states, goal states, and the formulation of problems as search problems. It explains different search methodologies such as blind search and heuristic search, along with examples like the Missionaries and Cannibals problem and the Traveling Salesman problem. Additionally, it covers performance metrics for search algorithms, including completeness, optimality, and complexity.

Uploaded by

Karim Sherif
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 56

Artificial

Intelligence
Associate Professor : Walaa H. El-Ashmawi

E-mail:
[email protected] [email protected]
Outlines

1. Search space definitions


2. Problem solving
3. Search methodologies
4. Blind search
Search Space

Many AI problems can be represented by search


spaces as:

• A set of possible choices in a given problem


• One or more are the solution to the problem
• Identify one or more goals
• Identify one or more paths to those goals
• Problem
• set of states
• states connected by paths that represent
actions
The goal of search procedure

• The goal is to identify one or more paths


to goals according to :
* shortest path
* path with least cost

Search space called as State spaces 

Because it consists of a set of states connected by


paths that represent actions that start with a state and
end with a goal state.
An example problem: Searching a graph

Initial
link(g,h). State
link(g,d).
link(e,d).
A B
link(h,f).
link(e,f).
C
link(a,e).
Goal
link(a,b).
State
link(b,f).
link(b,c).
link(f,c).
D E F

State-Space
G H
Semantic Tree
• A semantic tree is a kind of semantic net that
used to represent search spaces.

• It has the following properties:


1. Each node (except root node) has exactly one
predecessor (parent), and has zero, one or more
successors.
2. A node having no predecessor is called Root node,
and having no successor is a leaf node
3. One or more leaf nodes may be Goal nodes
(of which there may be more than one represent
solutions to a problem ).
Search Trees: An Example

• A is the root
node.
• L is the goal
node.

H,I, J, K, M, N and O are leaf nodes.


There is only one complete path:

A, C, F, L
Semantic Tree…

• A path is a route through the semantic tree, which may


consist of just one node (a path of length 0).

• A path of length 1 consists of a node, a branch that leads from


that node, and the successor node to which that branch leads.

• A path that leads from the root node to a goal node is called a
complete path.

• A path that leads from the root node to a leaf node that is not
a goal node is called a partial path.
Semantic tree…

• In semantic trees, an edge that connects two nodes is


called a branch.

• If a node has n successors, that node is said to have a


branching factor of n.

• A tree is often said to have a branching factor of n if the


average branching factor of all the nodes in the tree is n.

• The root node of a tree is said to be at level 0, and the


successors of the root node are at level 1. Successors of
nodes at level n are at level n + 1.
Semantic net Semantic tree
Search Trees

• Search tree is a type of semantic tree.


• Consider the following semantic net that has
several cyclic paths, we can represent this net in
form of a Tree, that is called Search Tree

A search tree
representation
for the semantic
net
Search Space Definitions
• State
• A description of a possible state of the world
• Includes all features of the world that are pertinent
to the problem.
• Initial state
• Description of all pertinent aspects of the state in
which the agent starts the search.
• Goal test
• Conditions the agent is trying to meet.
• Goal state
• Any state which meets the goal condition.
• Action
• Function that maps (transitions) from one state to
another.
• Problem formulation
• Describe a general problem as a search problem.
• Solution
• Sequence of actions that transitions the world from the
initial state to a goal state.
• Solution cost (additive)
• Sum of the cost of operators
• Alternative: sum of distances, number of steps, etc.
• Search
• Process of looking for a solution
• Search algorithm takes problem as input and returns
solution.
• We are searching through a space of possible states.
• Execution
• Process of executing sequence of actions (solution).
Problem Formulation
A search problem is defined by the

1. Initial state (e.g., Arad)


2. Operators (e.g., Arad -> Zerind, Arad -> Sibiu, etc.)
3. Goal test (e.g., at Bucharest)
4. Solution cost (e.g., path cost)
Example Problems – Missionaries and Cannibals

States: number of missionaries,


cannibals, and boat on near river
bank

Initial state: all objects on near


river bank

Operators: move boat with x


missionaries and y cannibals to
other side of river Goal: all objects on
• no more cannibals than far river bank
missionaries on either river bank
or in boat Path cost: 1 per
• boat holds at most m occupants
river crossing
• Three missionaries and three cannibals
• Want to cross a river using one boat.
• boat can hold up to two people.
• Can never be more cannibals than
missionaries on either side of the river.

• Aim: To get all safely across the river without


any missionaries being eaten.
Representation

• The first step in solving the problem is to


choose a suitable representation.
• We will show number of cannibals,
missionaries and boats on each side of the
river.

• Start state is therefore:


• C=3,M=3,B=1 0,0,0
Operators
• Now we have to choose suitable
operators that can be applied:
1. Move one cannibal across the river.
2. Move two cannibals across the river.
3. Move one missionary across the river.
4. Move two missionaries across the river.
5. Move one missionary and one cannibal.
Search
tree
formation

Partial search tree


• By applying operator 1 (moving one cannibal to the
other side) as the first action, and then applying
the same operator again, we return to the start
state.
• This is a perfectly valid way to try to solve the
problem, but not a very efficient one.
The Search Tree
• Cycles have been removed.

• Nodes represent states, edges


represent operators.

• There are two shortest paths that


lead to the solution.
Example : The Traveling Salesman

The Traveling Salesman problem is defined as follows:


• A salesman must visit each of a set of cities and then return
home.
• The aim of the problem is to find the shortest path that lets
the salesman visit each city.

• Let us imagine that our salesman is touring the following


American cities:
A : Atlanta
B : Boston
C : Chicago
D : Dallas
E : El Paso
Partial search tree with 5 cities
Search
Methodologies
Problem as a State Space
Search
• To build a system to solve a particular problem, we
need:

• Define the problem: must include precise


specifications ~ initial solution & final solution.
• Analyze the problem: select the most important
features that can have an immense impact.
• Isolate and represent : convert these important
features into knowledge representation.
• Problem solving technique(s): choose the best
technique and apply it to particular problem.

TIN 5013: Artificial Intelligence


Typical questions that need to be
answered:
• Is the problem solver guaranteed to find a
solution?
• Will the system always terminate or caught in an
infinite loop?
• If the solution is found, Is it optimal?
• What is the complexity of searching process?
• How the system be able to reduce searching
complexity?
• How it can effectively utilize the representation
paradigm? TIN 5013: Artificial Intelligence
Important Terms

Search space – Initial state – Goal state – Problem


state – Searching strategy – Search tree

• Search space  possible conditions and solutions.


• Initial state  state where the searching process started.
• Goal state  the ultimate aim of searching process.
• Problem space  “what to solve”
• Searching strategy strategy for controlling the search.
• Search tree  tree representation of search space,
showing possible solutions from initial state.

TIN 5013: Artificial Intelligence


Example: Traveling Salesperson
Problem
Suppose a salesperson has five cities to visit and then
must return home.
Goal  find the shortest path to travel.

A
125 B
75
125
100 75
E 125 50

C
50
D 100
TIN 5013: Artificial Intelligence
Searching for Solution

 Search through state space (explicitly using searching tree).


 Node expansion :- generating new node related to previous
nodes.
 Concepts:
 State :- conditions in which the node corresponds.
 Parent node :- the superior node
 Path cost :- the cost, from initial to goal state.
 Depth:- number of steps along the path from initial state

TIN 5013: Artificial Intelligence


Node expansion

TIN 5013: Artificial Intelligence


Node expansion (initial)

TIN 5013: Artificial Intelligence


Node expansion (expanding
Arad)

TIN 5013: Artificial Intelligence


Node expansion (expanding Sibiu)

TIN 5013: Artificial Intelligence


Measuring Searching Performance

The output from problem-solving (searching) algorithm is


either FAILURE or SOLUTION.

 Completeness : is guaranteed to find a solution?


 Optimality: does it find optimal(least cost) solution?
 Time complexity: How long does it take to find the
solution? (Often represented as the number of nodes
searched)
 Space complexity: How much memory is needed to
perform the search? (Often represented as the
maximum number of nodes stored at once)

TIN 5013: Artificial Intelligence


Complexity (time/space) : branching factor (b),
depth (d), and max. depth (m)

• b – maximum branching factor of the search tree


• m – maximum depth of the state space
• d – depth of the least cost solution
Search directions

Data driven / Goal driven


search
• A state may be searched in two
directions:
From the given data of a problem
instance toward a goal ( forward
chaining)
From a goal to the data (backward
The decision to choose between data- and goal-
chaining)
driven search is based on the structure of the
problem
Data driven
• In data driven search, also called forward chaining, the
problem solver begins with the given facts of the problem
and set of legal moves for changing state
• This process continues until (we hope!!) it generates a path
that satisfies the goal condition
Goal driven
• An alternative approach (Goal Driven) is start with the
goal that we want to solve.
• See what rules can generate this goal and determine what
conditions must be true to use them.
• These conditions become the new goals.
• Working backward through successive sub-goals until we
reach to the data.
Searching Strategies

•Blind search (Uninformed) •Heuristic search  search


 traversing the search process takes place by
space until the goal nodes is traversing search space with
found (might be doing applied rules (information).
exhaustive search). •Techniques: Greedy Best
First Search, A* Algorithm
•Techniques : Breadth First,
Uniform cost search, Depth •There is no guarantee that
first, Interactive Deepening solution is found.
search.

•Guarantees solution.

A search algorithm must determine the order in which states are


examined in the graph
TIN 5013: Artificial Intelligence
Blind Search

Breadth First Search (BFS)


•Strategy : search all the nodes expanded at given depth
before any node at next level ( i.e., explores the space in a
level-by-level fashion).
•Concept : First In First Out (FIFO) queue.
•Complete ?: Yes with finite b (branch).
•Complexity:
•Space : similar to complexity – keep nodes in every memory
•Optimal ? = Yes (if cost =1)

TIN 5013: Artificial Intelligence


Blind search cont.

1 2

3 4

TIN 5013: Artificial Intelligence


Blind search cont.
Uniform-cost search
Strategy : the nodes are ordered by path cost - equivalent to
breadth-first if all steps cost all equal.

Complete? Yes, if step cost ≥ ε


(otherwise, it can get stuck in infinite loops)

Time? # of nodes with path cost ≤ cost of optimal solution.

Space? # of nodes on paths with path cost ≤ cost of optimal


solution.

Optimal? Yes, for any step cost.


Breadth-first is only optimal if step costs is increasing
with depth (e.g. constant). Can we guarantee
optimality for any step cost?
Same idea as the algorithm
Uniform-cost Search: for breadth-first search…
but…
• Expand the least-cost
unexpanded node
• • Use priority
FIFO queuequeue
is ordered by
cost

The state space The goal node G is


associated with cost selected
Blind search cont.
Depth First Search (DFS)
•Strategy ~ search all the nodes expanded in deepest path
(i.e., when a state is examined, all of its children and their
descendants are examined before any of its siblings).
•Last In First Out concept (stack).
•Complete ?: No
•Complexity:
•Space : O(bm) – b ; branching factor, m ; max. depth
•Optimality ? : No

TIN 5013: Artificial Intelligence


Blind search cont.

1 2 3

4 5 N+1

…….

TIN 5013: Artificial Intelligence


DFS results:
What is the ABEKSLTFMCGNHOPUDIQJR
traversing
sequence as a BFS results:
result of DFS and ABCDEFGHIJKLMNOPQRSTU
BFS?
BFS DFS
 Because it always examines all  If it is known that the solution
nodes■ at level n before path will be long, DFS will not
Properties
proceeding to level n+1, BFSof BFS spend time searching a large
always finds the shortest path to number of “shallow” states in
a goal the graph
 In a problem have a simple  However, DFS may “lost” deep

solution, the solution will be in a graph, missing short paths


found to a goal, or even stuck in an
 Unfortunately, if the states infinite loop.
have a high average number
of children, it may use all the
memory before it find a
solution.
use a depth bound on
DFS
Iterative deepening search

• To avoid the infinite depth problem of DFS???


we can decide to only search until depth L, i.e. we
don’t expand beyond depth L.
 Depth-Limited Search

• What of solution is deeper than L?


Increase L iteratively.
 Iterative Deepening Search
Blind Search cont.

Iterative Deepening DFS (ID-DFS)


•Strategy ~ combines DFS with best depth limits.
•Gradually increase the limit; L=0, L=1… and so on.
•Complete ?: Yes (if b is finite)
•Complexity:
•Space :
•Optimality ? : yes (if path costs are all identical)

TIN 5013: Artificial Intelligence


Iterative deepening search L=0
Iterative deepening search L=1
Iterative deepening search L=2
Iterative deepening search L=3
Example IDS
Iterative deepening search
• Number of nodes generated in a depth-limited search
to depth d with branching factor b:
NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd

• Number of nodes generated in an iterative deepening


search to depth d with branching factor b:
NIDS = (d+1)b0 + d b1 + (d-1)b2 + … + 3bd-2 +2bd-1 +
O (b d ) O (b d 1) 1bd
= BFS

• For b = 10, d = 5,
• NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111
• NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,450
• NBFS = .............................................................................................. = 1,111,100
• Consider the following Route-finding problem start S and
goal G
 Breadth-First Search:
The path in the 2nd depth level that is SBG (or ) SCG.
 Depth-First Search:
The path in 3rd level is SADG

 Uniform Cost Search:


Initialization: { [ S , 0 ] }
Iteration1: { [ S->A , 1 ] , [ S->G , 12 ] }
Iteration2: { [ S->A->C , 2 ] , [ S->A->B , 4 ] , [ S->G , 12] }
Iteration3: { [ S->A->C->D , 3 ] , [ S->A->B , 4 ] , [ S->A->C->G , 4 ] ,
[ S->G , 12 ] }
Iteration4: { [ S->A->B , 4 ] , [ S->A->C->G , 4 ] , [ S->A->C->D->G ,
6 ] , [ S->G , 12 ] }
Iteration5: { [ S->A->C->G , 4 ] , [ S->A->C->D->G , 6 ] , [ S->A->B-
>D , 7 ] , [ S->G , 12 ] }
Iteration6 gives the final output as S->A->C->G.
Any Questions ?

You might also like