an introduction to artificial intelligence lecture 4a: informed search and exploration ramin...
TRANSCRIPT
![Page 1: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/1.jpg)
An Introduction to Artificial Intelligence
Lecture 4a: Informed Search and ExplorationRamin Halavati ([email protected])
In which we see how information about the state space can prevent algorithms from blundering about the dark.
![Page 2: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/2.jpg)
Outline• Best-first search• Greedy best-first search• A* search• Heuristics• Local search algorithms• Hill-climbing search• Simulated annealing search• Local beam search• Genetic algorithms
![Page 3: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/3.jpg)
UNINFORMED?• Uninformed:
– To search the states graph/tree using Path Path CostCost and Goal TestGoal Test.
![Page 4: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/4.jpg)
INFORMED?• Informed:
– More data about states such as distance to goal.
– Best First Search• Almost Best First Search• Heuristic
– h(n): estimated cost of the cheapest path from n to goal. h(goal) = 0.
– Not necessarily guaranteed, but seems fine.
![Page 5: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/5.jpg)
Greedy Best First Search• Compute estimated distances to goal.
• Expand the node which gains the least estimate.
![Page 6: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/6.jpg)
Greedy Best First Search Example• Heuristic: Straight Line Distance (HSLD)
![Page 7: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/7.jpg)
Greedy Best First Search Example
![Page 8: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/8.jpg)
Properties of Greedy Best First Search• Complete?
– No, can get stuck in loop.
• Time? – O(bm), but a good heuristic can give
dramatic improvement
• Space? – O(bm), keeps all nodes in memory
• Optimal? – No, it depends
–
–
–
![Page 9: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/9.jpg)
A* search• Idea: avoid expanding paths that are
already expensive
• Evaluation function f(n) = g(n) + h(n)– g(n) = 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 10: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/10.jpg)
A* search example
![Page 11: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/11.jpg)
A* vs Greedy
![Page 12: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/12.jpg)
Admissible Heuristics• h(n) is admissible:
– if for every node n,
h(n) ≤ h*(n),
h*(n): the true cost from n to goal.
– Never Overestimates.– It’s Optimistic.
– Example: hSLD(n) (never overestimates the actual road distance)
–
![Page 13: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/13.jpg)
A* is Optimal• Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal
–TREE-SEARCH: To re-compute the cost of each node, each time you reach it.
–GRAPH-SEARCH: To store the costs of all nodes, the first time you reach em.
![Page 14: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/14.jpg)
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 • 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 15: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/15.jpg)
Consistent Heuristics• h(n) 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')
• Consistency:– Monotonicity– Triangular Inequality.– Usually at no extra cost!
• Theorem: If h(n) is consistent, A* using GRAPH-SEARCH is optimal––
![Page 16: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/16.jpg)
Optimality of A*
• A* expands nodes in order of increasing f value
• Gradually adds "f-contours" of nodes
• Contour i has all nodes with f=fi, where fi < fi+1
•
•
![Page 17: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/17.jpg)
Properties of A*• Complete? Yes (unless there are infinitely
many nodes with f ≤ f(G) )
• Time? Exponential
• Space? Keeps all nodes in memory (bd)
• Optimal? Yes
• A* prunes all nodes with f(n)>f(Goal).• A* is Optimally Efficient.
•
•
•
•
![Page 18: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/18.jpg)
How to Design 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)
•
•
![Page 19: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/19.jpg)
Admissible heuristics
• h1(n) = Number of misplaced tiles• h2(n) = Total Manhattan distance
![Page 20: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/20.jpg)
Effective Branching Factor• If A* finds the answer
– by expanding N nodes, – using heuristic h(n), – At depth d,
– b* is effective branching factor if:• 1+b*+(b*)2+…+(b*)d = N+1
![Page 21: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/21.jpg)
Dominance• If h2(n) ≥ h1(n) for all n (both admissible)
• then h2 dominates h1.
• h2 is better for search.
• h2 is more realistic.
• h (n)=max(h1(n), h2(n),… ,hm(n))
• Heuristic must be efficient.
![Page 22: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/22.jpg)
How to Generate Heuristics?• Formal Methods
– Relaxed Problems– Pattern Data Bases
• Disjoint Pattern Sets
– Learning
• ABSOLVER, 1993– A new, better heuristic for 8 puzzle.– First heuristic for Rubik’s cube.
![Page 23: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/23.jpg)
“Relaxed Problem” Heuristic• A problem with fewer restrictions on the actions.
• The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem.
• 8-puzzle:– Main Rule:
• A tile can be moved from square A to B if A is horizontally or vertically adjacent to B and B is empty.
– Relaxed Rules:• A tile can move from square A to square B if A is adjacent to
B. (h2)• A tile can move from square A to square B if B is blank. • A tile can move from square A to square B. (h1)
![Page 24: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/24.jpg)
“Sub Problem” Heuristic• The cost to solve a subproblem.
• It IS admissible.
![Page 25: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/25.jpg)
“Pattern Database” Heuristics• To store the exact solution cost to
some sub-problems.
![Page 26: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/26.jpg)
“Disjoint Pattern” Databases• Disjoint Pattern Databases.
– To add the result of several Pattern-Database heuristics.
• Speed Up: 103 times for 15-Puzzle and 106 times for 24-Puzzle.
• Separablity: Rubik’s cube vs. 8-Puzzle.
![Page 27: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/27.jpg)
Learning Heuristics from Experience• Machine Learning Techniques.
• Feature Selection– Linear Combinations
![Page 28: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/28.jpg)
BACK TO MAIN SEARCH METHOD • What’s wrong with A*? It’s both Optimal
and Optimally Efficient.
– MEMORY
![Page 29: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/29.jpg)
Memory Bounded Heuristic Search• Iterative Deepening A* (IDA*)
– Similar to Iterative Deepening Depth First Search
– Bounded by f-cost.
– Memory: b*d
![Page 30: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/30.jpg)
Recursive Best First Search• Main Idea:
– To search a level with limited f-cost, based on other open nodes with continuous update.
![Page 31: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/31.jpg)
Recursive Best First Search
![Page 32: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/32.jpg)
Recursive Best First Search, Sample
![Page 33: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/33.jpg)
Recursive Best First Search, Sample• Complete? Yes, given enough space.
• Space? b * d
• Optimal? Yes, if admissible.
• Time? Hard to analyze. It depends…
•
![Page 34: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/34.jpg)
Memory, more memory…• A*: bd
• IDA*, RBFS: b*d
• What about exactly 10 MB?
![Page 35: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/35.jpg)
Memory-Bounded A*• MA*
• Simplified Memory Bounded A* (SMA*)– To store as many nodes as possible (the
A* trend).– When memory is full, remove the worst
current node and update its parent.
![Page 36: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/36.jpg)
SMA* Example
![Page 37: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/37.jpg)
SMA* Code
![Page 38: An Introduction to Artificial Intelligence Lecture 4a: Informed Search and Exploration Ramin Halavati (halavati@ce.sharif.edu) In which we see how information](https://reader035.vdocuments.us/reader035/viewer/2022070307/551b0ae755034607418b4fa2/html5/thumbnails/38.jpg)
To be continued…