0% found this document useful (0 votes)
16 views18 pages

Search 1

Uploaded by

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

Search 1

Uploaded by

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

Artificial Intelligence Searching

Problem Solving by Searching


.

Reading: Section 3.1 – 3.4 of Textbook R&N

Intelligence is often displayed during problem-solving


processes.

How an agent can find a sequence of actions


that achieves its goal?
Artificial Intelligence Searching

State Space Representation


In many situations, "to solve a problem" can be described
as to change the current situation, step by step, from
an initial state to a final state.

If each state is represented by a node, and each possible change is represented by


a link, then a "problem" can be represented as a graph (the "state space"), with a
"solution" corresponding to a path from the initial state to a final state.
In this way, a solution consists of a sequence of operations, each of which changes
one state into another one, and the whole sequence changes the initial state into a
final state in multiple steps.
Artificial Intelligence Searching

Problem-Solving Agents
Task: To solve a particular problem by searching state space.
function simple-problem-solving-agent (percept) returns an action
inputs: percept, a percept
static: seq, an action sequence, initially empty
state, some description of current world state
goal, a goal, initially empty
problem, a problem formulation
state Å update-state (state, percept)
if seq is empty then do
goal Å formulate-goal (state)
problem Å formulate-problem (state, goal)
seq Å search (problem)
action Å first (seq)
seq Å rest (seq) Assume the environment is:
return action Static, Observable, Discrete &
Deterministic.
Artificial Intelligence Searching

Defining Search Problems


A statement of a Search problem has four components:

1. initial state: starting point from which the agent sets out
2. actions (operators, successor functions):
• describe the set of possible actions
3. goal test: determines if a given state is the goal state.
4. path cost:
• determines the expenses of the agent for executing the actions in a path
• sum of the costs of the individual actions in a path
Solution quality is measured by the path cost function, and an
optimal solution has the lowest path cost
among all solutions.
Artificial Intelligence Searching

Example: Route Finding Problem


A 4 4
B C
Problem Formulation: 3

S 5 5
• states
– Locations (e.g: A, B, …) 4 G
• initial state D E F 3
2 4
– starting point (e.g: S)
• successor function (operators) To find the route from city S to city G
– move from one location to another
• goal test
– arrive at a certain location (e.g: G)
• path cost
– Total distance, money, time, travel
comfort etc. (here distance in km)
Artificial Intelligence Searching

Searching for Solutions

1. Start from initial state, test, is it goal? If not expand the current state.
(i.e. from S get A, D).
2. Move to anyone of new states to proceed further (i.e move to A or D).
3. Continue choosing, testing, and expending until either a solution is
found or no more state to be expanded.

For this example there are 8 states & infinite number of paths to
check.
Artificial Intelligence Searching

Search Method’s Performance


The choice of which state is to expand – search methods.
Search methods are evaluated along the following dimensions:
completeness:- does it always find a solution if one exists?
time complexity:- number of nodes generated/expanded
space complexity:- maximum number of nodes in memory
optimality:- does it always find a least-cost solution?

Time and space complexity are measured in terms of


b -- maximum branching factor (number of successor of any
node) of the search tree
d -- depth of the least-cost solution.
m -- maximum length of any path in the space (may be ∞)
Artificial Intelligence Searching

Search Methods
There are two broad classes of search methods:
- uninformed (or blind) search methods;
In the case of the uninformed search methods the order in which potential
solution paths are considered is arbitrary, using no domain-specific
information to judge where the solution is likely to lie.
• Breadth-first Search
• Uniform-cost search
• Depth-first search
• Depth-limited search.
• Interative deepening depth-first search.
• Bidirectional search
- informed (heuristic) search methods.
Use domain specific heuristic to find solution.
• Discussed later.
Artificial Intelligence Searching

Breadth-first search (BFS)


All nodes are expended at a given depth in the search tree before any nodes at
the next level are expanded until the goal reached.
A 4 4
B C
3
Constraint: Do not generate as child S 5 5
node if the node is already parent to
avoid more loop. 4 G
S E F 3
D 2 4
D Find path from S to G
A

D A E
B

B F
C E E B

D F B F C E A C G
Artificial Intelligence Searching

BFS: Discussion
• Complete? Yes, if b is finite (i.e goal is in some finite depth)
• Optimal? Yes, if steps are identical not optimal in general.
• Time complexity? 1 + b + b2 + b3 + . . . + bd = O(bd), i.e.,
exponential in d
• Space complexity? O(bd) (keeps every node in memory)

Lets assume a b= 10 at depth 10, number of nodes = 1011 time required for
processing (with processor can process 10,000 nodes per sec) = 129 days
and memory requirement = 101 TB (1 node = 1KB)

Required another solution!


Artificial Intelligence Searching

Uniform-Cost Search
Modified version of BFS to make optimal.
Expand the node n with lowest path cost.
4 4
A B C
C(i,j) = cost of an arc from node i to node j 3
C(x,z) = C(x,y) + C(y,z) S
5 5
Find the minimum cost path from S to G: 4 G
D E F 3
S 2 4
3 4
A3 4 D
4 5 5 2

B7 8 D A9 6 E
4 5 5 4

C 11 12 E 11 B F 10
3
G 13
Artificial Intelligence Searching

Uniform-Cost Search: Discussion

Does not care about the number of steps, only care about total cost.
• Complete? Yes, if step cost ≥ ε (small positive number).
• Time? Maximum as of BFS
• Space? Maximum as of BFS.
• Optimal? Yes
Artificial Intelligence Searching

Depth First Search


DFS expand the deepest unexpanded node.

A 4 4
A B C
3

B S
5 5

4 G
D E F 3
C E 2 4

D F Find a path from S to G.

G
Artificial Intelligence Searching

DFS: Discussion

• Complete? Yes: in finite state, No, if fall in infinite depth.


• Time? O(bm): terrible if m is much larger than d
• but if solutions are dense, may be much faster than breadth-first
• Space? O(bm), i.e., linear space!
• Optimal? No

The problem of unbounded trees can be solve by supplying depth-


first search with a determined depth limit (nodes at depth are treated
as they have no successors) – Depth limited search
Artificial Intelligence Searching

Iterative deepening depth-first search


A 4 4
B C
Performs successive depth-first searches, 3
considering increasing depth searches, until S 5 5
a goal node is reached.
4 G
Depth 0: S D E F 3
2 4

Depth 1: S S
A A D
Depth 2: S S S S
A A A D A D
B B D B D A B D A

Depth 3: S S S S
A A A A D

B B B D B D A
C C E C E E C E E B
Artificial Intelligence Searching

Iterative deepening DFS: Discussion


Combine the benefits of DFS and BFS.
• Complete? Yes
• Time? O(bd)
• Space? O(bd)
• Optimal? Yes, if steps costs are all identical
• Can be modified to explore uniform-cost tree
Artificial Intelligence Searching

Bidirectional Search
• Search simultaneously forwards from the start
point, and backwards from the goal, and stop
when the two searches meet in the middle.
• Problems: generate predecessors; many goal
states; efficient check for node already visited
by other half of the search; and, what kind of
search.
Artificial Intelligence Searching

Bidirectional Search: Discussion


• Complete? Yes
• Time? O(bd/2)
• Space? O(bd/2)
• Optimal? Yes (if done with correct strategy -
e.g. breadth first).

You might also like