Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Technological singularity wikipedia , lookup
Embodied cognitive science wikipedia , lookup
Computer Go wikipedia , lookup
Collaborative information seeking wikipedia , lookup
Philosophy of artificial intelligence wikipedia , lookup
History of artificial intelligence wikipedia , lookup
Ethics of artificial intelligence wikipedia , lookup
Intelligence explosion wikipedia , lookup
Existential risk from artificial general intelligence wikipedia , lookup
Artificial Intelligence 2.2 Heuristic (Informed) Search Prof. Dr. Jana Koehler Fall 2016 © HSLU - JK Agenda Using Knowledge during Search – evaluation of search states – admissible and monotone (consistent) Heuristics – finding good heuristics (1) Greedy Best-First Search (2) A* and IDA* (3) Recursive Best-First Search 2 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK How to Determine the next Node for Expansion? Uninformed Search – rigid procedure, no knowledge of the cost from a node to the goal – e.g. FIFO, LIFO queues Informed Search – "value" of expanding a node as knowledge that steers the search algorithm through the search space – evaluation function f(n) assigns a real number to each node 3 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK The Evaluation Function f(n) = g(n) + h(n) g(n) = the costs from the initial state to the current state (a precise value) + h(n) = the costs from the current state to the goal state (an estimated value) 4 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Heuristic Function h(n) h(n) is a heuristic – describes the estimated costs from node n to a goal state Heuristics are problem-specific and steer the search Important properties of h(n) – h(n) = 0 if n is a goal state – h is admissible – h is consistent 5 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Admissible h(n) h*(n) = the real costs of the optimal path from node n to the goal h is admissible if it guarantees for all n h is an optimistic estimate of the costs that actually occur – it underestimates the real costs 6 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Consistent (Monotone) h(n) a node n c(n,a,n') step cost of getting from n to n' with action a a n' is a successor of n h(n) h(n') goal state 7 Artificial Intelligence 2016 - Heuristic Search Die Dreiecksungleichung muss erfüllt sein. triangle inequality: each side of a triangle cannot be longer than the sum of the other two sides © HSLU - JK (1) Greedy (Best-First) Search Uses f(n) = h(n) Epands the node first that is estimated as being closest to the goal Does not consider the current path costs – "counterpart" to uniform-cost search, which uses f(n) = g(n) 8 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Greedy Search on the Romania Travel Example h: Aerial Distances to Bucharest 9 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK 10 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Example of Incompleteness Cannot use this table, why? Problem: From Iasi to Fagaras • Iasi to Neamt estimated shorter than Vaslui to Fagaras • Neamt is expanded, but it is a dead-end the algorithm gets stuck without finding a solution if it expands Neamt, it puts Iasi back into the frontier (infinite loop) 11 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Properties of Greedy Search minimal search costs (expands a single path) not optimal incomplete (graph search is complete on finite spaces) time and space complexity is O(bm) m - maximum depth 12 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK (2) A* (Hart, Nilsson, Raphael 1968) Greedy search only uses h(n) Uniform-Cost search uses g(n) – finds an optimal solution if path costs grow monotonically A* uses f(n) = g(n) + h(n) A* combines both using preferably admissible and consistent heuristics 13 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Properties of A* Complete – if a solution exists, A* will find it provided that 1) every node has a finite number of successor nodes, and 2) each action has positive and finite costs Optimal – first solution found has minimum path cost if h is admissible (on trees) or if h is consistent (on graphs) • under an admissable heuristics on graphs, A* needs to expand all nodes with f(n) <= C* (cost of optimal solution) Complexity – space and time exponential in the path length of the solution 14 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK f-based Contours in a Search Space A* fans out from the start node, adding nodes in concentric bands of increasing f-costs – with good heuristics the bands stretch towards the goal state and are more narrowly focused around the optimal path 15 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Branch and Bound under admissible Heuristics a first solution with cost C has been found f(n) > C … all nodes with f > C can be pruned from the search space A* on graphs finds a first solution s with cost C, - if f is consistent, s is the optimal solution - if f is only admissible, A* needs to expand all nodes with lower or equal costs than C, until only nodes with f(n) > C are left to be sure that s is the optimal solution 16 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK IDA* (Korf 1985) A* requires exponential memory in the worst case – combine with Depth-Limited Search Idea: use successive iterations with increasing f costs – use f bounds instead of bounding the length of the path At each iteration, perform a depth-first search, cutting off a branch when its total cost (g + h) exceeds a given threshold – threshold starts at the estimate of the cost of the initial state, and increases for each iteration of the algorithm – at each iteration, the threshold used for the next iteration is the minimum cost of all values that exceeded the current threshold 17 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Example of IDA* initial f-cost limit = 366 (f-costs of the initial state) – first expansion: T=118 +329, S=140+253, Z=75+374 next f-cost limit = 393 (S) 18 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Heuristics Informed search depends on good heuristics Heuristic = method to help solve a problem, commonly informal – "rules of thumb", educated guesses, intuitive judgments or simply common sense 22 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Designing Heuristic Functions The informedness of the heuristic is critical for the success of the search algorithm – steer the algorithm towards the most promising parts of the search space – recognize dead ends early – find a near-optimal solution under practical conditions Requires an understanding of the application domain – keep heuristic and search approach separate – try out different variants in empirical tests – an art …(… and a hot topic in AI research) 23 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Heuristic Functions Example (Misplaced Tiles) 24 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Misplaced Tiles vs. Manhattan Distance h1 = 8 (all tiles are misplaced) h2 = 3 + 1 + 2 + … = 18 initial state goal state Distance between two points measured along axes at right angles goal position current position Disadvantage: considers all tiles independently 25 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Empirical Comparison of Both Example Heuristics 26 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Linear Conflict Heuristic vs. Manhattan Distance MH = 2 + 0 = 2 LC = 2 + 2 = 4 Two tiles tj and tk are in a linear conflict if tj and tk are in the same line, the goal positions of tj and tk are both in that line, tj is to the right of tk and the goal position of tj is to the left of the goal position of tk – LC will add a cost of 2 moves for each pair of conflicting tiles to the Manhattan Distance – motivation: tiles need to surround one another 27 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Gaschnigs Heuristic 9 stands for the blank transform into 724596831 912345678 Relaxed Move: Any tile can be moved to the blank position (count the number of swaps) If 9 is not at the 1st position & the permutation is not a solution then swap 9 with the element whose target position 9 is taking else swap 9 with the rightmost element that is not in its proper place 724596831 – 729546831 – 792546831 – 712546839 – 712546938 – 712549638 – 712945638 – 712345698 – 912345678 = 8 swaps 28 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Applying Gaschnigs Heuristic During Search 724596831 794526831 724956831 724569831 724536891 4 successor nodes Compute the number of swaps for each node Expand the node with the fewest number of swaps first Problem relaxation is a powerful idea and very successfully used to derive good heuristics 29 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK General Technique: Problem Relaxation Primitive Predicates in the N-Puzzle – ON(x, y) – CLEAR(y) – ADJ(y, z) : : : tile x is on cell y cell y is clear of tiles cell y is adjacent to cell z preconditions : ON(x, y) & CLEAR(z) & ADJ(y, z) effects : ON(x, z) & CLEAR(y) & Move(x, y, z) NOT ON(x, y) & NOT CLEAR(z) Remove CLEAR(z) & ADJ(y, z) – Misplaced Tile Distance Remove CLEAR(z) – Manhattan Distance Remove ADJ(y, z) – Gaschnigs Distance 30 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Pattern Database Apply the Divide and Conquer principle – decompose the problem into subproblems (subgoals) – store solutions to the subproblems with associated costs (patterns) – reuse these solutions Divide the 15 puzzle into Fringe + 8 puzzle • map the current location of the fringe tiles into an index of the database • the data base tells us the minimal number of moves to achieve the fringe • achieve the fringe + solve the remaining 8 puzzle Famous example: end game libraries in chess 31 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Learning Heuristic Functions Relaxed problem heuristic – problem with fewer restrictions on the actions is called a relaxed problem – cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem Modern search algorithms analyze the domain and the given problem instance – learn a problem-instance specific heuristic before they start searching 32 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Summary Questions 1. Explain the underlying ideas of greedy best-first search, A* and IDA*. 2. What are the properties of A*? 3. Why can IDA* be more efficient in practice? 4. What is the principal idea behind branch and bound? 5. What are heuristics, which role do they play in informed search, and how can we develop good heuristics? 6. What is an admissible heuristics? 7. What can happen with A* if f is non-admissible? 33 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Exercise 2.2.1 A* Search of the Example Take the path costs from the Romania map for g(n) and the aerial distance estimates for h(h) a) Perform an A* search from Arad to Bucharest! b) Do you obtain the optimal route as the solution? Why? 34 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK Exercise 2.2.2 A* for the Vacuum World a) Formalize the vacuum world with a variable number of rooms, one cleaning agent, the actions left, right, up, down, suck (each with costs 1) that are always executable in any state. A room can be clean or dirty, with some random dirt distribution that is known to the agent. The goal is to have all rooms clean. b) Define a simple to compute heuristic and expand an A* search tree to depth 3 using your heuristic starting from the initial state shown below. Show the values for f(h), g(n), h(n) c) Give an argument why your heuristic is or is not admissible + monotone. Hint: the goal of this exercise is to investigate how A* explores the search and how this is influenced by the heuristic. Your heuristic does not need to be admissible and monotone. TESTAT bis zum 9.10. 24:00 35 Artificial Intelligence 2016 - Heuristic Search © HSLU - JK