Heuristics for sliding-tile puzzles

Slides:



Advertisements
Similar presentations
Informed search algorithms
Advertisements

Heuristic Search Russell and Norvig: Chapter 4 Slides adapted from:
Chapter 4: Informed Heuristic Search
Finding Optimal Solution of 15 puzzle B NTUCSIE Kai-Yung Chiang.
Local Search and Optimization
Cooperating Intelligent Systems
Heuristics, and what to do if you dont know what to do Carl Hultquist.
Heuristic Search The search techniques we have seen so far...
Lights Out Issues Questions? Comment from me.
Heuristics in AI Search. waretopics/software/story/0,10801, 99340,00.html waretopics/software/story/0,10801,
Heuristic Functions By Peter Lane
Informed search algorithms
Review: Search problem formulation
Heuristic Search. Best First Search A* Heuristic Search Heuristic search exploits additional knowledge about the problem that helps direct search to.
Informed Search Algorithms
Notes Dijstra’s Algorithm Corrected syllabus.
Lecture 4: Informed/Heuristic Search
Informed search strategies
Informed Search Problems
Informed search algorithms
Artificial Intelligence Presentation
An Introduction to Artificial Intelligence
The A* Algorithm Héctor Muñoz-Avila. The Search Problem Starting from a node n find the shortest path to a goal node g ?
A* Search. 2 Tree search algorithms Basic idea: Exploration of state space by generating successors of already-explored states (a.k.a.~expanding states).
Problem Solving: Informed Search Algorithms Edmondo Trentin, DIISM.
HEURISTIC SEARCH Ivan Bratko Faculty of Computer and Information Sc. University of Ljubljana.
Heuristic Search Jim Little UBC CS 322 – Search 4 September 17, 2014 Textbook §
Greedy best-first search Use the heuristic function to rank the nodes Search strategy –Expand node with lowest h-value Greedily trying to find the least-cost.
Informed search algorithms
Informed Search Methods How can we improve searching strategy by using intelligence? Map example: Heuristic: Expand those nodes closest in “as the crow.
Solving Problem by Searching
1 Heuristic Search Chapter 4. 2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*
Recent Progress in the Design and Analysis of Admissible Heuristic Functions Richard E. Korf Computer Science Department University of California, Los.
CSCE 580 ANDREW SMITH JOHNNY FLOWERS IDA* and Memory-Bounded Search Algorithms.
Review: Search problem formulation
Informed Search Methods How can we make use of other knowledge about the problem to improve searching strategy? Map example: Heuristic: Expand those nodes.
Problem Solving and Search in AI Heuristic Search
Heuristics CSE 473 University of Washington. © Daniel S. Weld Topics Agency Problem Spaces SearchKnowledge Representation Planning PerceptionNLPMulti-agentRobotics.
State-Space Searches.
Informed (Heuristic) Search
Li Wang Haorui Wu University of South Carolina 04/02/2015 A* with Pattern Databases.
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
Criticizing solutions to Relaxed Models Yields Powerful Admissible Heuristics Sean Doherty Mingxiang Zhu.
Informed search strategies Idea: give the algorithm “hints” about the desirability of different states – Use an evaluation function to rank nodes and select.
Informed searching. Informed search Blind search algorithms do not consider any information about the states and the goals Often there is extra knowledge.
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
Heuristic Search Andrea Danyluk September 16, 2013.
CSE 573: Artificial Intelligence Autumn2012 Heuristics & Pattern Databases for Search With many slides from Dan Klein, Richard Korf, Stuart Russell, Andrew.
Informed Search Reading: Chapter 4.5 HW #1 out today, due Sept 26th.
Informed Search and Heuristics Chapter 3.5~7. Outline Best-first search Greedy best-first search A * search Heuristics.
Informed Search II CIS 391 Fall CIS Intro to AI 2 Outline PART I  Informed = use problem-specific knowledge  Best-first search and its variants.
Heuristic Functions. A Heuristic is a function that, when applied to a state, returns a number that is an estimate of the merit of the state, with respect.
A* optimality proof, cycle checking CPSC 322 – Search 5 Textbook § 3.6 and January 21, 2011 Taught by Mike Chiang.
HEURISTIC SEARCH 4 4.0Introduction 4.1An Algorithm for Heuristic Search 4.2Admissibility, Monotonicity, and Informedness 4.3Using Heuristics in Games 4.4Complexity.
Heuristic Functions.
1 A* search Outline In this topic, we will look at the A* search algorithm: –It solves the single-source shortest path problem –Restricted to physical.
Review: Tree search Initialize the frontier using the starting state
Heuristic Functions.
Abstraction Transformation & Heuristics
Artificial Intelligence Problem solving by searching CSC 361
Informed search algorithms
Informed search algorithms
Heuristics Local Search
State-Space Searches.
Heuristic Search Generate and Test Hill Climbing Best First Search
State-Space Searches.
Reading: Chapter 4.5 HW#2 out today, due Oct 5th
State-Space Searches.
Informed Search.
Presentation transcript:

