8/7/2019 Problem and Search
1/50
8/7/2019 Problem and Search
2/50
2
Outline
State space search
Search strategies
Problem characteristics
Design of search programs
8/7/2019 Problem and Search
3/50
3
State Space Search
Problem solving ! Searching for a goal state
8/7/2019 Problem and Search
4/50
4
State Space Search: Playing Chess
Each position can be described by an 8-by-8 array.
Initial position is the game opening position.
Goal position is any position in which the opponentdoes not have a legal move and his or her king is
under attack.
Legal moves can be described by a set of rules: Left sides are matched againstthe current state.
Right sides describe the new resulting state.
8/7/2019 Problem and Search
5/50
5
State Space Search: Playing Chess
State space is a set of legal positions.
Starting atthe initial state.
Using the set of rules to move from one state toanother.
Attempting to end up in a goal state.
8/7/2019 Problem and Search
6/50
6
State Space Search: Wa
ter J
ug Problem
You are given two jugs, a 4-litre one and a 3-litre one.
Neither has any measuring markers on it. There is a
pump that can be used to fill the jugs with water. Howcan you get exactly 2 litres of water into 4-litre jug.
8/7/2019 Problem and Search
7/50
7
State Space Search: Wa
ter J
ug Problem
State: (x, y)
x = 0, 1, 2, 3, or 4 y = 0, 1, 2, 3
Start state: (0, 0).
Goal state: (2, n) for any n.
Attempting to end up in a goal state.
8/7/2019 Problem and Search
8/50
8
State Space Search: Wa
ter J
ug Problem
1. (x, y) p (4, y)
ifx 4
2. (x, y) p (x, 3)ify 3
3. (x, y) p (x d, y)
ifx " 0
4. (x, y) p (x, y d)
ify " 0
8/7/2019 Problem and Search
9/50
9
State Space Search: Wa
ter J
ug Problem
5. (x, y) p (0, y)
ifx " 0
6. (x, y) p (x, 0)ify " 0
7. (x, y) p (4, y (4 x))
ifx y u 4, y " 0
8. (x, y) p (x (3 y), 3)
ifx y u 3, x " 0
8/7/2019 Problem and Search
10/50
10
State Space Search: Wa
ter J
ug Problem
9. (x, y) p (x y, 0)
ifx y e 4, y " 0
10. (x, y) p (0, x y)ifx y e 3, x " 0
11. (0, 2) p (2, 0)
12. (2, y) p (0, y)
8/7/2019 Problem and Search
11/50
8/7/2019 Problem and Search
12/50
12
State Space Search: Wa
ter J
ug Problem
The role ofthe condition in the left side of a rule
restrictthe application ofthe rule
more efficient
1. (x, y) p (4, y)
ifx 4
2. (x, y) p (x, 3)
ify 3
8/7/2019 Problem and Search
13/50
13
State Space Search: Wa
ter J
ug Problem
Special-purpose rules to capture special-case
knowledge that can be used at some stage in solving a
problem
11. (0, 2) p (2, 0)
12. (2, y) p (0, y)
8/7/2019 Problem and Search
14/50
14
State Space Search: S
ummary
1. Define a state space that contains all the possible
configurations ofthe relevant objects.
2. Specify the initial states.
3. Specify the goal states.
4. Specify a set of rules: What are unstated assumptions?
How general should the rules be?
How much knowledge for solutions should be in the
rules?
8/7/2019 Problem and Search
15/50
15
Search Strategies
Requirements of a good search strategy:
1. It causes motion
Otherwise, it will never lead to a solution.
2. It is systematic
Otherwise, it may use more steps than necessary.
3. It is efficient
Find a good, but not necessarily the best, answer.
8/7/2019 Problem and Search
16/50
16
Search Strategies
1. Uninformed search (blind search)
Having no information aboutthe number of steps from the
current state to the goal.
2. Informed search (heuristic search)
More efficientthan uninformed search.
8/7/2019 Problem and Search
17/50
17
Search St
rat
egies
(0, 0)
(4, 0) (0, 3)
(1, 3)(0, 0)(4, 3) (3, 0)(0, 0)(4, 3)
8/7/2019 Problem and Search
18/50
18
Search St
rat
egies: Blind Search
Breadth-first searchExpand all the nodes of
one level first.
Depth-first searchExpand one ofthe nodes at
the deepest level.
8/7/2019 Problem and Search
19/50
19
Search St
rat
egies: Blind Search
Criterion Breadth-
First
Depth-
First
Time
Space
Optimal?
Complete?
b: branching factor d: solution depth m: maximum depth
8/7/2019 Problem and Search
20/50
20
Search Strategies: Blind Search
Criterion Breadth-
First
Depth-
First
Time bd bm
Space bd bm
Optimal? Yes No
Complete? Yes No
b: branching factor d: solution depth m: maximum depth
8/7/2019 Problem and Search
21/50
21
Search Strategies: Heuristic Search
Heuristic: involving or serving as an aid to learning,discovery, or problem-solving by experimental and
especially trial-and-error methods.
(Merriam-Websters dictionary)
Heuristic technique improves the efficiency of asearch process, possibly by sacrificing claims of
completeness oroptimality.
8/7/2019 Problem and Search
22/50
22
Search Strategies: Heuristic Search
Heuristic is for combinatorial explosion.
Optimal solutions are rarely needed.
8/7/2019 Problem and Search
23/50
23
Search Strategies: Heuristic Search
The Travelling Salesman Problem
A salesman has a list of cities, each of which he must
visit exactly once. There are direct roads between eachpair of cities on the list. Find the route the salesman
should follow forthe shortest possible round trip that
both starts and finishes at any one ofthe cities.
A
B
C
D E
1 10
5 5
515
8/7/2019 Problem and Search
24/50
24
Search Strategies: Heuristic Search
Nearest neighbour heuristic:
1. Select a starting city.
2. Selectthe one closestto the current city.
3. Repeat step 2 until all cities have been visited.
8/7/2019 Problem and Search
25/50
25
Search Strategies: Heuristic Search
Nearest neighbour heuristic:
1. Select a starting city.
2. Selectthe one closestto the current city.
3. Repeat step 2 until all cities have been visited.
O(n2) vs. O(n!)
8/7/2019 Problem and Search
26/50
26
Search Strategies: Heuristic Search
Heuristic function:
state descriptions p measures of desirability
8/7/2019 Problem and Search
27/50
27
Problem Characteristics
To choose an appropriate method for a particular
problem:
Is the problem decomposable? Can solution steps be ignored orundone?
Is the universe predictable?
Is a good solution absolute or relative?
Is the solution a state or a path? What is the role of knowledge?
Does the task require human-interaction?
8/7/2019 Problem and Search
28/50
28
Is the problem decomposable?
Can the problem be broken down to smaller
problems to be solved independently?
Decomposable problem can be solved easily.
8/7/2019 Problem and Search
29/50
29
Is the problem decomposable?
(x2 + 3x + sin2x.cos2x)dx
x2dx 3xdx sin2x.cos2xdx
(1 cos2x)cos2xdx
cos2xdx cos4xdx
8/7/2019 Problem and Search
30/50
30
Is the problem decomposable?
CLEAR(x) p ON(x, Table)
CLEAR(x) and CLEAR(y) p ON(x, y)
AC
B CB
A
Start Goal
Blocks World
8/7/2019 Problem and Search
31/50
31
Is the problem decomposable?
ON(B, C) and ON(A, B)
ON(B, C)
ON(A, B)
CLEAR(A) ON(A, B)
A
C
B C
B
A
8/7/2019 Problem and Search
32/50
32
Can solution steps be ignored orundone?
Theorem Proving
A lemma that has been proved can be ignored for next
steps.
Ignorable!
8/7/2019 Problem and Search
33/50
8/7/2019 Problem and Search
34/50
34
Can solution steps be ignored orundone?
Playing Chess
Moves cannot be retracted.
Irrecoverable!
8/7/2019 Problem and Search
35/50
35
Can solution steps be ignored orundone?
Ignorable problems can be solved using a simple
control structure that never backtracks.
Recoverable problems can be solved usingbacktracking.
Irrecoverable problems can be solved by recoverable
style methods via planning.
8/7/2019 Problem and Search
36/50
36
Is the universe predictable?
The 8-Puzzle
Every time we make a move, we know exactly what will
happen.
Certain outcome!
8/7/2019 Problem and Search
37/50
37
Is the universe predictable?
Playing Bridge
We cannot know exactly where all the cards are or what
the o
ther players will do on
their
turns.
Uncertain outcome!
8/7/2019 Problem and Search
38/50
8/7/2019 Problem and Search
39/50
39
Is a good solution absolute or relative?
1. Marcus was a man.
2. Marcus was a Pompeian.
3. Marcus was born in 40 A.D.
4. All men are mortal.
5. All Pompeians died when the volcanoerupted in 79 A.D.
6. No mortal lives longerthan 150 years.
7. It is now 2004 A.D.
8/7/2019 Problem and Search
40/50
40
Is a good solution absolute or relative?
1. Marcus was a man.
2. Marcus was a Pompeian.
3. Marcus was born in 40 A.D.
4. All men are mortal.
5. All Pompeians died when the volcano
erupted in 79 A.D.
6. No mortal lives longerthan 150 years.
7. It is now 2004 A.D.
Is Marcus alive?
8/7/2019 Problem and Search
41/50
8/7/2019 Problem and Search
42/50
42
Is a good solution absolute or relative?
The Travelling Salesman Problem
We have to try all paths to find the shortest one.
8/7/2019 Problem and Search
43/50
43
Is a good solution absolute or relative?
Any-path problems can be solved using heuristics
that suggest good paths to explore.
Forbest-path problems, much more exhaustive
search will be performed.
8/7/2019 Problem and Search
44/50
44
Is the solution a state or a path?
Finding a consistent intepretation
The bank president ate a dish of pasta salad withthe fork.
bank refers to a financial situation orto a side of a river?
dish or pasta salad was eaten?
Does pasta salad contain pasta, as dog food does notcontain dog?
Which part ofthe sentence does with the fork modify?What if with vegetables is there?
No record ofthe processing is necessary.
8/7/2019 Problem and Search
45/50
45
Is the solution a state or a path?
The Water Jug Problem
The path that leads to the goal must be reported.
8/7/2019 Problem and Search
46/50
8/7/2019 Problem and Search
47/50
47
What is the role of knowledge
Playing Chess
Knowledge is important only to constrain the search for
a solution.
Reading Newspaper
Knowledge is required even to be able to recognize a
solution.
8/7/2019 Problem and Search
48/50
48
Does the task require human-interaction?
Solitary problem, in which there is no intermediate
communication and no demand for an explanation of
the reasoning process.
Conversational problem, in which intermediate
communication is to provide either additional
assistance to the computer or additional information
to the user.
8/7/2019 Problem and Search
49/50
49
Problem Classification
There is a variety of problem-solving methods, but
there is no one single way of solving all problems.
Not all new problems should be considered as totally
new. Solutions of similar problems can be exploited.
8/7/2019 Problem and Search
50/50
50
Homework
Exercises 1-7 (Chapter 2 AI Rich & Knight)
Top Related