05 informed search - colorado state universitycs440/fall19/slides/... · best-first search n...

42
Informed Search Russell and Norvig chap. 3

Upload: others

Post on 02-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Informed Search

Russell and Norvig chap. 3

Page 2: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Not all search directions are equally promising

Page 3: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Outline

n  Informed: use problem-specific knowledge n  Add a sense of direction to search: work toward the goal n  Heuristic functions: a way to provide information to a

search algorithm

Page 4: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

What determines a search strategy

function TREE-SEARCH(problem) return a solution or failure Initialize frontier using the initial state of problem do if the frontier is empty then return failure choose leaf node from the frontier if node is a goal state then return solution else expand the node and add resulting nodes to the frontier

A search strategy is determined by the order in which nodes in the frontier are processed

Page 5: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Best-first search

n  Informed search strategy: expand the node that appears best

n  Factors going into determination of best: q  Current cost of the solution path q  Estimated distance to the nearest goal state

n  Node is selected for expansion based on an evaluation function f(n)

n  Implementation: q  Fringe is a queue sorted by value of f q  Special cases: greedy search, A* search

Page 6: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Heuristics

Heuristic: “A rule of thumb, simplification, or educated guess that reduces or limits the search for solutions” q  The heuristic function h(n) estimates cost of

the cheapest path from node n to goal node. q  If n is a goal node h(n)=0

Page 7: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Greedy best-first search

n  Expand node on the frontier closest to goal n  Determination of closest based upon the

heuristic function h

Page 8: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Greedy search: An example

n  Consider path planning between two cities n  Use the straight line distance heuristic, hSLD

n  The greedy solution is (A, C, D) n  The least cost solution is (A, B, D)

A B

C

D

Page 9: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* Search

n  Order states by their total estimated cost n  Always select the node with the lowest value n  Total estimated cost:

n  g(n) the cost to reach n n  h(n) the estimated cost to the goal

f(n) = g(n) + h(n)

Hart, P. E.; Nilsson, N. J.; Raphael, B. (1968). "A Formal Basis for the Heuristic Determination of Minimum Cost Paths". IEEE Transactions on Systems Science and Cybernetics SSC4 4 (2): 100–107.

Page 10: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* Search

n  Order states by their total estimated cost n  Always select the node with the lowest value n  Total estimated cost:

n  g(n) the cost to reach n n  h(n) the estimated cost to the goal n  Uniform cost search is a special case where

h(n)=0.

f(n) = g(n) + h(n)

Hart, P. E.; Nilsson, N. J.; Raphael, B. (1968). "A Formal Basis for the Heuristic Determination of Minimum Cost Paths". IEEE Transactions on Systems Science and Cybernetics SSC4 4 (2): 100–107.

Page 11: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Repeated states

n  BFS/DFS: q  Add to frontier only if state not already visited.

n  A*: q  If node represents state already visited, update

cost according to lower total estimated cost.

Page 12: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Heuristic functions

Heuristics for the 8 puzzle: n  h1 = the number of misplaced tiles

q  h1(s)=8 n  h2 = the sum of the distances of the tiles from their goal positions

(manhattan distance) q  h2(s)=3+1+2+2+2+3+3+2=18

Page 13: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Comparison of heuristics

Even very simple heuristics like h1 and h2 can significantly reduce the search cost:

Algorithm Depth 10 Depth 14

Iterative Deepening 47,127 3,473,941

A* with h1 93 539

A* with h2 39 113

Page 14: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* in Romania

Goal: shortest route from Arad to Bucharest

Giurgiu

UrziceniHirsova

Eforie

NeamtOradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Drobeta

Craiova

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

Page 15: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* in Romania

n  Get to Bucharest starting at Arad q  f(Arad) = c(Arad,Arad)+h(Arad)=0+366=366

(a) The initial state

(b) After expanding Arad

(c) After expanding Sibiu

Arad

Sibiu Timisoara447=118+329

Zerind449=75+374393=140+253

Arad366=0+366

(d) After expanding Rimnicu Vilcea

(e) After expanding Fagaras

