Heuristics and A* Search

Similar documents
AI: A Modern Approach, Chpts. 3-4 Russell and Norvig

Informed search algorithms. Chapter 4, Sections 1 2 1

Measuring the Performance of an Agent

Smart Graphics: Methoden 3 Suche, Constraints

An Introduction to The A* Algorithm

CS MidTerm Exam 4/1/2004 Name: KEY. Page Max Score Total 139

Search methods motivation 1

Guessing Game: NP-Complete?

Moving Target Search. 204 Automated Reasoning

LABEL PROPAGATION ON GRAPHS. SEMI-SUPERVISED LEARNING. ----Changsheng Liu

Integer Programming: Algorithms - 3

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

Cpt S 223. School of EECS, WSU

Analysis of Micromouse Maze Solving Algorithms

ARTIFICIAL INTELLIGENCE (CSCU9YE) LECTURE 6: MACHINE LEARNING 2: UNSUPERVISED LEARNING (CLUSTERING)

Lecture. Simulation and optimization

Introduction to LAN/WAN. Network Layer

Genetic Algorithms and Sudoku

Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Name Partners Date. Energy Diagrams I

Approximation Algorithms

Chapter 6. Decoding. Statistical Machine Translation

Chapter Load Balancing. Approximation Algorithms. Load Balancing. Load Balancing on 2 Machines. Load Balancing: Greedy Scheduling

Genetic Algorithm. Based on Darwinian Paradigm. Intrinsically a robust search and optimization mechanism. Conceptual Algorithm

Why? A central concept in Computer Science. Algorithms are ubiquitous.

MATHEMATICS Y3 Using and applying mathematics 3810 Solve mathematical puzzles and investigate. Equipment MathSphere

A Non-Linear Schema Theorem for Genetic Algorithms

Overview. Swarms in nature. Fish, birds, ants, termites, Introduction to swarm intelligence principles Particle Swarm Optimization (PSO)

Introduction Solvability Rules Computer Solution Implementation. Connect Four. March 9, Connect Four

Problem solving and search

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

Lecture 4 Online and streaming algorithms for clustering

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

SYSM 6304: Risk and Decision Analysis Lecture 5: Methods of Risk Analysis

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Decision Making under Uncertainty

Chess Algorithms Theory and Practice. Rune Djurhuus Chess Grandmaster / October 3, 2012

SUPPLY CHAIN OPTIMIZATION MODELS IN THE AREA OF OPERATION

1 Portfolio Selection

Statistical Machine Translation: IBM Models 1 and 2

6.099, Spring Semester, 2006 Assignment for Week 13 1

Ant Colony Optimization (ACO)

Stochastic Local Search Algorithms

The Taxman Game. Robert K. Moniot September 5, 2003

Chapter 11 Monte Carlo Simulation

SINGLE-STAGE MULTI-PRODUCT PRODUCTION AND INVENTORY SYSTEMS: AN ITERATIVE ALGORITHM BASED ON DYNAMIC SCHEDULING AND FIXED PITCH PRODUCTION

TEACHER S GUIDE TO RUSH HOUR

SEARCHING AND KNOWLEDGE REPRESENTATION. Angel Garrido

CALCULATIONS & STATISTICS

Load Balancing. Load Balancing 1 / 24

14.1 Rent-or-buy problem

Implementing an Approximate Probabilistic Algorithm for Error Recovery in Concurrent Processing Systems

Distributed Dynamic Load Balancing for Iterative-Stencil Applications

Chess Algorithms Theory and Practice. Rune Djurhuus Chess Grandmaster / September 23, 2014

Cross-validation for detecting and preventing overfitting

Greedy Routing on Hidden Metric Spaces as a Foundation of Scalable Routing Architectures

Session 6 Number Theory

Data Mining Practical Machine Learning Tools and Techniques

A Review And Evaluations Of Shortest Path Algorithms

Data Structures. Jaehyun Park. CS 97SI Stanford University. June 29, 2015

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Machine Learning using MapReduce

1/1 7/4 2/2 12/7 10/30 12/25

Chapter 13: Binary and Mixed-Integer Programming

6.852: Distributed Algorithms Fall, Class 2

Lecture 6 Online and streaming algorithms for clustering

The Basics of Graphical Models

Part-Based Recognition

Improving the Performance of a Computer-Controlled Player in a Maze Chase Game using Evolutionary Programming on a Finite-State Machine

A SIMULATOR FOR LOAD BALANCING ANALYSIS IN DISTRIBUTED SYSTEMS

Applied Algorithm Design Lecture 5

