Informed search algorithms. Chapter 4, Sections 1 2 1



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

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

Problem solving and search

SOLVING PROBLEMS BY SEARCHING

An Introduction to The A* Algorithm

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

Measuring the Performance of an Agent

Near Optimal Solutions

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

Guessing Game: NP-Complete?

Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

Romania. Analyst Presentation. 22 nd October 2015

CMPSCI611: Approximating MAX-CUT Lecture 20

2.3 Convex Constrained Optimization Problems

Social Media Mining. Graph Essentials

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

- Easy to insert & delete in O(1) time - Don t need to estimate total memory needed. - Hard to search in less than O(n) time

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

Loop Invariants and Binary Search

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

Connectivity and cuts

Analysis of Algorithms, I

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

Search methods motivation 1

Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

A Note on Maximum Independent Sets in Rectangle Intersection Graphs

Incremental Routing Algorithms For Dynamic Transportation Networks

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

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

Kenken For Teachers. Tom Davis June 27, Abstract

Lecture 4 Online and streaming algorithms for clustering

A binary heap is a complete binary tree, where each node has a higher priority than its children. This is called heap-order property

FOREIGN STUDENTS IN ROMANIA

Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case.

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 313]

Survey On: Nearest Neighbour Search With Keywords In Spatial Databases

Approximation Algorithms

Chapter 6. Decoding. Statistical Machine Translation

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

Single-Link Failure Detection in All-Optical Networks Using Monitoring Cycles and Paths

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

Offline sorting buffers on Line

Midterm Practice Problems

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

International Journal of Advanced Research in Computer Science and Software Engineering

Classifying Large Data Sets Using SVMs with Hierarchical Clusters. Presented by :Limou Wang

Introduction to Graph Theory

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

Applied Algorithm Design Lecture 5

6.852: Distributed Algorithms Fall, Class 2

8.1 Min Degree Spanning Tree

Introduction to Scheduling Theory

Problem Set 7 Solutions

CSC148 Lecture 8. Algorithm Analysis Binary Search Sorting

Network File Storage with Graceful Performance Degradation

Chapter 6: Graph Theory

Bicolored Shortest Paths in Graphs with Applications to Network Overlay Design

SUPPLY CHAIN OPTIMIZATION MODELS IN THE AREA OF OPERATION

J4C - JESSICA FOR CITIES BRASOV Romania

Theory of Computation Chapter 2: Turing Machines

Static Load Balancing

Cpt S 223. School of EECS, WSU

Section 4.2: The Division Algorithm and Greatest Common Divisors

Data Structures Fibonacci Heaps, Amortized Analysis

Chapter 13: Binary and Mixed-Integer Programming

Every tree contains a large induced subgraph with all degrees odd

Analysis of Micromouse Maze Solving Algorithms

The Goldberg Rao Algorithm for the Maximum Flow Problem

Algorithm Design and Analysis

Full and Complete Binary Trees

Euler Paths and Euler Circuits

Objectives. The Role of Redundancy in a Switched Network. Layer 2 Loops. Broadcast Storms. More problems with Layer 2 loops

Scheduling Home Health Care with Separating Benders Cuts in Decision Diagrams

Graph Theory Problems and Solutions

MATH 289 PROBLEM SET 4: NUMBER THEORY

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

Job Scheduling for MapReduce

Lecture 6 Online and streaming algorithms for clustering

Find-The-Number. 1 Find-The-Number With Comps

Finding Ethernet-Type Network Topology is Not Easy

Chapter 1. Computation theory

MATH10040 Chapter 2: Prime and relatively prime numbers

5 INTEGER LINEAR PROGRAMMING (ILP) E. Amaldi Fondamenti di R.O. Politecnico di Milano 1

Well-Separated Pair Decomposition for the Unit-disk Graph Metric and its Applications

Chapter 3. if 2 a i then location: = i. Page 40

1. Prove that the empty set is a subset of every set.

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

recursion, O(n), linked lists 6/14

THE NUMBER OF REPRESENTATIONS OF n OF THE FORM n = x 2 2 y, x > 0, y 0

Transcription:

Informed search algorithms Chapter 4, Sections 1 2 Chapter 4, Sections 1 2 1

Outline Best-first search A search Heuristics Chapter 4, Sections 1 2 2