(f) After expanding Pitesti

Zerind

Arad

Sibiu

Arad

Timisoara

Rimnicu VilceaFagaras Oradea

447=118+329 449=75+374

646=280+366 413=220+193415=239+176 671=291+380

Zerind

Arad

Sibiu Timisoara447=118+329 449=75+374

Rimnicu Vilcea

Craiova Pitesti Sibiu526=366+160 553=300+253417=317+100

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Fagaras Oradea

Craiova Pitesti Sibiu

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253417=317+100

671=291+380

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Oradea

Craiova Pitesti Sibiu

Bucharest Craiova Rimnicu Vilcea418=418+0

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253

615=455+160 607=414+193

671=291+380

Rimnicu Vilcea

Fagaras Rimnicu Vilcea

Arad Fagaras Oradea646=280+366 415=239+176 671=291+380

Page 16: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* in Romania

n  Expand Arrad and determine f(n): q  f(Sibiu)=c(Arad,Sibiu)+h(Sibiu)=140+253=393 q  f(Timisoara)=c(Arad,Timisoara)+h(Timisoara)=118+329=447 q  f(Zerind)=c(Arad,Zerind)+h(Zerind)=75+374=449

n  Best choice is Sibiu

(a) The initial state

(b) After expanding Arad

(c) After expanding Sibiu

Arad

Sibiu Timisoara447=118+329

Zerind449=75+374393=140+253

Arad366=0+366

(d) After expanding Rimnicu Vilcea

(e) After expanding Fagaras

(f) After expanding Pitesti

Zerind

Arad

Sibiu

Arad

Timisoara

Rimnicu VilceaFagaras Oradea

447=118+329 449=75+374

646=280+366 413=220+193415=239+176 671=291+380

Zerind

Arad

Sibiu Timisoara447=118+329 449=75+374

Rimnicu Vilcea

Craiova Pitesti Sibiu526=366+160 553=300+253417=317+100

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Fagaras Oradea

Craiova Pitesti Sibiu

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253417=317+100

671=291+380

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Oradea

Craiova Pitesti Sibiu

Bucharest Craiova Rimnicu Vilcea418=418+0

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253

615=455+160 607=414+193

671=291+380

Rimnicu Vilcea

Fagaras Rimnicu Vilcea

Arad Fagaras Oradea646=280+366 415=239+176 671=291+380

Giurgiu

UrziceniHirsova

Eforie

NeamtOradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Drobeta

Craiova

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

Page 17: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* in Romania

n  Expand Sibiu and determine f(n) q  f(Arad)=c(Sibiu,Arad)+h(Arad)=280+366=646 q  f(Fagaras)=c(Sibiu,Fagaras)+h(Fagaras)=239+179=415 q  f(Oradea)=c(Sibiu,Oradea)+h(Oradea)=291+380=671 q  f(Rimnicu Vilcea)=c(Sibiu,Rimnicu Vilcea)+

h(Rimnicu Vilcea)=220+192=413 n  Best choice is Rimnicu Vilcea

Giurgiu

UrziceniHirsova

Eforie

NeamtOradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Drobeta

Craiova

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

(a) The initial state

(b) After expanding Arad

(c) After expanding Sibiu

Arad

Sibiu Timisoara447=118+329

Zerind449=75+374393=140+253

Arad366=0+366

(d) After expanding Rimnicu Vilcea

(e) After expanding Fagaras

(f) After expanding Pitesti

Zerind

Arad

Sibiu

Arad

Timisoara

Rimnicu VilceaFagaras Oradea

447=118+329 449=75+374

646=280+366 413=220+193415=239+176 671=291+380

Zerind

Arad

Sibiu Timisoara447=118+329 449=75+374

Rimnicu Vilcea

Craiova Pitesti Sibiu526=366+160 553=300+253417=317+100

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Fagaras Oradea

Craiova Pitesti Sibiu

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253417=317+100

671=291+380

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Oradea

Craiova Pitesti Sibiu

Bucharest Craiova Rimnicu Vilcea418=418+0

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253