Big Data Analytics CSCI 4030

Network analysis: P.E.R.T,C.P.M & Resource Allocation Some important definition:

CMPSCI611: Approximating MAX-CUT Lecture 20

Seminar. Path planning using Voronoi diagrams and B-Splines. Stefano Martina

Wireless Sensor Networks Coverage Optimization based on Improved AFSA Algorithm

Section 1.5 Exponents, Square Roots, and the Order of Operations

Creating a NL Texas Hold em Bot

Decentralized Method for Traffic Monitoring

An Improved ACO Algorithm for Multicast Routing

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

6.042/18.062J Mathematics for Computer Science. Expected Value I

/ Department of Mechanical Engineering. Manufacturing Networks. Warehouse storage: cases or layers? J.J.P. van Heur. Where innovation starts

I n t e r a c t i n g G a l a x i e s - Making Ellipticals Te a c h e r N o t e s

Teaching Introductory Artificial Intelligence with Pac-Man

A Note on Maximum Independent Sets in Rectangle Intersection Graphs

A SPECIAL PROGRAM OF DISTRICT # 8 NY DAN CAVALLO DISTRICT ADMINSTRATOR

PARALLELIZED SUDOKU SOLVING ALGORITHM USING OpenMP

An Interactive Visualization Tool for the Analysis of Multi-Objective Embedded Systems Design Space Exploration

2After completing this chapter you should be able to

9. The kinetic energy of the moving object is (1) 5 J (3) 15 J (2) 10 J (4) 50 J

Gambling and Data Compression

Machine Learning. CUNY Graduate Center, Spring Professor Liang Huang.

ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite

The PageRank Citation Ranking: Bring Order to the Web

SIMS 255 Foundations of Software Design. Complexity and NP-completeness

Chapter 13: Query Processing. Basic Steps in Query Processing

Incremental Routing Algorithms For Dynamic Transportation Networks

Transcription:

1 Hal Daumé III (me@hal3.name) Heuristics and A* Search Hal Daumé III Computer Science University of Maryland me@hal3.name CS 421: Introduction to Artificial Intelligence 2 Feb 2012 Many slides courtesy of Dan Klein, Stuart Russell, or Andrew Moore

2 Hal Daumé III (me@hal3.name) Announcements Office hours: Angjoo: Tuesday 1:00-2:00 Me: Thursday 1:30-3:15 We will usually schedule overload office hours before the week that projects are due Project 1 posted Checkpoint: by next class, you should have pacman running without problems (see FAQ) (Ideally, also do DFS by next class) There is a lot to learn in this project The entire infrastructure will be used in all projects Start NOW!

3 Hal Daumé III (me@hal3.name) Today Heuristics A* Search Heuristic Design Local Search

4 Hal Daumé III (me@hal3.name) Recap: Search Search problems: States (configurations of the world) Successor functions, costs, start and goal tests Search trees: Nodes: represent paths / plans Paths have costs (sum of action costs) Strategies differ (only) in fringe management

5 Hal Daumé III (me@hal3.name) General Tree Search Expanding includes incrementing the path cost!

6 Hal Daumé III (me@hal3.name) Uniform Cost Strategy: expand lowest path cost The good: UCS is complete and optimal! c 1 The bad: Explores options in every direction No information about goal location c 2 c 3 Start Goal

7 Hal Daumé III (me@hal3.name) Heuristics

8 Hal Daumé III (me@hal3.name) Best First / Greedy Search Expand the node that seems closest What can go wrong?

9 Hal Daumé III (me@hal3.name) Best First / Greedy Search START h=12 h=11 2 b a 1 3 d 1 4 p 15 h=11 h=8 h=8 8 2 c 2 e 9 1 9 h 4 3 q h=9 h=5 h=4 h=6 2 f 5 r h=6 GOAL 5 h=0 h=4

10 Hal Daumé III (me@hal3.name) Best First / Greedy Search A common case: Best-first takes you straight to the (wrong) goal Worst-case: like a badlyguided DFS in the worst case Can explore everything Can get stuck in loops if no cycle checking b b Like DFS in completeness (finite states w/ cycle checking)

11 Hal Daumé III (me@hal3.name) Search Gone Wrong?

12 Hal Daumé III (me@hal3.name) Extra Work? Failure to detect repeated states can cause exponentially more work. Why?

13 Hal Daumé III (me@hal3.name) Graph Search In BFS, for example, we shouldn t bother expanding the circled nodes (why?) S d e p b c e h r q a a h r p q f p q f q c G a q c G a