Review: Tree search function Tree-Search( problem, fringe) returns a solution, or failure fringe Insert(Make-Node(Initial-State[problem]), fringe) loop do if fringe is empty then return failure node Remove-Front(fringe) if Goal-Test[problem] applied to State(node) succeeds return node fringe InsertAll(Expand(node, problem), fringe) A strategy is defined by picking the order of node expansion Chapter 4, Sections 1 2 3

Best-first search Idea: use an evaluation function for each node estimate of desirability Expand most desirable unexpanded node Implementation: fringe is a queue sorted in decreasing order of desirability Special cases: greedy search A search Chapter 4, Sections 1 2 4

Romania with step costs in km Oradea 71 Neamt Zerind 75 151 Arad 140 118 Timisoara 111 Lugoj 70 Mehadia 75 120 Dobreta Sibiu 99 Fagaras 80 Rimnicu Vilcea 97 Pitesti 211 146 101 85 138 Bucharest 90 Craiova Giurgiu 87 Iasi 92 142 98 Urziceni Vaslui Hirsova 86 Eforie Straight line distance to Bucharest Arad 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 Oradea 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 Zerind 374 Chapter 4, Sections 1 2 5

Greedy search Evaluation function h(n) (heuristic) = estimate of cost from n to the closest goal E.g., h SLD (n) = straight-line distance from n to Bucharest Greedy search expands the node that appears to be closest to goal Chapter 4, Sections 1 2 6

Greedy search example Arad 366 Chapter 4, Sections 1 2 7

Greedy search example Arad Sibiu Timisoara Zerind 253 329 374 Chapter 4, Sections 1 2 8

Greedy search example Arad Sibiu Timisoara Zerind 329 374 Arad Fagaras Oradea Rimnicu Vilcea 366 176 380 193 Chapter 4, Sections 1 2 9

Greedy search example Arad Sibiu Timisoara Zerind 329 374 Arad Fagaras Oradea Rimnicu Vilcea 366 380 193 Sibiu Bucharest 253 0 Chapter 4, Sections 1 2 10

Properties of greedy search Complete?? Chapter 4, Sections 1 2 11

Properties of greedy search Complete?? No can get stuck in loops, e.g., with Oradea as goal, Iasi Neamt Iasi Neamt Complete in finite space with repeated-state checking Time?? Chapter 4, Sections 1 2 12

Properties of greedy search Complete?? No can get stuck in loops, e.g., Iasi Neamt Iasi Neamt Complete in finite space with repeated-state checking Time?? O(b m ), but a good heuristic can give dramatic improvement Space?? Chapter 4, Sections 1 2 13

Properties of greedy search Complete?? No can get stuck in loops, e.g., Iasi Neamt Iasi Neamt Complete in finite space with repeated-state checking Time?? O(b m ), but a good heuristic can give dramatic improvement Space?? O(b m ) keeps all nodes in memory Optimal?? Chapter 4, Sections 1 2 14

Properties of greedy search Complete?? No can get stuck in loops, e.g., Iasi Neamt Iasi Neamt Complete in finite space with repeated-state checking Time?? O(b m ), but a good heuristic can give dramatic improvement Space?? O(b m ) keeps all nodes in memory Optimal?? No Chapter 4, Sections 1 2 15

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 to goal from n f(n) = estimated total cost of path through n to goal A search uses an admissible heuristic i.e., h(n) h (n) where h (n) is the true cost from n. (Also require h(n) 0, so h(g) = 0 for any goal G.) E.g., h SLD (n) never overestimates the actual road distance Theorem: A search is optimal Chapter 4, Sections 1 2 16

A search example Arad 366=0+366 Chapter 4, Sections 1 2 17

A search example Arad Sibiu 393=140+253 Timisoara Zerind 447=118+329 449=75+374 Chapter 4, Sections 1 2 18

A search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras Oradea Rimnicu Vilcea 646=280+366 415=239+176 671=291+380 413=220+193 Chapter 4, Sections 1 2 19

A search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras 646=280+366 415=239+176 Oradea 671=291+380 Rimnicu Vilcea Craiova Pitesti Sibiu 526=366+160 417=317+100 553=300+253 Chapter 4, Sections 1 2 20

A search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras Oradea Rimnicu Vilcea 646=280+366 671=291+380 Sibiu Bucharest Craiova Pitesti Sibiu 591=338+253 450=450+0 526=366+160 417=317+100 553=300+253 Chapter 4, Sections 1 2 21

