uniform cost search (ucs)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · optimal solution path...

30
Uniform cost search (UCS) qExpand least-cost (())unexpanded node qImplementation: Priority queue – sort the nodes in the queue based on cost. Search CSL302 ARTIFICIAL INTELLIGENCE 1

Upload: others

Post on 13-Sep-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Uniform cost search (UCS)qExpand least-cost (𝑔(𝑛))unexpanded nodeqImplementation: Priority queue – sort the nodes in the queue based on cost.

Search CSL302 ARTIFICIAL INTELLIGENCE 1

Page 2: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

UCS - AnalysisqCompleteness: Yes; if step cost ≥ 𝜖qOptimality: Yes; nodes are expanded in increasing order of 𝑔(𝑛)qTime Complexity: # of nodes with 𝑔 ≤ cost of optimal solution(𝐶∗) - 𝑂(𝑏 ,∗ -⁄ )qSpace Complexity: # of nodes with 𝑔 ≤cost of optimal solution - 𝑂(𝑏 ,∗ -⁄ )

Search CSL302 ARTIFICIAL INTELLIGENCE 2

Large subtrees with inexpensive steps may be explored before useful paths with costly steps

Page 3: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Informed SearchCHAPTER 3

Page 4: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Informed (Heuristic) SearchqHeuristic – problem-specific knowledgeoFinds solutions more efficiently

qNew termso𝑔(𝑛): cost from initial state to the state at node noℎ 𝑛 : estimated cost from state at node n to the

closest goalo𝑓 𝑛 : evaluation function; cost estimate from the

initial state to the closest goal state through the state at node n

qGenre of Best First Search (BFS)oGreedy BFSoA* search

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 4

Page 5: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Greedy Best First Search (GBFS)qExpand the most “desirable” nodeoDesirability is measured through the evaluation

function 𝑓(𝑛) and here 𝑓 𝑛 = ℎ(𝑛)

qImplementation: priority queue based on ℎ(𝑛)

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 5

Page 6: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

GBFS - AnalysisqCompleteness: No, can get stuck in loopsoCan be made complete with repeated state

checking

qOptimality: NoqTime Complexity: 𝑂 𝑏3

qSpace Complexity: 𝑂(𝑏3)oKeeps all nodes in memory.

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 6

Page 7: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

A* searchqIdea: avoid expanding paths that are already expensive.qImplementation: priority queue based on the evaluation function 𝑓(𝑛)

𝑓 𝑛 = 𝑔 𝑛 + ℎ 𝑛o𝑔 𝑛 : cost so far to reach the node 𝑛oℎ(𝑛): estimated cost to goal from 𝑛o𝑓(𝑛): estimated total cost of path through 𝑛 to

goal.qIdentical to uniform cost search(UCS) except that we use 𝑔 + ℎ instead of only 𝑔

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 7

Page 8: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

A* - Example

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 8

Page 9: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

A* search - AnalysisqCompleteness: Yes, unless there are infinitely many nodes with 𝑓 ≤ 𝑓(𝐺)qOptimality:???

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 9

Page 10: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Admissible HeuristicqA* uses an admissible heuristic ℎ(𝑛)

ℎ 𝑛 ≤ ℎ∗ 𝑛 , ∀𝑛oℎ∗(𝑛) – is the true cost to the goal node from 𝑛oℎ 𝑛 ≥ 0, ∀𝑛

Heur

istic

val

ue

Search nodes

h* h_1

h_2

h_3

h_4

h_5

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 10

Page 11: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Example Heuristic Functions (1)q8-puzzle problem

qExamplesoNumber of misplaced tilesoTotal Manhattan distance

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 11

Page 12: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Example Heuristic Functions (2)qRomania Tourist Problem

qExamplesoStraight line distance – never overestimates the

actual road distance

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 12

Section 3.5. Informed (Heuristic) Search Strategies 93

Urziceni

Neamt

Oradea

Zerind

Timisoara

Mehadia

Sibiu

Pitesti

Rimnicu Vilcea

Vaslui

Bucharest

Giurgiu

Hirsova

Eforie

Arad

Lugoj

Drobeta

Craiova

Fagaras

Iasi

0160242161

77151

366

244226

176

241

25332980

199

380234

374

100193

