CMU Lecture 4: Informed Search. Teacher: Gianni A. Di Caro

Similar documents
CMU-Q Lecture 3: Search algorithms: Informed. Teacher: Gianni A. Di Caro

AI Programming CS S-06 Heuristic Search

Tree/Graph Search. q IDDFS-? B C. Search CSL452 - ARTIFICIAL INTELLIGENCE 2

Informed Search. Day 3 of Search. Chap. 4, Russel & Norvig. Material in part from

Informed Search. Chap. 4. Breadth First. O(Min(N,B L )) BFS. Search. have same cost BIBFS. Bi- Direction. O(Min(N,2B L/2 )) BFS. have same cost UCS

Graph Search Howie Choset

Game Engineering CS F-12 Artificial Intelligence

CS 4100 // artificial intelligence. Recap/midterm review!

Problem solving and search. Chapter 3. Chapter 3 1

Principles of AI Planning

I may not have gone where I intended to go, but I think I have ended up where I needed to be. Douglas Adams

Deterministic Planning and State-space Search. Erez Karpas

Breadth First Search, Dijkstra s Algorithm for Shortest Paths

Analysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes

Static Program Analysis

CMU-Q Lecture 5: Classical Planning Factored Representations STRIPS. Teacher: Gianni A. Di Caro

CS 4407 Algorithms Lecture: Shortest Path Algorithms

Algorithms: Lecture 12. Chalmers University of Technology

Economics 204 Fall 2011 Problem Set 2 Suggested Solutions

CS360 Homework 12 Solution

Principles of AI Planning

Query Processing in Spatial Network Databases

Principles of AI Planning

CSE 4502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions

Shortest Path Algorithms

A* Search. 1 Dijkstra Shortest Path

ICS 252 Introduction to Computer Design

COMP251: Bipartite graphs

Incremental Path Planning

Single Source Shortest Paths

Faster than Weighted A*: An Optimistic Approach to Bounded Suboptimal Search

Pigeonhole Principle and Ramsey Theory

Artificial Intelligence Methods. Problem solving by searching

Principles of AI Planning

CMU Lecture 11: Markov Decision Processes II. Teacher: Gianni A. Di Caro

Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees

CSC242: Intro to AI. Lecture 5. Tuesday, February 26, 13

Optimal Planning for Delete-free Tasks with Incremental LM-cut

d(x n, x) d(x n, x nk ) + d(x nk, x) where we chose any fixed k > N

Advanced Calculus I Chapter 2 & 3 Homework Solutions October 30, Prove that f has a limit at 2 and x + 2 find it. f(x) = 2x2 + 3x 2 x + 2

Learning in State-Space Reinforcement Learning CIS 32

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

Artificial Intelligence (Künstliche Intelligenz 1) Part II: Problem Solving

CS 188 Introduction to Fall 2007 Artificial Intelligence Midterm

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker

Network Design and Game Theory Spring 2008 Lecture 6

Complexity Theory Part II

Heuristic Search Algorithms

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Lecture 1 : Data Compression and Entropy

Design and Analysis of Algorithms

Part V. Matchings. Matching. 19 Augmenting Paths for Matchings. 18 Bipartite Matching via Flows

CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk. 10/8/12 CMPS 2200 Intro.

CSC242: Artificial Intelligence. Lecture 4 Local Search

Introduction to Algorithms

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm

Introduction to Algorithms

CSE 473: Artificial Intelligence Spring 2014

2. Metric Spaces. 2.1 Definitions etc.

The exam is closed book, closed calculator, and closed notes except your one-page crib sheet.

Midterm Exam, Thursday, October 27

BFS Dijkstra. Oct abhi shelat

Single Source Shortest Paths

Constraint satisfaction search. Combinatorial optimization search.

CMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis

Solving Problems By Searching

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Algorithm Design and Analysis

DD* Lite: Efficient Incremental Search with State Dominance

arxiv: v1 [cs.dc] 4 Oct 2018

Sublinear Algorithms Lecture 3. Sofya Raskhodnikova Penn State University

Algorithm Design Strategies V

Doctoral Course in Speech Recognition. May 2007 Kjell Elenius

Introduction to Algorithms

(tree searching technique) (Boolean formulas) satisfying assignment: (X 1, X 2 )

Dynamic Programming: Shortest Paths and DFA to Reg Exps

CSE 417. Chapter 4: Greedy Algorithms. Many Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Average Case Complexity: Levin s Theory

