Upload
others
View
22
Download
0
Embed Size (px)
Citation preview
• Problem Solving:• Problem Formulation• Finding a solution:
• Uninformed search: • When the agent has no additional information of the domain (DFS, BFS, ID)
• Informed search
Recall• Search methods:
• They manage a list of OPEN nodes• Different strategies (BFS, DFS, etc.) constructed by expanding
nodes in that list in different orders. • For example, BFS:
A
B C
D E F
G
Iteration 1: [A](expand A): Remove A, Insert B,C
Iteration 2: [B,C](expand B): Remove B, Insert D,E
Iteration 3: [C,D,E](expand C): Remove C, Insert F
Iteration 4: [D,E,F](expand D): Remove D
Iteration 5: [E,F](expand E): Remove E, Insert G
Iteration 6: [F,G](expand F): Remove F
Iteration 7: [G]
Recall• Search methods:
• They manage a list of OPEN nodes• Different strategies (BFS, DFS, etc.) constructed by expanding
nodes in that list in different orders. • For example, BFS:
A
B C
D E F
G
BFS: we remove the first element in the list, and add its children at
the end.
DFS: we remove the first element in the list and add its children at
the beginning.
Iteration 1: [A](expand A): Remove A, Insert B,C
Iteration 2: [B,C](expand B): Remove B, Insert D,E
Iteration 3: [C,D,E](expand C): Remove C, Insert F
Iteration 4: [D,E,F](expand D): Remove D
Iteration 5: [E,F](expand E): Remove E, Insert G
Iteration 6: [F,G](expand F): Remove F
Iteration 7: [G]
Recall• Search methods:
• They manage a list of OPEN nodes• Different strategies (BFS, DFS, etc.) constructed by expanding
nodes in that list in different orders. • For example, BFS:
A
B C
D E F
G
BFS: we remove the first element in the list, and add its children at
the end.
DFS: we remove the first element in the list and add its children at
the beginning.
Iteration 1: [A](expand A): Remove A, Insert B,C
Iteration 2: [B,C](expand B): Remove B, Insert D,E
Iteration 3: [C,D,E](expand C): Remove C, Insert F
Iteration 4: [D,E,F](expand D): Remove D
Iteration 5: [E,F](expand E): Remove E, Insert G
Iteration 6: [F,G](expand F): Remove F
Iteration 7: [G]
In other words:
BFS: we expand the node with the smallest depth
DFS: we expand the node with the largest depth.
Recall• All the problem solving strategies we have seen so far
use the following knowledge:• Goal check: knowing if the problem is solved• States• Actions: an agent knows which actions can be executed in the
current state.
• Notice that is very little information
Example
There are 4 possible actions to execute. Now, if you were the robot, which one would you try first?
(3,2,6,2)
(2,2,6,2) (3,1,6,2) (3,3,6,2) (4,2,6,2)
ExampleGoalRobot
There are 4 possible actions to execute. If you were the robot, which one would you try first?
What if now you know what the coordinates mean?
ExampleGoalRobot
There are 4 possible actions to execute. If you were the robot, which one would you try first?
What if now you know what the coordinates mean?
General Idea: if we have information about the
problem we are trying to solve, we can exploit it during problem solving.
Evaluation Function• Idea: represent the information we have about the domain
as an “evaluation function” h
• Evaluation function (heuristic):• Given a state s• h(s) it estimates how close or how far it is from the goal
• Example:• In a maze solving problem: Euclidean distance to the goal
ExampleGoalRobot
h(s2) = 4 h(s3) = 3.16 h(s3) = 3.16 h(s4) = 2
h(s1) = 3
h: Euclidean distance to the goal
ExampleGoalRobot
h(s2) = 4 h(s3) = 3.16 h(s3) = 3.16 h(s4) = 2
h(s1) = 3
h: Euclidean distance to the goal
The evaluation function (heuristic) can help the agent determine which actions are
more promising.
Slides borrowed from Russell and Norvig’s website
Best-first search
Idea: use an evaluation function for each node– estimate of “desirability”
⇒ Expand most desirable unexpanded node
Implementation:fringe is a queue sorted in decreasing order of desirability
Special cases:greedy searchA∗ search
Chapter 4, Sections 1–2 4
Romania with step costs in km
Bucharest
Giurgiu
Urziceni
Hirsova
Eforie
NeamtOradea
Zerind
Arad
Timisoara
LugojMehadia
DobretaCraiova
Sibiu
Fagaras
PitestiRimnicu Vilcea
Vaslui
Iasi
Straight−line distanceto Bucharest
0160242161
77151
241
366
193
178
25332980199
244
380
226
234
374
98
Giurgiu
UrziceniHirsova
Eforie
Neamt
Oradea
Zerind
Arad
Timisoara
Lugoj
Mehadia
DobretaCraiova
Sibiu Fagaras
Pitesti
Vaslui
Iasi
Rimnicu Vilcea
Bucharest
71
75
118
111
70
75120
151
140
99
80
97
101
211
138
146 85
90
98
142
92
87
86
Chapter 4, Sections 1–2 5
Greedy search
Evaluation function h(n) (heuristic)= estimate of cost from n to the closest goal
E.g., hSLD(n) = straight-line distance from n to Bucharest
Greedy search expands the node that appears to be closest to goal
Chapter 4, Sections 1–2 6
Greedy search example
Arad366
Chapter 4, Sections 1–2 7
Greedy search example
Zerind
Arad
Sibiu Timisoara253 329 374
Chapter 4, Sections 1–2 8
Greedy search example
Rimnicu Vilcea
Zerind
Arad
Sibiu
Arad Fagaras Oradea
Timisoara329 374
366 176 380 193
Chapter 4, Sections 1–2 9
Greedy search example
Rimnicu Vilcea
Zerind
Arad
Sibiu
Arad Fagaras Oradea
Timisoara
Sibiu Bucharest
329 374
366 380 193
253 0
Chapter 4, Sections 1–2 10
Properties of greedy search
Complete??
Chapter 4, Sections 1–2 11
Properties of greedy search
Complete?? No–can get stuck in loops, e.g., with Oradea as goal,Iasi → Neamt → Iasi → Neamt →
Complete in finite space with repeated-state checking
Time??
Chapter 4, Sections 1–2 12
Properties of greedy search
Complete?? No–can get stuck in loops, e.g.,Iasi → Neamt → Iasi → Neamt →
Complete in finite space with repeated-state checking
Time?? O(bm), but a good heuristic can give dramatic improvement
Space??
Chapter 4, Sections 1–2 13
Properties of greedy search
Complete?? No–can get stuck in loops, e.g.,Iasi → Neamt → Iasi → Neamt →
Complete in finite space with repeated-state checking
Time?? O(bm), but a good heuristic can give dramatic improvement
Space?? O(bm)—keeps all nodes in memory
Optimal??
Chapter 4, Sections 1–2 14
Properties of greedy search
Complete?? No–can get stuck in loops, e.g.,Iasi → Neamt → Iasi → Neamt →
Complete in finite space with repeated-state checking
Time?? O(bm), but a good heuristic can give dramatic improvement
Space?? O(bm)—keeps all nodes in memory
Optimal?? No
Chapter 4, Sections 1–2 15
Heuristics• Idea: estimate the distance to the solution.
• Must be computationally efficient (otherwise, one could just run the complete search algorithm to determine the actual cost!).
• Finding good heuristics makes a huge difference in computation time.
Heuristics: Fox-Goat-Cabbage • Assuming that “cost” is the number
of boat trips.
• What would be a good heuristic?
Heuristics: Fox-Goat-Cabbage • Assuming that “cost” is the number
of boat trips.
• What would be a good heuristic?
• Example:• Number of “items” on the left bay.• Since, we know that at least we have to
make that number of trips
Heuristics: Fox-Goat-Cabbage • Assuming that “cost” is the number
of boat trips.
• What would be a good heuristic?
• Example:• Number of “items” on the left bay.• Since, we know that at least we have to
make that number of trips
• We can improve: • (“number of items in left bay” – 1) * 2. • Add 1 if boat on right bay and “number of
items in left bay” > 0
Heuristics: 8-Puzzle• Cost: number of moves
• What would be a good heuristic?
8 1
3 2 6
7 4 5
Heuristics: 8-Puzzle• Cost: number of moves
• What would be a good heuristic?
• Heuristic 1:• Number of blocks out of place
8 1
3 2 6
7 4 5
Heuristics: 8-Puzzle• Cost: number of moves
• What would be a good heuristic?
• Heuristic 1:• Number of blocks out of place
• Heuristic 2:• Distance of each block to its target position
8 1
3 2 6
7 4 5
Heuristic: Robot navigation with keys• A robot (blue) needs to exit a maze (light
green), and has to pick up keys to cross doors (red)
K
R D E
K
Heuristic: Robot navigation with keys• A robot needs to exit a maze, and has to
pick up keys to cross doors
• Heuristic 1:• Simply Euclidean distance to goal (ignoring keys
and doors)
• Can you improve it?
K
R D E
K