Figure 3.22 Values of hSLD—straight-line distances to Bucharest.

expanding a node that is not on the solution path; hence, its search cost is minimal. It isnot optimal, however: the path via Sibiu and Fagaras to Bucharest is 32 kilometers longerthan the path through Rimnicu Vilcea and Pitesti. This shows why the algorithm is called“greedy”—at each step it tries to get as close to the goal as it can.

Greedy best-first tree search is also incomplete even in a finite state space, much likedepth-first search. Consider the problem of getting from Iasi to Fagaras. The heuristic sug-gests that Neamt be expanded first because it is closest to Fagaras, but it is a dead end. Thesolution is to go first to Vaslui—a step that is actually farther from the goal according tothe heuristic—and then to continue to Urziceni, Bucharest, and Fagaras. The algorithm willnever find this solution, however, because expanding Neamt puts Iasi back into the frontier,Iasi is closer to Fagaras than Vaslui is, and so Iasi will be expanded again, leading to an infi-nite loop. (The graph search version is complete in finite spaces, but not in infinite ones.) Theworst-case time and space complexity for the tree version is O(bm), where m is the maximumdepth of the search space. With a good heuristic function, however, the complexity can bereduced substantially. The amount of the reduction depends on the particular problem and onthe quality of the heuristic.

3.5.2 A* search: Minimizing the total estimated solution cost

The most widely known form of best-first search is called A∗ search (pronounced “A-starA∗

SEARCH

search”). It evaluates nodes by combining g(n), the cost to reach the node, and h(n), the costto get from the node to the goal:

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

Since g(n) gives the path cost from the start node to node n, and h(n) is the estimated costof the cheapest path from n to the goal, we have

f(n) = estimated cost of the cheapest solution through n .

Thus, if we are trying to find the cheapest solution, a reasonable thing to try first is thenode with the lowest value of g(n) + h(n). It turns out that this strategy is more than justreasonable: provided that the heuristic function h(n) satisfies certain conditions, A∗ search isboth complete and optimal. The algorithm is identical to UNIFORM-COST-SEARCH exceptthat A∗ uses g + h instead of g.

Page 13: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

A* search - optimalityqProof by contradictionoLet 𝑁 be the goal node A* outputs and suppose there

is another goal node 𝑁′. Then 𝑔 𝑁 ≤ 𝑔(𝑁;)oAssume to the contrary 𝑔 𝑁; < 𝑔(𝑁)oWhen we picked 𝑁 for expansion, either 𝑁′ or an

ancestor of 𝑁′ - 𝑁′′ must have been on the queue. Since we picked 𝑁 for expansion

o𝑓 𝑁 ≤ 𝑓 𝑁;; implies 𝑔 𝑁 + ℎ 𝑁 ≤ 𝑔 𝑁;; + ℎ 𝑁;;

o𝑔 𝑁 ≤ 𝑔 𝑁;; + ℎ 𝑁;; For a goal node ℎ 𝑁 = 0o𝑔 𝑁; = 𝑔 𝑁;; + 𝑑𝑖𝑠𝑡 𝑁;, 𝑁;; , ℎ 𝑁;; ≤ ℎ∗ 𝑁;; =𝑑𝑖𝑠𝑡 𝑁;, 𝑁;;

oSo𝑔 𝑁; ≥ 𝑔 𝑁;; + ℎ 𝑁;; (2)oFrom (1) and (2) 𝑔 𝑁 ≤ 𝑔 𝑁; - contradiction

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 13

Page 14: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

A* search with inadmissible heuristic

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 14

96 Chapter 3. Solving Problems by Searching

(a) The initial state

(b) After expanding Arad

(c) After expanding Sibiu

Arad

Sibiu Timisoara

447=118+329

Zerind

449=75+374393=140+253

Arad

366=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 Timisoara

447=118+329 449=75+374

Rimnicu Vilcea

Craiova Pitesti Sibiu

526=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 Vilcea

418=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 Oradea

646=280+366 415=239+176 671=291+380

Figure 3.24 Stages in an A∗ search for Bucharest. Nodes are labeled with f = g +h. Theh values are the straight-line distances to Bucharest taken from Figure 3.22.

Section 3.5. Informed (Heuristic) Search Strategies 93

Urziceni

Neamt

Oradea

Zerind

Timisoara