Math 391: Midterm 1.0 Spring 2016

Algorithm Design and Analysis

Algorithm Design and Analysis

Dynamic Programming: Shortest Paths and DFA to Reg Exps

COMP251: Bipartite graphs

Announcements. CompSci 102 Discrete Math for Computer Science. Chap. 3.1 Algorithms. Specifying Algorithms

Worst-Case Solution Quality Analysis When Not Re-Expanding Nodes in Best-First Search

Unit 1A: Computational Complexity

A* with Lookahead Re-evaluated

Lecture: Workload Models (Advanced Topic)

EE376A: Homework #3 Due by 11:59pm Saturday, February 10th, 2018

Search and Lookahead. Bernhard Nebel, Julien Hué, and Stefan Wölfl. June 4/6, 2012

Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

CMPS 6610 Fall 2018 Shortest Paths Carola Wenk

Lecture 10: Linear programming duality and sensitivity 0-0

Discrete Optimization 2010 Lecture 3 Maximum Flows

where X is the feasible region, i.e., the set of the feasible solutions.

MHCA Math Summer Packet 2015

Math 118B Solutions. Charles Martin. March 6, d i (x i, y i ) + d i (y i, z i ) = d(x, y) + d(y, z). i=1

Computational Boolean Algebra. Pingqiang Zhou ShanghaiTech University

Transcription:

CMU 15-781 Lecture 4: Informed Search Teacher: Gianni A. Di Caro

UNINFORMED VS. INFORMED Uninformed Can only generate successors and distinguish goals from non-goals Informed Strategies that can distinguish whether one non-goal is more promising than another 2

REMINDER: TREE SEARCH function TREE-SEARCH(problem, strategy) set of frontier nodes contains the start state of problem loop if there are no frontier nodes return failure choose a frontier node for expansion using strategy if the node contains a goal return corresponding solution else expand the node add the resulting nodes to the set of frontier nodes 3

RECAP: STRATEGIES FOR UNINFORMED SEARCH BFS: Shallowest unexpanded node DFS / IDP: Deepest unexpanded node UCS: Lowest cost-to-come (from start) LS: Local highest-value successor node 4

ESTIMATE OF COST-TO-GO 5

STRATEGY: BEST-FIRST SEARCH General strategy template for informed search A node n in the frontier set is selected for expansion based on an evaluation function f(n), which is a cost estimate Backward (to-come) and (estimates of) Forward (to-go) costs The node with the lowest cost estimate is expanded first Data structure: Priority queue using f(n) for ordering 6

UNIFORM COST SEARCH Strategy: Expand by f x = g x = cost-to-come s c 1 3 2 a d 5 1 1 1 b e t s a b d e c t d g = 0 g = 1 g = 2 g = 4 g = 6 g = 3 g = 6 g = 7 #1 #2 #3 #5 #6 #4 #7 7

UCS VS. DIJKSTRA S ALGORITHM DA All nodes are initially inserted into the PQ (explicit graph description is given as input) Initial distance (g(s), cost-to-come) from start: d[s]=0, d[x s] = The node with the minimal estimated distance is selected at each step Shortest paths to all other nodes or to a single one UCS o o o Explicit graph description is not given as input Nodes are inserted to the PQ lazily during the search, based on node expansion choices Can naturally handle the presence of multiple goals 8

DIJKSTRA S ALGORITHM (1959) Input: Graph G=(V,E) ( x s) dist[x] = + dist[s] = 0 S = Q = V // Ordered by dist[] while Q do u = extract_min(q) S = S {u} foreach vertex v Adjacent(u) do dist[v] = min(dist[v], dist[u] + c(u,v)) // Relaxation end do end do 9

PROBLEM DESCRIPTION + HEURISTIC KNOWLEDGE So far, only problem description (successors, step costs) has been used to search the state space What about using (also) additional, heuristic knowledge, h(x), to direct state expansion by looking forward? Heuristics are rules of thumb, educated guesses, intuitive judgments or, simply, common sense The term derives from the ancient Greek keuriskein, meaning serving to find out, or discover. Archimedes Eureka! means I have found it! 10

EXAMPLE: HEURISTIC City Aerial dist Arad 366 Sibiu 253 Rimnicu Vilcea 193 Fagaras 176 Pitesti 100 11