14 Hal Daumé III (me@hal3.name) Graph Search Very simple fix: never expand a state type twice Can this wreck completeness? Why or why not? How about optimality? Why or why not?

15 Hal Daumé III (me@hal3.name) Some Hints Graph search is almost always better than tree search (when not?) Fringes are sometimes called closed lists but don t implement them with lists (use sets)! Nodes are conceptually paths, but better to represent with a state, cost, and reference to parent node

16 Hal Daumé III (me@hal3.name) Best First Greedy Search n # states b avg branch C* least cost s shallow goal m max depth Algorithm Complete Optimal Time Space Greedy Best-First Search Y* N O(b m ) O(b m ) b m What do we need to do to make it complete? Can we make it optimal?

Example: Heuristic Function 17 Hal Daumé III (me@hal3.name) h(x)

Combining UCS and Greedy Uniform-cost orders by path cost, or backward cost g(n) Best-first orders by goal proximity, or forward cost h(n) 5 1 e h=1 1 3 2 S a d G 1 h=5 2 h=6 h=2 h=0 1 b c h=5 h=4 A* Search orders by the sum: f(n) = g(n) + h(n) 18 Hal Daumé III (me@hal3.name) Example: Teg Grenager

19 Hal Daumé III (me@hal3.name) When should A* terminate? Should we stop when we enqueue a goal? 2 A 2 S h = 2 h = 3 B 2 3 h = 1 No: only stop when we dequeue a goal G h = 0

20 Hal Daumé III (me@hal3.name) Is A* Optimal? 1 A h = 6 3 S h = 7 h = 0 G 5 What went wrong? Actual bad goal cost > estimated good goal cost We need estimates to be less than actual costs!

21 Hal Daumé III (me@hal3.name) Admissible Heuristics A heuristic h is admissible (optimistic) if: where is the true cost to a nearest goal E.g. Euclidean distance on a map problem Coming up with admissible heuristics is most of what s involved in using A* in practice.

22 Hal Daumé III (me@hal3.name) Optimality of A*: Blocking Proof: What could go wrong? We d have to have to pop a suboptimal goal G off the fringe before G* This can t happen: Imagine a suboptimal goal G is on the queue Some node n which is a subpath of G* must be on the fringe (why?) n will be popped before G

23 Hal Daumé III (me@hal3.name) Properties of A* Uniform-Cost A* b b

UCS vs A* Contours Uniform-cost expanded in all directions Start Goal A* expands mainly toward the goal, but does hedge its bets to ensure optimality Start Goal 24 Hal Daumé III (me@hal3.name) [demo: position search UCS / A*]

25 Hal Daumé III (me@hal3.name) Admissible Heuristics Most of the work is in coming up with admissible heuristics Inadmissible heuristics are often quite effective (especially when you have no choice) Very common hack: use α x h(n) for admissible h, α > 1 to generate a faster but less optimal inadmissible h from admissible h

26 Hal Daumé III (me@hal3.name) Example: 8 Puzzle What are the states? How many states? What are the actions? What states can I reach from the start state? What should the costs be?

27 Hal Daumé III (me@hal3.name) 8 Puzzle I Number of tiles misplaced? Why is it admissible? h(start) = This is a relaxedproblem heuristic Average nodes expanded when optimal path has length 4 steps 8 steps 12 steps ID 112 6,300 3.6 x 10 6 TILES 13 39 227

28 Hal Daumé III (me@hal3.name) 8 Puzzle II What if we had an easier 8-puzzle where any tile could slide any direction at any time, ignoring other tiles? Total Manhattan distance Why admissible? h(start) = Average nodes expanded when optimal path has length 4 steps 8 steps 12 steps TILES 13 39 227 MAN- HATTAN 12 25 73

29 Hal Daumé III (me@hal3.name) 8 Puzzle III How about using the actual cost as a heuristic? Would it be admissible? Would we save on nodes expanded? What s wrong with it?

30 Hal Daumé III (me@hal3.name) Trivial Heuristics, Dominance Dominance: h a h c if Heuristics form a semi-lattice: Max of admissible heuristics is admissible Trivial heuristics Bottom of lattice is the zero heuristic (what does this give us?) Top of lattice is the exact heuristic

31 Hal Daumé III (me@hal3.name) Where do heuristics come from? Classically designed by hand (and still...) Alternatively, can you watch a person (or optimal agent) and try to learn heuristics from their demonstrations?

32 Hal Daumé III (me@hal3.name) SP/LBD @ CS 297 Examples of demonstrations

33 Hal Daumé III (me@hal3.name) SP/LBD @ CS 297 Examples of demonstrations

