Chapter 2 - Problem Solving by Searching - 1
Chapter 2 - Problem Solving by Searching - 1
L3 – SCI
Chapter 2
1
Problem solving by searching 1
Objectives
Uninformed search
Basic concepts
Problem formulation
Performance evaluation
4
Introduction
Task = search Why search ?
Early works of AI was mainly towards
• proving theorems
• solving puzzles
• playing games
All AI is search!
Not totally true (obviously) but more true than you might
think.
Task = Search
Search is required to solve a wide range of problems.
Start
End
Task = finding the sequence of actions that lead to the
7
desirable goal.
Introduction: Classic AI Search
Problems
Map searching (navigation)
8
Introduction: Classic AI Search
Problems
3*3*3 Rubik’s Cube
Rubik’s cube: Rubik 1974
2 1 3 1 2 3
4 7 6 4 5 6
5 8 7 8
11
Introduction: Classic AI Search
Problems
:Queens-5
1 2 3 4 5
1
5
12
Introduction: Classic AI Search
Problems
:Queens-5
1 2 3 4 5
1
5
13
Introduction: Classic AI Search
Problems
:Queens-5
1 2 3 4 5
1
5
14
Introduction: Classic AI Search
Problems
:Queens-5
1 2 3 4 5
1
5
15
Introduction: Classic AI Search
Problems
:Queens-5
1 2 3 4 5
1
5
16
Introduction: Classic AI Search
Problems
:Queens-5
1 2 3 4 5
1
2
Solution !!
No Queen is 3
under Attack
4
5
17
Introduction: Classic AI Search
Problems
Missionaries and Cannibals
Three missionaries and three cannibals are on the
left bank of a river.
18
Introduction: Classic AI Search
Problems
Initial Situation
19
Introduction: Classic AI Search
Problems
Missionaries and Cannibals
Goal
20
Introduction: Classic AI Search
Problems
The River Problem
A farmer wishes to carry a wolf, a duck and corn across a river, from
the south to the north shore. The farmer is the proud owner of a
small rowing boat called Bounty which he feels is easily up to the
job. Unfortunately the boat is only large enough to carry at most the
farmer and one other item. Worse again, if left unattended the wolf
.will eat the duck and the duck will eat the corn
Farmer, Wolf,
Duck and Corn
River River boat
boat
Farmer, Wolf,
Duck and Corn
How can the farmer safely transport the wolf, the duck and the corn to
?the opposite shore
21
Introduction
Real world Problems
Touring problems
Route Finding
Travelling salesperson
VLSI Layout
Robot navigation
Internet searching …
22
Introduction
23
Uninformed search
24
Uninformed search
Key questions to be addressed:
1. What goal do we need to achieve?
2. How to know when a goal is reached?
3. What knowledge we need?
4. What actions do we need to do?
25
Uninformed search: Basic concepts
Uninformed search: Basic concepts
27
Uninformed search: Basic concepts
28
Problem solving by searching 1
Successor function
Given a particular state x,
fsuccessor(x) = {(<action, new state>) }
where action is one of the legal actions in state x and new
state is the successor state that can be reached from x by
applying action.
30
Problem solving by searching 1
Solution definition:
Arad
Sibiu Bucharest
32
Problem solving by searching 1
Uninformed search: An example
Touring problem: Given a set of n cities, the touring problem consists in visiting cities at
least once starting and ending in the same city.
States:
Specified by the current city and the set of cities already visited.
Initial state:
Any state can be designed as the initial state.
Successor function:
Generates the next city to visit according to the current state.
Goal test:
Ending city reached and all cities have been visited.
Path cost:
Sum of all step costs.
33
Problem solving by searching 1
Uninformed search: Searching for solutions:
34
Problem solving by searching 1
Uninformed search: Informal description
35
Problem solving by searching 1
37
Problem solving by searching 1
Uninformed search: Towards a formal description
38
Problem solving by searching 1
Loop do
If Empty?(fringe) then return failure
node ← Remove-First(fringe)
End loop 39
Problem solving by searching 1
return successors 40
Problem solving by searching 1
Uninformed search: Performance evaluation
41
Problem solving by searching 1
42
Basic search strategies
Breadth First Search (BFS)
43
Basic search strategies
Strategies that order nodes without using any
domain specific information (only problem
definition is provided).
44
Basic search strategies: BFS
Main idea: Nodes at depth i are expanded before nodes at
depth (i+1).
Implementation: use of a First-In-First-Out queue (FIFO).
Nodes visited first are expanded first.
48
Basic search strategies
49
Basic search strategies: DFS
DFS evaluation
Completeness: Incomplete in case of unbounded depth
containing no solution.
Optimality: does not provide always optimal solutions.
52
Basic search strategies: IDS
Key idea: Iterative deepening search (IDS) applies DLS repeatedly with
increasing depth. It terminates when a solution is found or no solutions
exists.
IDS combines the benefits of BFS and DFS: Like DFS the memory
requirements are very modest (O(bd)). Like BFS, it is complete when the
branching factor is finite.
The total number of generated nodes is :
53
Basic search strategies: UCS
55
Basic search strategies: UCS
56
Basic search strategies
57
Repeated states problem
Problem: Possibility of wasting time by expanding states that have
already been encountered and expanded before.
closed ← empty;
fringe ← Insert (Make-Node(Initial-state[problem],NULL,NULL,d,c),fringe)
Loop do
If Empty?(fringe) then return failure
node ← Remove-First(fringe)
If Goal-Test[ problem] applied to State[node] succeeds then return
Solution(node)
If state [node] is not in closed then
add State [node] to closed
fringe ← Insert-all( Expand (node,problem),fringe)
End Loop
59
Searching with partial information
Uninformed search: Searching with partial information
60
Searching with partial information
Uninformed search: Searching with partial information
61
Searching with partial information
GO Right action on the belief state leads to:
62
Summary
Search: process of constructing sequences of actions that achieve a goal given
a problem.
63