GREEDY BEST-FIRST SEARCH Strategy: Expand by h x = heuristic evaluation of cost-to-go(al) from x h = 6 h = 5 h = 2 h = 0 s c h = 7 1 3 2 a d 5 1 1 1 b e h = 6 h = 1 t s a b d e d t h = 6 h = 5 h = 6 h = 2 h = 1 h = 2 h = 0 #1 #2 #3 #4 #5 12

A* SEARCH (1968) Strategy: Combine cost-to-come (past) and heuristic estimate of cost-to-go (future), expand by f x = h x + g x Poll 1: Which node is expanded fourth? 1. d 2. e 3. g 4. c d e t c h = 6 h = 5 h = 2 h = 0 s c 1 3 2 a d 5 1 1 1 b e h = 7 h = 6 h = 1 t 13

A* SEARCH Should we stop when we discover a goal? h = 2 h = 3 s 2 a 2 h = 0 t 2 b 3 h = 1 No: Only stop when we expand a goal! (same as in UCS) 15781 Slide adapted Fall 2016: from Lecture Dan Klein 4 14

A* SEARCH Is A* optimal? h = 7 h = 0 s 5 1 a 3 h = 6 t The good path has a pessimistic estimate Circumvent this issue by being optimistic! 15781 Slide adapted Fall 2016: from Lecture Dan Klein 4 15

ADMISSIBLE HEURISTICS h is admissible if for all nodes x, h x h x, where h is the cost of the optimal path to a goal An admissible heuristic is a lower bound on real cost Example: Aerial distance in the path finding example Example: h 0 The tighter the bound, the better 16

OPTIMALITY OF A* Theorem: A* tree search with an admissible heuristic returns an optimal solution Proof (by contradiction): o Assume that a suboptimal goal t is expanded before the optimal goal t x t Frontier t 15781 Slide adapted Fall 2016: from Lecture Dan Klein 4 17

OPTIMALITY OF A* Proof (cont.): o There is a node x in the frontier, on the optimal path to t that has been discovered but not expanded yet o f x = g x + h x g x + h x x o But since x is on the optimal path to t*: = g t < g t = f(t) (h(t)=0) t Frontier t o x should have been expanded before t! 15781 Slide adapted Fall 2016: from Lecture Dan Klein 4 18

8-PUZZLE HEURISTICS Defining a good heuristic it s not a trivial task 5 2 h 1 : #tiles in wrong position [h 1 (s) = 5] h 2 : sum of Manhattan distances of tiles from goal [h 1 (s) = 2+0+1+3+2+2+0+0=10] Poll 2: Which heuristic is admissible? 1. Only h ; 2. Only h < 3. Both h ; and h < 4. Neither one 6 1 7 8 3 4 Example state 1 4 5 6 7 2 8 3 Goal state 19

Heuristic for designing admissible heuristics: relax the problem! Relaxation: Remove functional / domain constraints Add forbidden moves 20

DOMINANCE h 1 : #tiles in wrong position h 2 : sum of Manhattan distances of tiles from goal h dominates h iff x, h x h @ x (h is consistently a tighter bound wrt h ) Poll 3: What is the dominance relation between h ; and h <? 1. h ; dominates h < 2. h < dominates h ; 3. h ; and h < are incomparable 5 6 1 7 2 8 3 4 Example state 1 4 5 6 7 2 8 3 Goal state 21

8-PUZZLE HEURISTICS The following table gives the search cost of A* with the two heuristics, averaged over random 8-puzzles, for various solution lengths Length A (h 1 ) A (h 2 ) 16 1301 211 18 3056 363 20 7276 676 22 18094 1219 24 39135 1641 Moral: Good heuristics are crucial! 22

GRAPH SEARCH In tree search, expanding the same state multiple times can cause exponentially more work a a b b b c c c c c 23

GRAPH SEARCH Same as tree search, but never expand a node twice E.g., in BFS expanding the circled nodes is not necessary Set of already expanded nodes has to be stored in memory 15781 Slide Fall adapted 2016: from Lecture Dan 4Klein 24

GRAPH SEARCH AND OPTIMALITY Is optimality of A* under admissible heuristics preserved? No! Search tree h = 4 1 1 s f = (0+2) h = 2 s 1 a b h = 1 2 h = 1 c 3 h = 0 t (1+4) (2+1) a c {a,b} {a,c} b c (1+1) (3+1) (5+0) t No! {a,t} {t} t (6+0) 15781 Slide adapted Fall 2016: from Lecture Dan Klein 4 25

CONSISTENT HEURISTICS c x, y = real cost of cheapest path between x and y h is consistent if for every two nodes x, y, h x c(x, y) + h(y) Triangle inequality Necessary for graph search optimality x y t 26

