48
Reading Material • Sections 3.3 – 3.5 • “Optimal Rectangle Packing: New Results” By R. Korf (optional) “Optimal Rectangle Packing: A Meta-CSP Approach” (optional) • Sections 4.1 – 4.2

Reading Material

  • Upload
    nikki

  • View
    24

  • Download
    1

Embed Size (px)

DESCRIPTION

Reading Material. Sections 3.3 – 3.5Sections 4.1 – 4.2 “Optimal Rectangle Packing: New Results” By R. Korf (optional) “Optimal Rectangle Packing: A Meta-CSP Approach” (optional). Best-first search. Idea: use an evaluation function f(n) for each node estimate of the desirability - PowerPoint PPT Presentation

Citation preview

Page 1: Reading Material

Reading Material

• Sections 3.3 – 3.5

• “Optimal Rectangle Packing: New Results”By R. Korf (optional)

“Optimal Rectangle Packing: A Meta-CSP Approach” (optional)

• Sections 4.1 – 4.2

Page 2: Reading Material

Best-first search

• Idea: use an evaluation function f(n) for each node– estimate of the desirability- Expand most desirable unexpanded node

• Implementation:Order the nodes in fringe in decreasing order of desirability

• Special cases:– greedy best-first search– A* search

Page 3: Reading Material

Romania with step costs in km

Page 4: Reading Material

Greedy best-first search

• Evaluation function f(n) = h(n) (heuristic)

• = estimate of cost from n to goal

• e.g., hSLD(n) = straight-line distance from n to Bucharest

• Greedy best-first search expands the node that appears to be closest to goal

Page 5: Reading Material

Greedy best-first search example

Page 6: Reading Material

Greedy best-first search example

Page 7: Reading Material

Greedy best-first search example

Page 8: Reading Material

Greedy best-first search example

Page 9: Reading Material

Properties of greedy best-first search

• Complete? Yes (with assumptions)

• Time? O(bm), but a good heuristic can give dramatic improvement

• Space? O(bm) -- keeps all nodes in memory

• Optimal? No

Page 10: Reading Material

A* search

• Idea: avoid expanding paths that are already expensive

• Evaluation function f(n) = g(n) + h(n)

• g(n) = actual cost so far to reach n

• h(n) = estimated cost from n to goal

• f(n) = estimated total cost of path through n to goal

Page 11: Reading Material

Romania with step costs in km

Page 12: Reading Material

A* search example

Page 13: Reading Material

A* search example

Page 14: Reading Material

A* search example

Page 15: Reading Material

A* search example

Page 16: Reading Material

A* search example

Page 17: Reading Material

A* search example

Page 18: Reading Material

Admissible heuristics

• A heuristic h(n) is admissible if for every node n,

h(n) ≤ h*(n), where h*(n) is the true optimal cost to reach the goal state from n.

• An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic

• Example: hSLD(n) (never overestimates the actual road distance)

• Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal

Page 19: Reading Material

Optimality of A* (proof)

• Suppose some suboptimal goal G2 has been generated and is in the fringe. Let n be an unexpanded node in the fringe such that n is on a shortest path to an optimal goal G.

• f(G2) = g(G2) since h(G2) = 0

• g(G2) > g(G) since G2 is suboptimal

• f(G) = g(G) since h(G) = 0

• f(G2) > f(G) from above

Page 20: Reading Material

Optimality of A* (proof)

• Suppose some suboptimal goal G2 has been generated and is in the fringe. Let n be an unexpanded node in the fringe such that n is on a shortest path to an optimal goal G.

• f(G2) > f(G) from above

• h(n) ≤ h^*(n) since h is admissible• g(n) + h(n) ≤ g(n) + h*(n) • f(n) ≤ f(G)

Hence f(G2) > f(n), and A* will never select G2 for expansion

Page 21: Reading Material

A* with Graph-Search

• Is it optimal?

• Not optimal when the search discards an optimal path to a repeated state A if the optimal path is not the first path that generates A

• Example?

Page 22: Reading Material

Consistent heuristics• A heuristic is consistent if for every node n, every successor n' of n