Mehadia

Sibiu

Pitesti

Rimnicu Vilcea

Vaslui

Bucharest

Giurgiu

Hirsova

Eforie

Arad

Lugoj

Drobeta

Craiova

Fagaras

Iasi

0160242161

77151

366

244226

176

241

25332980

199

380234

374

100193

Figure 3.22 Values of hSLD—straight-line distances to Bucharest.

expanding a node that is not on the solution path; hence, its search cost is minimal. It isnot optimal, however: the path via Sibiu and Fagaras to Bucharest is 32 kilometers longerthan the path through Rimnicu Vilcea and Pitesti. This shows why the algorithm is called“greedy”—at each step it tries to get as close to the goal as it can.

Greedy best-first tree search is also incomplete even in a finite state space, much likedepth-first search. Consider the problem of getting from Iasi to Fagaras. The heuristic sug-gests that Neamt be expanded first because it is closest to Fagaras, but it is a dead end. Thesolution is to go first to Vaslui—a step that is actually farther from the goal according tothe heuristic—and then to continue to Urziceni, Bucharest, and Fagaras. The algorithm willnever find this solution, however, because expanding Neamt puts Iasi back into the frontier,Iasi is closer to Fagaras than Vaslui is, and so Iasi will be expanded again, leading to an infi-nite loop. (The graph search version is complete in finite spaces, but not in infinite ones.) Theworst-case time and space complexity for the tree version is O(bm), where m is the maximumdepth of the search space. With a good heuristic function, however, the complexity can bereduced substantially. The amount of the reduction depends on the particular problem and onthe quality of the heuristic.

3.5.2 A* search: Minimizing the total estimated solution cost

The most widely known form of best-first search is called A∗ search (pronounced “A-starA∗

SEARCH

search”). It evaluates nodes by combining g(n), the cost to reach the node, and h(n), the costto get from the node to the goal:

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

Since g(n) gives the path cost from the start node to node n, and h(n) is the estimated costof the cheapest path from n to the goal, we have

f(n) = estimated cost of the cheapest solution through n .

Thus, if we are trying to find the cheapest solution, a reasonable thing to try first is thenode with the lowest value of g(n) + h(n). It turns out that this strategy is more than justreasonable: provided that the heuristic function h(n) satisfies certain conditions, A∗ search isboth complete and optimal. The algorithm is identical to UNIFORM-COST-SEARCH exceptthat A∗ uses g + h instead of g.

68 Chapter 3. Solving Problems by Searching

Giurgiu

Urziceni

Hirsova

Eforie

Neamt

Oradea

Zerind

Arad

Timisoara

Lugoj

Mehadia

Drobeta

Craiova

Sibiu Fagaras

Pitesti

Vaslui

Iasi

Rimnicu Vilcea

Bucharest

71

75

118

111

70

75

120

151

140

99

80

97

101

211

138

146 85

90

98

142

92

87

86

Figure 3.2 A simplified road map of part of Romania.

Sometimes the goal is specified by an abstract property rather than an explicitly enumer-ated set of states. For example, in chess, the goal is to reach a state called “checkmate,”where the opponent’s king is under attack and can’t escape.

• A path cost function that assigns a numeric cost to each path. The problem-solvingPATH COST

agent chooses a cost function that reflects its own performance measure. For the agenttrying to get to Bucharest, time is of the essence, so the cost of a path might be its lengthin kilometers. In this chapter, we assume that the cost of a path can be described as thesum of the costs of the individual actions along the path.3 The step cost of taking actionSTEP COST

a in state s to reach state s′ is denoted by c(s, a, s

′). The step costs for Romania areshown in Figure 3.2 as route distances. We assume that step costs are nonnegative.4

The preceding elements define a problem and can be gathered into a single data structurethat is given as input to a problem-solving algorithm. A solution to a problem is an actionsequence that leads from the initial state to a goal state. Solution quality is measured by thepath cost function, and an optimal solution has the lowest path cost among all solutions.OPTIMAL SOLUTION

3.1.2 Formulating problems

In the preceding section we proposed a formulation of the problem of getting to Bucharest interms of the initial state, actions, transition model, goal test, and path cost. This formulationseems reasonable, but it is still a model—an abstract mathematical description—and not the