CONSISTENT HEURISTICS Consistency : The estimated distance to the goal from x cannot be reduced by moving to a different state y and adding the estimate of the distance to the goal from y to the cost of reaching y from x c x, y h x h(y) The real cost is higher than the cost implied by the heuristics h = 2 s 1 h = 4 a 1 h = 1 c 3 h = 0 t x y 1 b h = 1 2 What was the problem? t 27

CONSISTENT HEURISTICS h is consistent if for every two nodes x, y, h x c(x, y) + h(y) Assuming h(t) = 0 at goals t Poll 4: What is the relation between admissibility and consistency? 1. Admissible consistent 2. Consistent admissible 3. They are equivalent 4. They are incomparable x t y 28

CONSISTENCY MONOTONICITY Lemma: If h(x) is consistent, then the values of the cost function f(x) along any path are nondecreasing Proof: o o If y is a successor of x: g(y) = g(x) + c(x,y) By consistency: f(y) = g(y) + h(y) = g(x) + c(x,y) + h(y) g(x) + h(x) = f(x) In moving from a state to its neighbor, (a consistent) h must not decrease more than the cost of the edge that connects them. Consistency is a property of h(x), monotonicity is a property of f(x) 29

8-PUZZLE HEURISTICS, REVISITED h 1 : #tiles in wrong position h 2 : sum of Manhattan distances of tiles from goal 5 2 6 1 3 Poll 5: Which heuristic is consistent? 1. Only h ; 2. Only h < 3. Both h ; and h < 4. Neither one 7 8 4 Example state 1 4 5 6 7 2 8 3 Goal state 30

Heuristic for designing consistent heuristics: design an admissible heuristic! 31

ADMISSIBLE BUT INCONSISTENT HEURISTICS? Keep the LB property, but violate monotonicity Inconsistent for at least one pair of states f(p) = 10 Manhattan distance for set {1,2,3,4} Manhattan distance for set {5,6,7,8} At each step, choose at random which set What is the relation between heuristic estimates? f(c 1 ) = 8 5 2 1 2 3 6 1 3 4 5 6 7 8 4 7 8 32

OPTIMALITY OF A*, REVISITED Theorem: A* graph search with a consistent heuristic returns an optimal solution Proof: o Whenever A* selects a state x for expansion, the optimal path to x has been found. Otherwise, there would a frontier node y (separation property) on the optimal path from start to x that should be expanded first because f is non decreasing along any path (monotonicity) o The first goal state x* selected for expansion must be optimal, because f(x*) is the true (optimal) cost for goal nodes (h(x*) = 0), and any other later goal node would be at least as expensive because of f monotonicity 33

CONTOURS IN THE STATE SPACE f-costs are nondecreasing along any path from the start Contours (isolines) in the state-space, like in topographic maps A* search fans out adding nodes in circoncentric bands of increasing f-cost The tight the LB bounds are, the more the bands will stretch O toward the goal state Bands using UCS? A T Z 380 D L 400 M S R C F P 420 G N B I U V H E 34

PRUNING AND COMPLETENESS A T Z 380 O D L 400 M S R If C* is the cost of the optimal path, A* expands all nodes with f(x) < C*, and no nodes with f(x) > C* (automatic pruning) A* might expand some of the nodes on the goal contour, where f(x) = C*, before selecting the goal node Completeness? Yes, if only a finitely many nodes with cost less or equal to C* are present (b is finite and all step costs are ɛ > 0) C F P 420 G N B I U V H E 35

A* IS OPTIMALLY EFFICIENT Theorem: Any algorithm that returns the optimal solution given a consistent heuristic will expand all nodes surely expanded by A* But this is not the case when the heuristic is only admissible a s b h = 1 h = 20 h = 6 1 1 3 1 1 1 h = 1 h = 1 c t 10 Alg B: Conduct exhaustive search except for expanding a; then expand a only if it has the potential to sprout cheaper solution 36

Terminology: o o o Search problems SUMMARY Algorithms: tree search, graph search, best-first search, uniform cost search, greedy, A* Admissible and consistent heuristics Big ideas: o o o Properties of the heuristic A* optimality Don t be too pessimistic! Be consistent! 37

PROJECTS Proposals to be submitted by October 24 1-2 pages stating: o o o Motivation Goals Work plan 40 hours of work Can be done in pairs Poster presentation only, at the end of the semester 38