generated by any action a,

h(n) ≤ c(n,a,n') + h(n')

• If h is consistent, we havef(n') = g(n') + h(n') = g(n) + c(n,a,n') + h(n') ≥ g(n) + h(n) = f(n)• i.e., f(n) is non-decreasing along any path.• A heuristic is admissible if it is consistent• Theorem: If h(n) is consistent, A* using GRAPH-SEARCH is optimal

Page 23: Reading Material

Time Complexity of A*

• Still exponential unless h(n) is very good– Sub-exponential possible when

|h(n) – h*(n)| < O(log h*(n))

• Helmert & Roger (2008) result:– Still exponential even if

|h(n) – h*(n)| < c– Optional reading: “How Good is Almost Perfect?”

Malte Helmert, Gabriele Röger, AAAI 2008 (best paper award)

Page 24: Reading Material

A* SearchHeuristicWhich way should I go?

Go that way

Give better advice Get there faster?

A better heuristic is important for A*?

Page 25: Reading Material

General Search Model

• Search space – infinite b-ary tree

– multiple solution nodes

• For each node v:– g(v) = depth of v– h*(v) = shortest distance

from v to a solution

b g(v)

h*(v)

Page 26: Reading Material

Heuristic Functions

• Heuristic h(v) is an estimate of h*(v).• h is admissible if

h(v) ≤ h*(v)• h is -approximate if

(1-)h*(v) ≤ h(v) ≤ (1+)h*(v)

Page 27: Reading Material

Nearly Optimal Solutions

k

(1+)k

N = number of -optimal solutions

Optimal solutions lie at depth k

-optimal solutionsdepth < (1+)k

Page 28: Reading Material

Generic Upper Bounds on Running Time of A* (Dinh et.al 2007)

Upper bounds on the number of expanded nodes:

Heuristic -approximate

-approximate and admissible

Trivial bounds 2b(1+)k 2bk

Better bounds 2b2k +kN2 2bk +kN

Page 29: Reading Material

Admissible heuristics

E.g., for the 8-puzzle:• h1(n) = number of misplaced tiles• h2(n) = total Manhattan distance(i.e., no. of squares from desired location of each tile)

• h1(S) = ? • h2(S) = ?

Page 30: Reading Material

Admissible heuristics

E.g., for the 8-puzzle:• h1(n) = number of misplaced tiles• h2(n) = total Manhattan distance(i.e., no. of squares from desired location of each tile)

• h1(S) = ? 8• h2(S) = ? 3+1+2+2+2+3+3+2 = 18

Page 31: Reading Material

Effect of Heuristic

• Typical search costs (average number of nodes expanded):

• d=12 IDS = 3,644,035 nodesA*(h1) = 227 nodes A*(h2) = 73 nodes

• d=24 IDS = too many nodesA*(h1) = 39,135 nodes A*(h2) = 1,641 nodes

Page 32: Reading Material

Dominance

• If h2(n) ≥ h1(n) for all n (both admissible)• then h2 dominates h1

• Is h2 always better than h1 in terms of – # of node expansions?– computing time?

• What if there is no clear winner out of many heuristics?

Page 33: Reading Material

Dominance

• If h2(n) ≥ h1(n) for all n (both admissible)• then h2 dominates h1

• Is h2 always better than h1 in terms of – # of node expansions? yes– computing time? no

• What if there is no clear winner out of many heuristics?– Maximum(h1,h2, ….)

Page 34: Reading Material

Relaxed problems

• A problem with fewer restrictions on the actions is called a relaxed problem

• The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem– Relaxed problems for 8-puzzle

• A heuristic derived from a relaxed problem is consistent

Page 35: Reading Material

Subproblem• Usually reduce the number of involved entities

instead of relaxing the actions– E.g. get only 1,2,3,4 to position

– get half of the people to the other side

• Also admissible and consistent

Page 36: Reading Material

Pattern Database• Save the optimal solution to some

subproblems

• For example, the solution for all possible configurations of 1,2,3,4

Page 37: Reading Material

Constructing Pattern Database

• Search backward from the goal state

• The cost for building the PD is amortized by the time reduction for solving many problem instances

• Take the maximum of multiple PDs– E.g. 1-2-3-4, 5-6-7-8, 2-4-6-8– Reduce the cost for 15-puzzle by 1000 times

Page 38: Reading Material

Multiple Pattern Databases

• Can we do better utilizing multiple PDs?

Page 39: Reading Material

Multiple Pattern Databases

• Can we do better utilizing multiple PDs?

• Can we use h(1-2-3-4) + h(5-6-7-8)?

Page 40: Reading Material

Multiple Pattern Databases• Can we do better utilizing multiple PDs?• Can we use h(1-2-3-4) + h(5-6-7-8)?

– No. Because of action sharing.– So what can we do?

• A solution: disjoint PD– h’(1-2-3-4): Count the moves involving1,2,3,4 only – h’(5-6-7-8): Count the moves involving 5,6,7,8 only – Use h’(1-2-3-4) + h’(5-6-7-8)– millionX speedup for 24-puzzle

• Not always possible to decompose the problem, e.g. Rubik’s cube

Page 41: Reading Material

Space complexity of A*

• Space complexity:(all nodes are stored)

• Optimality: YES– Cannot expand f+1 until f is finished.– A* expands all nodes with f(n)< C*– A* expands some nodes with f(n)=C*– A* expands no nodes with f(n)>C*

Page 42: Reading Material

Memory-efficient variants of A*

• Some solutions to A* space problems (maintain completeness and optimality)– Iterative-deepening A* (IDA*)

• Here cutoff information is the f-cost (g+h) instead of depth

– Recursive best-first search(RBFS)• Recursive algorithm that attempts to mimic standard best-first

search with linear space.

– (simple) Memory-bounded A* ((S)MA*)• Drop the worst-leaf node when memory is full

Page 43: Reading Material

Recursive best-first search

function RECURSIVE-BEST-FIRST-SEARCH(problem) return a solution or failurereturn RFBS(problem,MAKE-NODE(INITIAL-STATE[problem]),∞)

function RFBS( problem, node, f_limit) return a solution or failure and a new f-cost limitif GOAL-TEST[problem](STATE[node]) then return nodesuccessors EXPAND(node, problem)if successors is empty then return failure, ∞for each s in successors do

f [s] max(g(s) + h(s), f [node])repeat

best the lowest f-value node in successorsif f [best] > f_limit then return failure, f [best]alternative the second lowest f-value among successorsresult, f [best] RBFS(problem, best, min(f_limit, alternative))if result failure then return result

Page 44: Reading Material

AI 1

Recursive best-first search

• Keeps track of the f-value of the best-alternative path available.– If current f-values exceeds this alternative f-value

than backtrack to alternative path.

– Upon backtracking change f-value to best f-value of its children.

– Re-expansion of this result is thus still possible.

Page 45: Reading Material

AI 1

Recursive best-first search, ex.

• Path until Rumnicu Vilcea is already expanded• Above node; f-limit for every recursive call is shown on top.• Below node: f(n)• The path is followed until Pitesti which has a f-value worse than the f-

limit.

Page 46: Reading Material

AI 1

Recursive best-first search, ex.

• Unwind recursion and store best f-value for current best leaf Pitesti

result, f [best] RBFS(problem, best, min(f_limit, alternative))

• best is now Fagaras. Call RBFS for new best– best value is now 450

Page 47: Reading Material

Recursive best-first search, ex.

• Unwind recursion and store best f-value for current best leaf Fagarasresult, f [best] RBFS(problem, best, min(f_limit, alternative))

• best is now Rimnicu Viclea (again). Call RBFS for new best– Subtree is again expanded.– Best alternative subtree is now through Timisoara.

• Solution is found since because 447 > 418.

Page 48: Reading Material

RBFS evaluation

• RBFS is a bit more efficient than IDA*– Still excessive node generation

• Like A*, optimal if h(n) is admissible• Space complexity is O(bd).• Time complexity difficult to characterize

– Depends on accuracy of h(n) and how often best path changes.

• IDA* and RBFS suffer from too little memory.