615=455+160 607=414+193

671=291+380

Rimnicu Vilcea

Fagaras Rimnicu Vilcea

Arad Fagaras Oradea646=280+366 415=239+176 671=291+380

Page 18: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* in Romania

n  Expand Rimnicu Vilcea and determine f(n) q  f(Craiova)=c(Rimnicu Vilcea, Craiova)+h(Craiova)=360+160=526 q  f(Pitesti)=c(Rimnicu Vilcea, Pitesti)+h(Pitesti)=317+100=417 q  f(Sibiu)=c(Rimnicu Vilcea,Sibiu)+h(Sibiu)=300+253=553

n  Best choice is Fagaras

Giurgiu

UrziceniHirsova

Eforie

NeamtOradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Drobeta

Craiova

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

(a) The initial state

(b) After expanding Arad

(c) After expanding Sibiu

Arad

Sibiu Timisoara447=118+329

Zerind449=75+374393=140+253

Arad366=0+366

(d) After expanding Rimnicu Vilcea

(e) After expanding Fagaras

(f) After expanding Pitesti

Zerind

Arad

Sibiu

Arad

Timisoara

Rimnicu VilceaFagaras Oradea

447=118+329 449=75+374

646=280+366 413=220+193415=239+176 671=291+380

Zerind

Arad

Sibiu Timisoara447=118+329 449=75+374

Rimnicu Vilcea

Craiova Pitesti Sibiu526=366+160 553=300+253417=317+100

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Fagaras Oradea

Craiova Pitesti Sibiu

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253417=317+100

671=291+380

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Oradea

Craiova Pitesti Sibiu

Bucharest Craiova Rimnicu Vilcea418=418+0

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253

615=455+160 607=414+193

671=291+380

Rimnicu Vilcea

Fagaras Rimnicu Vilcea

Arad Fagaras Oradea646=280+366 415=239+176 671=291+380

Page 19: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* in Romania

n  Expand Fagaras and determine f(n) q  f(Sibiu)=c(Fagaras, Sibiu)+h(Sibiu)=338+253=591 q  f(Bucharest)=c(Fagaras,Bucharest)+h(Bucharest)=450+0=450

n  Best choice is Pitesti!

Giurgiu

UrziceniHirsova

Eforie

NeamtOradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Drobeta

Craiova

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

(a) The initial state

(b) After expanding Arad

(c) After expanding Sibiu

Arad

Sibiu Timisoara447=118+329

Zerind449=75+374393=140+253

Arad366=0+366

(d) After expanding Rimnicu Vilcea

(e) After expanding Fagaras

(f) After expanding Pitesti

Zerind

Arad

Sibiu

Arad

Timisoara

Rimnicu VilceaFagaras Oradea

447=118+329 449=75+374

646=280+366 413=220+193415=239+176 671=291+380

Zerind

Arad

Sibiu Timisoara447=118+329 449=75+374

Rimnicu Vilcea

Craiova Pitesti Sibiu526=366+160 553=300+253417=317+100

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Fagaras Oradea

Craiova Pitesti Sibiu

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253417=317+100

671=291+380

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Oradea

Craiova Pitesti Sibiu

Bucharest Craiova Rimnicu Vilcea418=418+0

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253

615=455+160 607=414+193

671=291+380

Rimnicu Vilcea

Fagaras Rimnicu Vilcea

Arad Fagaras Oradea646=280+366 415=239+176 671=291+380

Page 20: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* in Romania

n  Expand Pitesti and determine f(n) q  f(Bucharest)=c(Pitesti,Bucharest)+h(Bucharest)=418+0=418

n  Best choice is Bucharest n  Note values along optimal path!! n  Is the solution optimal?

Giurgiu

UrziceniHirsova

Eforie

NeamtOradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Drobeta

Craiova

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

(a) The initial state

(b) After expanding Arad

(c) After expanding Sibiu

Arad

Sibiu Timisoara447=118+329

Zerind449=75+374393=140+253

Arad366=0+366

(d) After expanding Rimnicu Vilcea