34 Hal Daumé III (me@hal3.name) Course Scheduling From the university s perspective: Set of courses {c 1, c 2, c n } Set of room / times {r 1, r 2, r n } Each pairing (c k, r m ) has a cost w km What s the best assignment of courses to rooms? States: list of pairings Actions: add a legal pairing Costs: cost of the new pairing Admissible heuristics? (Who can think of a algorithms answer to this problem?)

Other A* Applications Pathing / routing problems Resource planning problems Robot motion planning Language analysis Machine translation Speech recognition 35 Hal Daumé III (me@hal3.name)

36 Hal Daumé III (me@hal3.name) Graph Search Very simple fix: never expand a state twice Can this wreck completeness? Optimality?

37 Hal Daumé III (me@hal3.name) Optimality of A* Graph Search Consider what A* does: Expands nodes in increasing total f value (f-contours) Proof idea: optimal goals have lower f value, so get expanded first We re making a stronger assumption than in the last proof What?

38 Hal Daumé III (me@hal3.name) Consistency Wait, how do we know we expand in increasing f value? Couldn t we pop some node n, and find its child n to have lower f value? YES: h = 0 h = 8 3 B g = 10 G A h = 10 What can we require to prevent these inversions? Consistency: Real cost must always exceed reduction in heuristic

39 Hal Daumé III (me@hal3.name) Optimality Tree search: A* optimal if heuristic is admissible (and nonnegative) UCS is a special case (h = 0) Graph search: A* optimal if heuristic is consistent UCS optimal (h = 0 is consistent) In general, natural admissible heuristics tend to be consistent

40 Hal Daumé III (me@hal3.name) Summary: A* A* uses both backward costs and (estimates of) forward costs A* is optimal with admissible heuristics Heuristic design is key: often use relaxed problems

41 Hal Daumé III (me@hal3.name) Limited Memory Options Bottleneck: not enough memory to store entire fringe Hill-Climbing Search: Only best node kept around, no fringe! Usually prioritize successor choice by h (greedy hill climbing) Compare to greedy backtracking, which still has fringe Beam Search (Limited Memory Search) In between: keep K nodes in fringe Dump lowest priority nodes as needed Can prioritize by h alone (greedy beam search), or h+g (limited memory A*) Why not applied to UCS? We ll return to beam search later No guarantees once you limit the fringe size!

42 Hal Daumé III (me@hal3.name) Types of Problems Planning problems: We want a path to a solution (examples?) Usually want an optimal path Incremental formulations Identification problems: We actually just want to know what the goal is (examples?) Usually want an optimal goal Complete-state formulations Iterative improvement algorithms

43 Hal Daumé III (me@hal3.name) Hill Climbing Simple, general idea: Start wherever Always choose the best neighbor If no neighbors have better scores than current, quit Why can this be a terrible idea? Complete? Optimal? What s good about it?

44 Hal Daumé III (me@hal3.name) Hill Climbing Diagram Random restarts? Random sideways steps?

45 Hal Daumé III (me@hal3.name) Simulated Annealing Idea: Escape local maxima by allowing downhill moves But make them rarer as time goes on

46 Hal Daumé III (me@hal3.name) Simulated Annealing Theoretical guarantee: Stationary distribution: If T decreased slowly enough, will converge to optimal state! Is this an interesting guarantee? Sounds like magic, but reality is reality: The more downhill steps you need to escape, the less likely you are to every make them all in a row People think hard about ridge operators which let you jump around the space in better ways

47 Hal Daumé III (me@hal3.name) Beam Search Like greedy search, but keep K states at all times: Greedy Search Beam Search Variables: beam size, encourage diversity? The best choice in MANY practical settings Complete? Optimal? Why do we still need optimal methods?

48 Hal Daumé III (me@hal3.name) Genetic Algorithms Genetic algorithms use a natural selection metaphor Like beam search (selection), but also have pairwise crossover operators, with optional mutation Probably the most misunderstood, misapplied (and even maligned) technique around!

49 Hal Daumé III (me@hal3.name) Example: N-Queens Why does crossover make sense here? When wouldn t it make sense? What would mutation be? What would a good fitness function be?

50 Hal Daumé III (me@hal3.name) Continuous Problems Placing airports in Romania States: (x 1,y 1,x 2,y 2,x 3,y 3 ) Cost: sum of squared distances to closest city

Gradient Methods How to deal with continuous (therefore infinite) state spaces? Discretization: bucket ranges of values E.g. force integral coordinates Continuous optimization E.g. gradient ascent 51 Hal Daumé III (me@hal3.name) Image from vias.org