0% found this document useful (0 votes)
121 views33 pages

Lect Topic3 Search Sem1 0910

This document discusses problem solving as search and techniques for searching a problem space. It defines search as examining a problem space to find a goal state. Problem spaces can be represented as state spaces or search trees. Common searching approaches include data-driven search, which starts from an initial state, and goal-driven search, which works backwards from the goal. Techniques for searching include generate-and-test, depth-first search, and breadth-first search. Depth-first follows each path to its greatest depth, while breadth-first examines all nodes at each level before moving deeper. The best technique depends on factors like path lengths and branching.

Uploaded by

Na2ry
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views33 pages

Lect Topic3 Search Sem1 0910

This document discusses problem solving as search and techniques for searching a problem space. It defines search as examining a problem space to find a goal state. Problem spaces can be represented as state spaces or search trees. Common searching approaches include data-driven search, which starts from an initial state, and goal-driven search, which works backwards from the goal. Techniques for searching include generate-and-test, depth-first search, and breadth-first search. Depth-first follows each path to its greatest depth, while breadth-first examines all nodes at each level before moving deeper. The best technique depends on factors like path lengths and branching.

Uploaded by

Na2ry
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 33

CSC 3301 - Principles Of Artificial Intelligence

STRUCTURE and STRATEGIES for STATE


SEARCH SPACE

Assoc. Prof. Dr. Normaziah Abdul Aziz


Semester 1 2009/2010

Note: Some parts of the lecture slides are referred to notes of Prof. Michael Pazzani, University of Irvine, California.
The Relation of Problem Solving
And Search
Problem Solving as Search (1)

 Search is a method that can be used by the computer to


examine a problem space in order to find a goal.

 Many problems in AI are represented as search spaces.

 A search space is a representation of the set of the possible


choices in a given problem. One or more of the choices leads to
the solution to the problem.

Example

Find the word a’dab from an Arabic-English


dictionary that has 500 pages.
The page that is being searched for is called a goal,
and it can be identified by seeing whether the word
we are searching for is on the page or not.
Problem Solving as Search (2)

 The aim of most search procedures is to identify one or


more goals and identify one or more paths to those goals.

 Often the shortest path or path with least cost is selected as


the best solution path.
Problem Solving as Search (3)

 A search space is a representation of the set of the possible


choices in a given problem. One or more of the choices leads
to the solution to the problem.

State spaces - A search space that consists of a set of states,


connected by paths that represent actions.

 Many search problems can be represented by a state space,


where the aim is to start with the world in one state and end
with the world in another more desirable state.

 Initial state or start state – the situation where we begin.

 Goal state – the final situation that we want it to be.

 Illegal state – the situation where we have to avoid. This is also


referred to as constraint.
Search Trees
 We can represent search space in the form of a tree. This tree
is referred to as search tree.
 node – represents a situation or a state. Several types of
nodes: a root node, leaf node, goal node, parent node, child node
 path – connects one node to another node
 branch – the path between the parent node and child node(s). A
tree can have deep or shallow branching and high number of
branching in terms of breadth.

parent nodes
root node
A

B
C

D E

leaf nodes Note: Goal node(s) can be from any of the


G
F leaf nodes that has the value/content of the
H I problem’s goal
Problem Solving – Example 2
Searching Approach
Searching Approaches – the broad perspective

 Data-driven search – search process starts from an


initial state and uses actions that are allowed to move
forward until a goal is reached. Also known as forward
chaining.

 Goal-driven search – search process begins from


the goal and work back towards a start state, by
seeing what moves could have led to the goal state.
This is also known as backward chaining.
Searching Approaches (cont.)
 Data-driven is most useful when the initial data are provided,
and it is unclear what the goal is.
Example
A system that analyses astronomical data and thus makes
deduction about the nature of stars and planets. Here, there is a lot
of data but it would not necessarily be given any direct goals. It is
expected to analyse the data and determine conclusions of its own.
In this case, data-driven search is appropriate.

Other examples: weather forecast, _________________

 Goal-driven is most useful in situations where the goal can be


clearly specified.
Example
A situation in medical diagnosis where the goal (i.e. the condition to
be diagnosed) is known, but the data (i.e. the causes of the sickness
condition) need to be discovered.

Other examples: finding right path in a maze, ______________


Techniques of Searching (1) A
B
C
D E
 Generate and Test F
G
H I
 generates each nodes in the search space and test it to find out