Heuristics for sliding-tile puzzles Shaun Gause Yu Cao CSE Department University of South Carolina

Contents Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Heuristic Linear Conflict Heuristic Gaschnig’s Heuristic Conclusion

Sliding-Tile Puzzle Invented by Sam Loyd in the 1870’s Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Sliding-Tile Puzzle Invented by Sam Loyd in the 1870’s The oldest type of sliding block puzzle

Solving Sliding Puzzle Problem Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Solving Sliding Puzzle Problem Brute-Force Search (Exhaustive Search). Heuristic Search (A*, IDA*,etc).

Brute Force (Exhaustive Search) Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Brute Force (Exhaustive Search) Brute-Force Search Time (10 million nodes/second) Problem Nodes 8 Puzzle: 105 .01 seconds 15 Puzzle: 1013 6 days 24 Puzzle: 1025 12 billion years 48 Puzzle: 1048 why dinosaurs really went extinct

A* Hart, Nilsson, and Raphael, 1968 Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion A* Hart, Nilsson, and Raphael, 1968 Best-first search with cost function f’(s)=g(s)+h’(s) g(s) – length of the shortest path from initial state to s h’(s) – length of the shortest path from s to any goal state A* stores all the nodes it generates, exhausting available memory in minutes.

Iterative-Deepening-A* (IDA*) Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Iterative-Deepening-A* (IDA*) IDA* (Korf, 1985) is a linear-space version of A*, using the same cost function. Each iteration searches depth-first for solutions of a given length. IDA* is simpler, and often faster than A*, due to less overhead per node. First to find optimal solution to random instances of 15-Puzzle (using Manhattan distance)

Heuristics (Wikipedia) Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Heuristics (Wikipedia) A method to help solve a problem, commonly informal. It is particularly used for a method that often rapidly leads to a solution that is usually reasonably close to the best possible answer. Heuristics are "rules of thumb", educated guesses, intuitive judgments or simply common sense.

Admissible Heuristics Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Admissible Heuristics Never over estimated Guaranteed to find optimal solutions (A* or IDA*) Based on evaluation function: f’(s) = g(s) + h’(s) h’(s): estimate of length of shortest path from s to goal state h(s): actual length

Monotone Heuristic Closed Set Implies Admissible Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Monotone Heuristic Closed Set Implies Admissible Not all Admissible are Monotone Based on evaluation function: f’(s) = g(s) + h’(s) s’: successor of s f’(s): evaluation function f’(s’): evaluation function of the successor state

Relaxed Heuristic Relaxed problem Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Relaxed Heuristic Relaxed problem 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.

Systematic Relaxation Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Systematic Relaxation Precondition List A conjunction of predicates that must hold true before the action can be applied Add List A list of predicates that are to be added to the description of the world-state as a result of applying the action Delete List A list of predicates that are no longer true once the action is applied and should, therefore, be deleted from the state description Primitive Predicates ON(x, y) : tile x is on cell y CLEAR(y) : cell y is clear of tiles ADJ(y, z) : cell y is adjacent to cell z

Two simple relaxed models of Sliding Puzzle problems Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Two simple relaxed models of Sliding Puzzle problems We can generate two simple relaxed models by removing certain conditions: Move(x, y, z): precondition list : ON(x, y), CLEAR(z), ADJ(y, z) add list : ON(x, z), CLEAR(y) delete list : ON(x, y), CLEAR(z)

Misplaced distance is 1+1=2 moves Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion (1) By removing CLEAR(z) and ADJ(y, z), we can derive “Misplaced distance”. Misplaced distance is 1+1=2 moves 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Manhattan distance is 6+3=9 moves Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion (2) By removing CLEAR(z), we can derive “Manhattan distance”. Manhattan distance is 6+3=9 moves 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Three more relaxed heuristic functions Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Three more relaxed heuristic functions Pattern Database Heuristics Linear Conflict Heuristics Gaschnig’s Heuristics

Pattern Database Heuristics Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Pattern Database Heuristics The idea behind pattern database heuristics is to store these exact solution costs for every possible sub-problem instance.

Introduction. Heuristic Search Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Fringe Pattern 3 7 11 12 13 14 15 3 7 11 12 13 14 15 3 7 11 12 13 14 15

Disjoint Pattern Database Heuristics Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Disjoint Pattern Database Heuristics Two or more patterns that have no tiles in common. Add together the heuristic values from the different databases. The sum of different heuristics results still be an admissible functions which is closed to the actual optimal cost.

Examples for Disjoint Pattern Database Heuristics Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Examples for Disjoint Pattern Database Heuristics 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 20 moves needed to solve red tiles 25 moves needed to solve blue tiles Overall heuristic is sum, or 20+25=45 moves

Introduction. Heuristic Search Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion A trivial example of disjoint pattern database heuristics is Manhattan Distance in the case that I view every slide as a single pattern database 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Overall heuristic is sum of the Manhattan Distance of each tile which is 39 moves.