(e) After expanding Fagaras

(f) After expanding Pitesti

Zerind

Arad

Sibiu

Arad

Timisoara

Rimnicu VilceaFagaras Oradea

447=118+329 449=75+374

646=280+366 413=220+193415=239+176 671=291+380

Zerind

Arad

Sibiu Timisoara447=118+329 449=75+374

Rimnicu Vilcea

Craiova Pitesti Sibiu526=366+160 553=300+253417=317+100

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Fagaras Oradea

Craiova Pitesti Sibiu

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253417=317+100

671=291+380

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Oradea

Craiova Pitesti Sibiu

Bucharest Craiova Rimnicu Vilcea418=418+0

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253

615=455+160 607=414+193

671=291+380

Rimnicu Vilcea

Fagaras Rimnicu Vilcea

Arad Fagaras Oradea646=280+366 415=239+176 671=291+380

Page 21: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* in Romania

Whole subtrees of the search tree got pruned!

(a) The initial state

(b) After expanding Arad

(c) After expanding Sibiu

Arad

Sibiu Timisoara447=118+329

Zerind449=75+374393=140+253

Arad366=0+366

(d) After expanding Rimnicu Vilcea

(e) After expanding Fagaras

(f) After expanding Pitesti

Zerind

Arad

Sibiu

Arad

Timisoara

Rimnicu VilceaFagaras Oradea

447=118+329 449=75+374

646=280+366 413=220+193415=239+176 671=291+380

Zerind

Arad

Sibiu Timisoara447=118+329 449=75+374

Rimnicu Vilcea

Craiova Pitesti Sibiu526=366+160 553=300+253417=317+100

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Fagaras Oradea

Craiova Pitesti Sibiu

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253417=317+100

671=291+380

Zerind

Arad

Sibiu

Arad

Timisoara

Sibiu Bucharest

Oradea

Craiova Pitesti Sibiu

Bucharest Craiova Rimnicu Vilcea418=418+0

447=118+329 449=75+374

646=280+366

591=338+253 450=450+0 526=366+160 553=300+253

615=455+160 607=414+193

671=291+380

Rimnicu Vilcea

Fagaras Rimnicu Vilcea

Arad Fagaras Oradea646=280+366 415=239+176 671=291+380

Giurgiu

UrziceniHirsova

Eforie

NeamtOradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Drobeta

Craiova

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

Page 22: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Admissible heuristics n  A heuristic is admissible if it never overestimates the

cost to reach the goal (optimistic) Formally:

1. h(n) ≤ h*(n) where h*(n) is the true cost from n 2. h(n) ≥ 0 so h(G)=0 for any goal G.

Examples: n  hSLD(n) never overestimates the actual road distance n  Heuristics for 8 puzzle

Page 23: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Consistency

A heuristic is consistent if: h(n) ≤ c(n, a, n’) + h(n’)

Given a consistent heuristic: f(n’) = g(n’) + h(n’)

≥ g(n) + c(n,a,n’) + h(n’)≥ g(n) + h(n) = f(n)

A consequence of consistency: f(n) non-decreasing along a path

c(n, a, n’): cost of getting to n’ from n using action a

Page 24: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Consistency and admissibility

n  Consistency implies admissibility n  Hard to find heuristics that are admissible but

not consistent n  Focus on consistent heuristics for proving

optimality of A*

Page 25: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Consistency and admissibility

n  Consistency implies admissibility n  Proof by induction on the length of the path from

a goal node.

Notation: h*(n) – cost of getting from node n to a goal

n  Base case: Let n be any node such that the goal g is reachable from it by a single edge.

h(n) ≤ c(n, a, g) + h(g) = c(n, a, g) = h*(n)

Page 26: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Consistency and admissibility

n  Consistency implies admissibility

Induction step: consider a node n. From the admissibility of h: h(n) ≤ c(n, a, n') + h(n')

≤ c(n, a, n') + h*(n') (by induction hypothesis) ≤ h*(n)

Page 27: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Consistency and the optimality of A*