if it is a goal node. If it is, the search has succeed and need not
carry on. Else, the process moves on to the next node.
 the simplest brute-force search (also known as exhaustive
search).
 no additional knowledge besides knowing how to traverse he
search tree, and how to identify leaf nodes and goal nodes.
 3 properties for successful Generate & Test searching process:
 complete – must generate all possible solution to avoid missing
a suitable node
 non-redundant – should not generate the same solution twice
 well informed – should only propose suitable solutions &
should not examine possible solution that do not match the
search space.
Techniques of Searching (2)
 Depth-First Search
 the search process follows each path to its greatest depth
before moving on to the next path.
 if we start from the left side of a search tree and work
towards the right, depth-first search goes all the way down
the left-most path in the tree until the leaf node is reached. If
this is a goal state, the search stops & success is reported.
 if the leaf node is not the goal state, search backtracks up
to the next highest node that has unexplored path.
Examples 1 A
12
Locating files on a disk and web search 2 B
11 C
engines.
Other examples: ______________ 3 D 10 E13 14
9
F 8 I J
4 15
6 7
G H L
5 K
If node I is the goal node, hence node J, K
& L need not be examined.
Techniques of Searching (3)

 Breadth-First Search
 the search process starts by examining all nodes
one level (also known as ply) down from the root node.
 if the goal state is reached, success is reported.
Else, search continues by expanding paths from all
nodes in the current level down to the next level.
 search continues until a goal node is met and
success is reported. Failure is reported when all nodes
have been examined but no goal node has been found.
A
1 2
B
C
3 4
D
E 6
5
F7 I J

8 9
G L
10 11 K
H
Techniques of Searching (4) A
B
C
 Comparison between Depth-First and
D E
Breadth-First Search G
F
H I

Situation Depth first performance Breadth first performance

Some path are extremely Well


Bad
long or even infinite

All path are of similar Well Well


length

All path are of similar


Time & memory
length & all path lead to a Well wasted
goal state

High branching factor Depends on other Poor


factors

 Depth-first search is usually simpler to implement than breadth-first search.


 Depth-first search requires less memory usage because it needs to store only the
information the current path it is exploring.
 Breadth-first search needs more memory to store information of all paths that reach
the current depth.
Techniques of Searching (5)

 Depth-First Search with Iterative Deepening


 Depth-First Search Iterative Deepening (DFID) is also called
Iterative Deepening Search (IDS) is an exhaustive search
technique that combines both dept-first with breadth-first search.
 DFID technique involves repeatedly carrying out depth-first
search on the tree until a depth bound that is set.
 The depth bound forces a failure on a search space once it gets
below a certain level. This causes a breadth-like sweep of the
search space at that particular depth level.
 This technique is suitable when it is known that a solution lies
within a certain depth or when time constraints. such as those
occur in an extremely large search space.
Examples
In playing chess, we can limit the number of states that
are to be considered; then a depth-first search with a
depth bound can be applied.
Properties of Search Approaches
 Several important properties that search methods should have in
order to be most useful. How efficient the method is, are based on time
and space required.

 Complexity. The time complexity is a related to the length of time that


the method takes to to find a goal state. The space complexity is related
to the amount of memory that the method needs to use.

 Big-O notation is used to describe the complexity of a method. As


d
example, breadth-first search has a time complexity of O(b ), where
b is the branching factor of the tree and d is the depth of the goal
node in the tree.

 Depth-first is efficient in space but not efficient in terms of time.

 Complexity must be balanced against the adequacy of the


solution generated by the method. Ex. A very fast search method
may not find the best solution, and a search method that examines
all possible solution will guarantee to find the best solution though it
is very time-consuming.
Properties of Search Approaches

 Completeness. A search method is considered complete if it is


guaranteed to find a goal state if one exists.

 Breadth-first search is complete but depth-first search is not


complete because it may explore a path of infinite length and
never find a goal node that exist on another path.
 this is a desirable property because the objective of running
a search is to find the solution (goal state)).

 Optimality. A search method is optimal if it is guaranteed to find


the best solution that exists. It will find the path to a goal state that
involves taking the least number of steps.

 The method may not be efficient – it may take longer time for
an optimal search to identify the optimal solution – but once it
has found, it is guaranteed to be the best one.
 Breadth-first search is an optimal method.
Properties of Search Approaches

 Irrevocablility. A search method that do not use backtracking &


therefore examine just a path not more than once.