A search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras Oradea Rimnicu Vilcea 646=280+366 671=291+380 Sibiu Bucharest Craiova Pitesti Sibiu 591=338+253 450=450+0 526=366+160 553=300+253 Bucharest Craiova Rimnicu Vilcea 418=418+0 615=455+160 607=414+193 Chapter 4, Sections 1 2 22

Optimality of A (standard proof) Suppose some suboptimal goal G 2 has been generated and is in the queue. Let n be an unexpanded node on a shortest path to an optimal goal G 1. Start n G G 2 f(g 2 ) = g(g 2 ) since h(g 2 ) = 0 > g(g 1 ) since G 2 is suboptimal f(n) since h is admissible Since f(g 2 ) > f(n), A will never select G 2 for expansion Chapter 4, Sections 1 2 23

Optimality of A (more useful) Lemma: A expands nodes in order of increasing f value Gradually adds f-contours of nodes (cf. breadth-first adds layers) Contour i has all nodes with f = f i, where f i < f i+1 O Z N A I T 380 400 S R F V L P D M C 420 G B U H E Chapter 4, Sections 1 2 24

Properties of A Complete?? Chapter 4, Sections 1 2 25

Properties of A Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Chapter 4, Sections 1 2 26

Properties of A Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of soln.] Space?? Chapter 4, Sections 1 2 27

Properties of A Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of soln.] Space?? Keeps all nodes in memory Optimal?? Chapter 4, Sections 1 2 28

Properties of A Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of soln.] Space?? Keeps all nodes in memory Optimal?? Yes cannot expand f i+1 until f i is finished A expands all nodes with f(n) < C A expands some nodes with f(n) = C A expands no nodes with f(n) > C Chapter 4, Sections 1 2 29

A heuristic is consistent if Proof of lemma: Consistency h(n) c(n, a, n ) + h(n ) If h is consistent, we have f(n ) = g(n ) + h(n ) = g(n) + c(n, a, n ) + h(n ) g(n) + h(n) = f(n) I.e., f(n) is nondecreasing along any path. n c(n,a,n ) n h(n ) h(n) G Chapter 4, Sections 1 2 30

E.g., for the 8-puzzle: Admissible heuristics h 1 (n) = number of misplaced tiles h 2 (n) = total Manhattan distance (i.e., no. of squares from desired location of each tile) 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State h 1 (S) =?? h 2 (S) =?? Chapter 4, Sections 1 2 31

E.g., for the 8-puzzle: Admissible heuristics h 1 (n) = number of misplaced tiles h 2 (n) = total Manhattan distance (i.e., no. of squares from desired location of each tile) 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State h 1 (S) =?? 6 h 2 (S) =?? 4+0+3+3+1+0+2+1 = 14 Chapter 4, Sections 1 2 32

Dominance If h 2 (n) h 1 (n) for all n (both admissible) then h 2 dominates h 1 and is better for search Typical search costs: d = 14 IDS = 3,473,941 nodes A (h 1 ) = 539 nodes A (h 2 ) = 113 nodes d = 24 IDS 54,000,000,000 nodes A (h 1 ) = 39,135 nodes A (h 2 ) = 1,641 nodes Given any admissible heuristics h a, h b, h(n) = max(h a (n), h b (n)) is also admissible and dominates h a, h b Chapter 4, Sections 1 2 33

Relaxed problems Admissible heuristics can be derived from the exact solution cost of a relaxed version of the problem If the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h 1 (n) gives the shortest solution If the rules are relaxed so that a tile can move to any adjacent square, then h 2 (n) gives the shortest solution Key point: the optimal solution cost of a relaxed problem is no greater than the optimal solution cost of the real problem Chapter 4, Sections 1 2 34

Relaxed problems contd. Well-known example: travelling salesperson problem (TSP) Find the shortest tour visiting all cities exactly once Minimum spanning tree can be computed in O(n 2 ) and is a lower bound on the shortest (open) tour Chapter 4, Sections 1 2 35

Summary Heuristic functions estimate costs of shortest paths Good heuristics can dramatically reduce search cost Greedy best-first search expands lowest h incomplete and not always optimal A search expands lowest g + h complete and optimal also optimally efficient (up to tie-breaks, for forward search) Admissible heuristics can be derived from exact solution of relaxed problems Chapter 4, Sections 1 2 36