3 This assumption is algorithmically convenient but also theoretically justifiable—see page 649 in Chapter 17.4 The implications of negative costs are explored in Exercise 3.8.

Page 15: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

A* search - AnalysisqCompleteness: Yes, unless there are infinitely many nodes with 𝑓 ≤ 𝑓(𝐺)qOptimality: YesqSpace Complexity: Keeps all nodes in memoryqTime Complexity: exponential in [relative error in ℎ * length of the solution]oA* expands all nodes with 𝑓 < 𝐶∗

oA* expands some nodes with 𝑓 = 𝐶∗

oA* expands no nodes with 𝑓 > 𝐶∗

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 15

Page 16: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 1619/01/16 CSL452 - ARTIFICIAL INTELLIGENCE 12

Page 17: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Admissibility, Monotonicity, Pathmax Correction

qIs orange ℎ admissible?qIs green ℎ admissible?qDoes 𝑓(𝐶) make sense?o𝑓(𝐵)= .1+8.8 = 8.9o𝑓(𝐶)= .2+0 = 0.2

qPath cost estimate reducesoThis doesn’t make sense since we are reducing the

estimate of the actual cost of the path

qTo make 𝑓(. )monotonic along a path, we say𝑓 𝑛 = max 𝑓 𝑝𝑎𝑟𝑒𝑛𝑡 , 𝑔 𝑛 + ℎ 𝑛

o Also referred to as Pathmax correction

A

B

C

D

G

9

.1

.1

.1

25

7

20

0

28

25

7

8.8

0

0

25

9

25.2

025.1

25

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 17

Page 18: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Monotonic HeuristicqConsistent HeuristicqA heuristic is monotonic if

ℎ 𝑛 ≤ 𝑐 𝑛, 𝑎, 𝑛; + ℎ(𝑛;)qIf ℎ is monotonic, we have

𝑓 𝑛; = 𝑔 𝑛; + ℎ 𝑛; = 𝑔 𝑛 + 𝑐 𝑛, 𝑎, 𝑛; + ℎ(𝑛;)≥ 𝑔 𝑛 + ℎ 𝑛 = 𝑓 𝑛

qi.e., 𝑓(𝑛)is monotonic along any path

Triangle Inequality

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 18

Page 19: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Visualizing A* SearchqA* expands nodes of increasing 𝑓 value

Uniformcost search

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 19

Page 20: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Effect of Heuristic Accuracy on Performance (1)qTotal number of nodes generated by A* search – 𝑁qSolution depth is 𝑑qEffective branching factor - 𝑏∗ - branching factor of a uniform tree of depth 𝑑 with 𝑁 + 1 nodes

𝑁 + 1 = 1 + 𝑏∗ + 𝑏∗ O + ⋯+ 𝑏∗ Q

qWhat should be the value of 𝑏∗to perform search efficiently?

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 20

Page 21: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Effect of Heuristic Accuracy on Performance (2)q8-puzzle problem

qTwo heuristicsoNumber of misplaced tiles – ℎRoTotal Manhattan distance - ℎO

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 21

Page 22: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Effect of Heuristic Accuracy on Performance (3)q8-puzzle problem

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 22

104 Chapter 3. Solving Problems by Searching

To test the heuristic functions h1 and h2, we generated 1200 random problems withsolution lengths from 2 to 24 (100 for each even number) and solved them with iterativedeepening search and with A∗ tree search using both h1 and h2. Figure 3.29 gives the averagenumber of nodes generated by each strategy and the effective branching factor. The resultssuggest that h2 is better than h1, and is far better than using iterative deepening search. Evenfor small problems with d= 12, A∗ with h2 is 50,000 times more efficient than uninformediterative deepening search.

Search Cost (nodes generated) Effective Branching Factor

d IDS A∗(h1) A∗(h2) IDS A∗(h1) A∗(h2)

2 10 6 6 2.45 1.79 1.794 112 13 12 2.87 1.48 1.456 680 20 18 2.73 1.34 1.308 6384 39 25 2.80 1.33 1.24

10 47127 93 39 2.79 1.38 1.2212 3644035 227 73 2.78 1.42 1.2414 – 539 113 – 1.44 1.2316 – 1301 211 – 1.45 1.2518 – 3056 363 – 1.46 1.2620 – 7276 676 – 1.47 1.2722 – 18094 1219 – 1.48 1.2824 – 39135 1641 – 1.48 1.26