1 A
12
2 B
11 C
3 13 14
D 10 E
9
F 8 I J
4 15
7
6
G H
L
K
5
Some Calculations …
Calculating the number of nodes that need to be examined:
For a tree of depth d and with a branching factor of b, the total
number of nodes is:
1 root node A
b nodes in the first layer
2 B
b nodes in the second layer C
… D E
n th
b nodes in the n layer
G
Therefore, the total number of nodes is F
H I
2 3 d
1 + b + b + b+ … + b d+1
which is a geometric progression equal to 1 - b
1-b
Example
A tree with depth of 2 with a branching factor of 2, has
1 – 8 = 7 nodes
1–2
Using depth-first or breadth-first search, the total number
of nodes to be examined is 7.
Some Calculations …
Calculating the number of nodes that need to be examined:
Using DFID, nodes need to be examined more than once, resulting
to the following progression: number of nodes is:
2 3 d
(d + 1) + b (d) + b (d – 1) + b (d – 2)+… + b
d
Hence, DFID has a time complexity of O(b ). It has the memory
efficiency nof depth-first search because it only ever needs to store
information about the current path.
Hence, its space complexity is O(bd).

Example

A tree with depth of 4 with a branching factor of 10. Using


DFID, it has the following number of nodes to be examined
(4+1) + 10(4) + 100(3) + 1000(2) + 10,000
= 12,345 nodes
Using Heuristics for Search
Heuristic Search
 Heuristic – a commonsense rule (or set of rules) intended to
increase the success probability of solving some problems

 In the context of state space search, heuristic are rules for


choosing those branches in a state space that are most likely to lead
to an acceptable problem solution.

 The heuristic used in search is one that provides an estimate of


the distance from any given node to a goal node. This estimate
assist us to get better results than our pure/random guesswork.
Example

A problem may not have an exact solution because of inherent


ambiguities in the problem statement or available data. Medical
diagnosis is an example. A given set of symptoms may have
several possible causes; doctors use heuristics to choose the most
likely diagnosis and formulate a plan of treatment.
Informed and Uninformed Search Methods

 Search method is informed – if it uses additional information


about nodes that have not yet been explored to decide which nodes
to examine next.

 If the search method is not informed, it is referred to as


uninformed or blind search method.

 Search method that uses heuristics are informed.

 Best-first search is an example of informed search, whereas


breadth-first and depth-first are uninformed or blind.

 A heuristic, h is said to be more informed than another heuristic j,


if h(node) < = j(node) for all nodes in the search space.

 The more informed a search method is , the more efficiently it will


search.
Hill Climbing

 Hill climbing – is an informed search method. It uses information


about the search space to search in a reasonably efficient manner.

 Hill climbing strategies expand the current state of search and


evaluate its children nodes. The best child is selected for further
expansion; neither its sibling or parent are retained.

 In examining a search tree, hill climbing will move to the first


successor node that is better than the current node.
Best-First Search

 Best-first search - employs a heuristic in a similar manner to hill


climbing. The difference is that with best-first search the queue is
sorted after the new paths have been added to it, rather than adding
a set of sorted paths.

 Best-first search follows the best path available from the current
(partially developed) tree, rather than always follow a depth-first
approach.
Identifying Optimal Paths

 Optimal path – path that involves the lowest cost or travels the
shortest distance from the start to goal node.

 Sophisticated techniques to identify optimal paths:


 A*
 Uniform cost search (Branch & Bound)
 Greedy search
Problem Solving – Example

The Missionaries and Cannibals problem

3 missionaries and 3 cannibals are on the one side of a river,


with a canoe. They all want to get to the other side of the river.
The canoe can only hold 1 or 2 people at a time. At no time
should there be more cannibals than missionaries on either
side of the river, as this would probably result in the
missionaries being eaten.

What is the start state? What is the goal state?


What is the state space? What is the state that we have
to avoid or the illegal state?

Start state: 0, 0, 0 Goal state: 3, 3, 1


State space: All possible states in between.
Illegal state or constraint: 2, 1, 1 or 2, 1, 0
Exercise
The Missionaries and Cannibals problem
River River
bank A bank B
C, M, Canoe C, M, Canoe
3, 3, 1 Initial
0, 0, 0
state

Apply any of the operators given to


move from the Initial state to the
Goal state:

1) Move 1 C to the other side of the river


2) Move 2 C to the other side of the river
3) Move 1 M to the other side of the river
4) Move 2 M to the other side of the river
5) Move 1 C & 1M to the other side of the
river.

0, 0, 0 3, 3, 1 Goal
state

You might also like