1 / 48

Reading Material

Reading Material. Sections 3.3 – 3.5 Sections 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

nikki
Télécharger la présentation

Reading Material

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Best-first search • Idea: use an evaluation functionf(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

  3. Romania with step costs in km

  4. 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

  5. Greedy best-first search example

  6. Greedy best-first search example

  7. Greedy best-first search example

  8. Greedy best-first search example

  9. 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

  10. 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

  11. Romania with step costs in km

  12. A* search example

  13. A* search example

  14. A* search example

  15. A* search example

  16. A* search example

  17. A* search example

  18. 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

  19. Optimality of A* (proof) • Suppose some suboptimal goal G2has 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

  20. Optimality of A* (proof) • Suppose some suboptimal goal G2has 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

  21. 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?

  22. 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 have f(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

  23. 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)

  24. A better heuristic is important for A*? Heuristic A* Search Which way should I go? Go that way Give better advice Get there faster?

  25. g(v) b h*(v) 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

  26. 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)

  27. k (1+)k Nearly Optimal Solutions Optimal solutions lie at depth k -optimal solutions depth < (1+)k N= number of -optimal solutions

  28. Generic Upper Bounds on Running Time of A* (Dinh et.al 2007) Upper bounds on the number of expanded nodes:

  29. 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) = ?

  30. 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

  31. Effect of Heuristic • Typical search costs (average number of nodes expanded): • d=12 IDS = 3,644,035 nodes A*(h1) = 227 nodes A*(h2) = 73 nodes • d=24 IDS = too many nodes A*(h1) = 39,135 nodes A*(h2) = 1,641 nodes

  32. Dominance • If h2(n) ≥ h1(n) for all n (both admissible) • then h2dominatesh1 • 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?

  33. Dominance • If h2(n) ≥ h1(n) for all n (both admissible) • then h2dominatesh1 • 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, ….)

  34. 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

  35. 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

  36. Pattern Database • Save the optimal solution to some subproblems • For example, the solution for all possible configurations of 1,2,3,4

  37. 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

  38. Multiple Pattern Databases • Can we do better utilizing multiple PDs?

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

  40. 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

  41. 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*

  42. 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

  43. Recursive best-first search function RECURSIVE-BEST-FIRST-SEARCH(problem) return a solution or failure return RFBS(problem,MAKE-NODE(INITIAL-STATE[problem]),∞) function RFBS( problem, node, f_limit) return a solution or failure and a new f-cost limit if GOAL-TEST[problem](STATE[node]) then return node successors  EXPAND(node, problem) ifsuccessors is empty then return failure, ∞ for eachsinsuccessorsdo f [s]  max(g(s) + h(s), f [node]) repeat best the lowest f-value node in successors iff [best] > f_limitthen return failure, f [best] alternative the second lowest f-value among successors result, f [best]  RBFS(problem, best, min(f_limit, alternative)) ifresult failure then returnresult

  44. 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. AI 1

  45. 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. AI 1

  46. 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 AI 1

  47. Recursive best-first search, ex. • Unwind recursion and store best f-value for current best leaf Fagaras result, 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.

  48. 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.

More Related