n  Lemma: Whenever A* selects a node n for expansion the optimal path to that node has been found (assuming consistent heuristic).

n  Suppose not: Then there is an unexpanded node n’ on the optimal path to n. From monotonicity: f(n) ≥ f(n’), so n’ should have already been expanded.

n  Therefore whenever a goal node is expanded, it is the lowest cost, i.e. optimal goal node

Page 28: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* expansion contours

n  Expansion represented as contours of states with equal f value

n  A* expands all nodes with f(n) < C*n  A* may expand nodes on the goal contour

Page 29: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Properties of A*

n  A* expands all nodes with f(n) < C*n  But there can still be exponentially many

such nodes!

Page 30: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

When a heuristic is “almost” admissible n  Graceful Decay of Admissibility

If a heuristic rarely overestimates cost by more than δ, then the A* algorithm will rarely find a solution whose cost is more that δ greater than the cost of the optimal solution.

n  Means: q  So long as we undershoot almost all the time, and bound

how much we overshoot, we seldom get in trouble, and the trouble is minor.

Page 31: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Evaluation of A*

n  Completeness: YES q  Unless there are infinitely many nodes with f<f(G), and regardless

of the heuristic

Page 32: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Evaluation of A*

n  Completeness: YES n  Time complexity:

q  Number of nodes with f(n) < C* can be exponential

Page 33: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Evaluation of A*

n  Completeness: YES n  Time complexity:

q  Number of nodes with f(n) < C* can be exponential

n  Space complexity: also exponential.

Page 34: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Evaluation of A*

n  Completeness: YES n  Time complexity:

q  Number of nodes with f(n) < C* can be exponential

n  Space complexity: also exponential. n  Optimality: YES

q  A* does not expand any node with f(n) > C*

n  Also optimally efficient (no other optimal algorithm is guaranteed to expand fewer nodes)

Page 35: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Memory-bounded heuristic search

n  Some solutions to the A* space problem (maintaining completeness and optimality) q  Iterative-deepening A* (IDA*)

n  Like IDS, but cutoff information is the f-cost (g+h) instead of depth

n  Expands by contour

Page 36: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Memory-bounded heuristic search

n  Some solutions to A* space problems (maintaining completeness and optimality) q  Iterative-deepening A* (IDA*) q  Recursive best-first search (RBFS) q  (Simplified) Memory-bounded A* ((S)MA*)

n  SMA*: Drop the worst-leaf node when memory is full (regenerate it later if necessary; back up the value of the forgotten node to its parent)

Page 37: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Comparing heuristics

Heuristics for the 8 puzzle: n  h1 = the number of misplaced tiles n  h2 = the sum of the distances of the tiles from their goal positions

(manhattan distance) n  For every state s, h2(s) ≥ h1(s) n  We say that h2 dominates h1 n  A dominating heuristic is better for search. WHY?

Page 38: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Inventing heuristics

n  Admissible heuristics can be derived from the exact solution cost of a relaxed version of the problem q  Relaxed 8-puzzle for h1 : a tile can move anywhere. q  Relaxed 8-puzzle for h2 : a tile can move to any adjacent square. q  Another relaxation: a tile can move to any blank square.

n  Admissibility: The optimal solution cost of a relaxed problem is no

greater than the optimal solution cost of the real problem.

Page 39: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Inventing heuristics

n  Admissible heuristics can also be derived from the solution cost of a subproblem of a given problem.

n  This cost is a lower bound on the cost of the real problem. n  Construct a database of solutions for subproblems.

Page 40: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Inventing heuristics

n  Having the best of all worlds: given admissible heuristics h1,…,hm h(n) = max(h1(n),…,hm(n))is a dominating admissible heuristic.

n  Useful in the context of the subproblems

approach.

Page 41: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

Inventing heuristics

n  Learning from experience: q  Experience = solving lots of 8-puzzles q  A learning algorithm can be used to predict costs for

states that arise during search.

Page 42: 05 informed search - Colorado State Universitycs440/fall19/slides/... · Best-first search n Informed search strategy: expand the node that appears best n Factors going into determination

A* with search.py