Linear Conflict Heuristic Function Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Linear Conflict Heuristic Function Def. Linear Conflict Heuristic --Two tiles tj and tk are in a linear conflict if tj and tk are the same line, the goal positions of tj and tk are both in that line, tj is to the right of tk, and goal position of tj is to the left of the goal position of tk.

Linear Conflict Example Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Linear Conflict Example 3 1 1 3 Manhattan distance is 2+2=4 moves

Linear Conflict Example Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Linear Conflict Example 3 1 1 3 Manhattan distance is 2+2=4 moves

Linear Conflict Example Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Linear Conflict Example 3 1 3 1 Manhattan distance is 2+2=4 moves

Linear Conflict Example Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Linear Conflict Example 3 1 3 1 Manhattan distance is 2+2=4 moves

Linear Conflict Example Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Linear Conflict Example 3 1 3 1 Manhattan distance is 2+2=4 moves

Linear Conflict Example Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Linear Conflict Example 1 3 1 3 Manhattan distance is 2+2=4 moves

Linear Conflict Example Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Linear Conflict Example 1 3 1 3 Manhattan distance is 2+2=4 moves

Consistency of Linear Conflict Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Consistency of Linear Conflict

Linear Conflict Heuristic Function Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Linear Conflict Heuristic Function The linear conflict heuristic cost will at least 2 more than Manhattan distance. Linear conflict heuristic is more accurate or more informative than just using Manhattan Distance since it is closer to the actual optimal cost.

Gaschnig’s Heuristic Function Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Gaschnig’s Heuristic Function Gaschnig introduced the 9MAXSWAP problem. The relaxed problem assume that a tile can move from square A to B if B is blank, but A and B do not need to be adjacent. It underestimates the distance function of 8-puzzle, it is a closer approximation of the 8-puzzle’s distance.

Maxsort Algorithm One algorithm to solve 9MAXSWAP is Maxsort. Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Maxsort Algorithm One algorithm to solve 9MAXSWAP is Maxsort. P: the current permutation B: the location of element i in the permutation Array. Basic Idea: swaps iteratively P[B[n]] with P[B[b[n]]] for n-puzzle.

Apply MAXSORT as A Heuristic Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Apply MAXSORT as A Heuristic To apply MAXSORT as a heuristic for the 8-puzzle, we take the number of switches as the heuristic cost at any search node.

Gaschnig Heuristic Example Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Gaschnig Heuristic Example Current Node : Goal Node: 29613478 123456789 1 2 3 4 5 6 7 8 9 2 9 6 1 3 4 7 5 8

Gaschnig Heuristic Function Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Gaschnig Heuristic Function iteration permutation b array 1 296134758 415683792 2 926134758 425683791 3 126934758 125683794 4 126439758 125483796 5 129436758 125486793 6 123496758 123486795 7 123456798 8 123456789

Gaschnig Heuristic Function Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Gaschnig Heuristic Function In the previous example, the Gaschnig Heuristic cost for the node on the right side is 7 which is just the number of switches to make the sequence 296134758 to be 123456789. (9 means blank) 2 9 6 1 3 4 7 5 8

Comparison of Heuristic Estimates Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Comparison of Heuristic Estimates Puzzle   Average σ² Misplaced Tiles 4 8 7 5.75 4.25 Relaxed Adjacency (Gaschnig’s) 6 10 5.33 Manhattan Distance (Subset of Pattern) 22 14 12 58.67 Linear Conflict 24 16.5 59.67 Actual Distance 20 26 23.5 9

Introduction. Heuristic Search Introduction Heuristic Search Relaxed Heuristic Functions Pattern Database Linear Conflict Gaschnig Conclusion Sources www.tilepuzzles.com www.wikipedia.com Sakawa, Masatoshi and Yano, Hitoshi. “Criticizing Solutions to Relaxed Models Yields Powerful Admissible Heuristics.” Information Sciences 63, 1992. 207-227 Korf, Richard E. “Recent Progress in the Design and Analysis of Admissible Heuristic Functions.” American Association for Artificial Intelligence, 2000. Gaschnig, John. “A Problem Similarity Approach to Devising Heuristics: First Results.” International Joint Conferences on Artificial Intelligence, 1979. 301-307. Pearl, Judea. “Heuristics: Intelligent Search Strategies for Computer Problem Solving.” Addison-Wesley, 1984. 118-125. Hansson, Othar and Mayer, Andrew and Yung, Mordechai. “Criticizing Solutions to Relaxed Models Yields Powerful Admissible Heuristics.” Information Sciences: an International Journal. Volume 63, Issue 3. 207-227. Valtorta, Marco. “A Result on the Computational Complexity of Heuristic Estimates for the A* Algorithm.” Information Science 34, 47-59(1984). Hansson, Othar and Mayer, Andrew and Valtorta, Marco. “A New Result on The Complexity of Heuristic Estimates for The A* Algorithm.” Artificial Intelligence 55 (1992) 129-143. Korf’s Slides for “Recent Progress in the Design and Analysis of Admissible Heuristic Functions”. http://sara2000.unl.edu/Korf-slides.ppt#295,49,Time Complexity of Admissible Heuristic Search Algorithms