Figure 3.29 Comparison of the search costs and effective branching factors for theITERATIVE-DEEPENING-SEARCH and A∗ algorithms with h1, h2. Data are averaged over100 instances of the 8-puzzle for each of various solution lengths d.

One might ask whether h2 is always better than h1. The answer is “Essentially, yes.” Itis easy to see from the definitions of the two heuristics that, for any node n, h2(n) ≥ h1(n).We thus say that h2 dominates h1. Domination translates directly into efficiency: A∗ usingDOMINATION

h2 will never expand more nodes than A∗ using h1 (except possibly for some nodes withf(n)= C

∗). The argument is simple. Recall the observation on page 97 that every nodewith f(n) < C

∗ will surely be expanded. This is the same as saying that every node withh(n) < C

∗ − g(n) will surely be expanded. But because h2 is at least as big as h1 for allnodes, every node that is surely expanded by A∗ search with h2 will also surely be expandedwith h1, and h1 might cause other nodes to be expanded as well. Hence, it is generallybetter to use a heuristic function with higher values, provided it is consistent and that thecomputation time for the heuristic is not too long.

3.6.2 Generating admissible heuristics from relaxed problems

We have seen that both h1 (misplaced tiles) and h2 (Manhattan distance) are fairly goodheuristics for the 8-puzzle and that h2 is better. How might one have come up with h2? Is itpossible for a computer to invent such a heuristic mechanically?

h1 and h2 are estimates of the remaining path length for the 8-puzzle, but they are alsoperfectly accurate path lengths for simplified versions of the puzzle. If the rules of the puzzle

Page 23: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Effect of Heuristic Accuracy on Performance (4)qFor two heuristics - ℎR and ℎOqIf ℎO 𝑛 ≥ ℎR 𝑛 , ∀𝑛qThen ℎO dominates ℎRqDomination ~ efficiency of search – in terms of number of nodes expandedoℎO will never expand more nodes than A* using ℎR

(except for some nodes with 𝑓 𝑛 = 𝐶∗)

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 23

Page 24: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Generating Admissible Heuristic – Relaxed ProblemsqShortest Path Problem on the plane

I

G

I

G“circular abstraction”

ℎ𝐶

I

G“Polygonal abstraction”

ℎ𝑃

I

G

ℎ∗Actual

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 24

Page 25: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Heuristic Functions -Abstractions

h_0 h_D h_C h_P h* -------> Reduced level of abstraction

cost of searching with the heuristic cost of computing the heuristic

Total cost incurred in

search

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 25

Page 26: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Generating Admissible Heuristics – Pattern Databases

qStore the exact solution costs for every sub problem instance

qAdmissible heuristic will be cost for solving the corresponding sub problem.

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 26

Page 27: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Iterative Deepening A* (IDA*)SearchqEssentially IDDS, that uses 𝑓 as the cost threshold, instead of depth.qImplementation: add child to the queue if 𝑓 𝑐ℎ𝑖𝑙𝑑 < 𝑡ℎ𝑟𝑒𝑠ℎ𝑜𝑙𝑑.o Start with 𝑓 cutoff equal to the 𝑓 value of the root nodeo Loop until solution is found

o Generate and search all nodes whose 𝑓 values are ≤ the current thresholdo Use DFS to search the trees in each iterationo Keep track of the node which has the smallest 𝑓 value

that is > the current threshold. o If a goal node is found terminate, else set the threshold

to be next highest 𝑓 value and loop back.

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 27

Page 28: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

IDA* Search - Example

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 28

Page 29: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

IDA* Search - AnalysisqCompleteness: yesqOptimality: yesqTime Complexity: worst case: 𝑏QoWhen all nodes have distinct 𝑓 values

qSpace Complexity: linear - 𝑏𝑑

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 29

Page 30: Uniform cost search (UCS)cse.iitrpr.ac.in/ckn/courses/s2017/csl302/w3.pdf · OPTIMAL SOLUTION path cost function, and an optimal solution has the lowest path cost among all solutions

Additional ReadingsqRecursive Best First SearchqSimplified memory-bounded A*

Informed Search CSL302 ARTIFICIAL INTELLIGENCE 30