Searching. Lecture 3 - States and Searching. Example Problem for Delivery Robot. Directed Graphs. Topological Map of DC/MC

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

Measuring the Performance of an Agent

An Introduction to The A* Algorithm

Informed search algorithms. Chapter 4, Sections 1 2 1

Analysis of Micromouse Maze Solving Algorithms

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

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

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

2. Length and distance in hyperbolic geometry

New Admissible Heuristics for Domain-Independent Planning

Project and Production Management Prof. Arun Kanda Department of Mechanical Engineering Indian Institute of Technology, Delhi

Dynamic programming formulation

Search methods motivation 1

Scheduling Shop Scheduling. Tim Nieberg

A hierarchical multicriteria routing model with traffic splitting for MPLS networks

Computational Geometry. Lecture 1: Introduction and Convex Hulls

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

Graph Theory Problems and Solutions

Moving Target Search. 204 Automated Reasoning

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

Linear Programming. Solving LP Models Using MS Excel, 18

6.02 Practice Problems: Routing

10.2 Series and Convergence

WAN Wide Area Networks. Packet Switch Operation. Packet Switches. COMP476 Networked Computer Systems. WANs are made of store and forward switches.

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

Approximation Algorithms

Smart Graphics: Methoden 3 Suche, Constraints

6.852: Distributed Algorithms Fall, Class 2

Game playing. Chapter 6. Chapter 6 1

9th Max-Planck Advanced Course on the Foundations of Computer Science (ADFOCS) Primal-Dual Algorithms for Online Optimization: Lecture 1

Midterm Practice Problems

Near Optimal Solutions

High Performance Computing for Operation Research

Dynamic Programming. Lecture Overview Introduction

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

Dynamic programming. Doctoral course Optimization on graphs - Lecture 4.1. Giovanni Righini. January 17 th, 2013

2) Write in detail the issues in the design of code generator.

Static IP Routing and Aggregation Exercises

3D Drawing. Single Point Perspective with Diminishing Spaces

Arrangements And Duality

Reinforcement Learning

Decision Making under Uncertainty

Static Load Balancing

Manifold Learning Examples PCA, LLE and ISOMAP

Sequential lmove Games. Using Backward Induction (Rollback) to Find Equilibrium

Regular Expressions and Automata using Haskell

Goals of the Unit. spm adolfo villafiorita - introduction to software project management

Problem Set 7 Solutions

DEVELOPMENT OF A VULNERABILITY ASSESSMENT CODE FOR A PHYSICAL PROTECTION SYSTEM: SYSTEMATIC ANALYSIS OF PHYSICAL PROTECTION EFFECTIVENESS (SAPE)

Chapter 6. Decoding. Statistical Machine Translation

Reinforcement Learning

So today we shall continue our discussion on the search engines and web crawlers. (Refer Slide Time: 01:02)

West Virginia University College of Engineering and Mineral Resources. Computer Engineering 313 Spring 2010

TEACHER S GUIDE TO RUSH HOUR

Dynamic Programming 11.1 AN ELEMENTARY EXAMPLE

Chapter 13: Binary and Mixed-Integer Programming

3 An Illustrative Example

Random Map Generator v1.0 User s Guide

Introduction & Overview

Chapter 15: Dynamic Programming

1 Introduction. 2 Prediction with Expert Advice. Online Learning Lecture 09

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

SUPPLY CHAIN OPTIMIZATION MODELS IN THE AREA OF OPERATION

Data Mining Practical Machine Learning Tools and Techniques

Practical Guide to the Simplex Method of Linear Programming

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

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

Linear Programming for Optimization. Mark A. Schulze, Ph.D. Perceptive Scientific Instruments, Inc.

Review; questions Discussion of Semester Project Arbitrary interprocedural control flow Assign (see Schedule for links)

Data Structures and Algorithms Written Examination

Data Structures and Algorithms

Embedded Systems 20 REVIEW. Multiprocessor Scheduling

14.1 Rent-or-buy problem

Learning to Search More Efficiently from Experience: A Multi-Heuristic Approach

Equilibrium computation: Part 1

Load Balanced Optical-Network-Unit (ONU) Placement Algorithm in Wireless-Optical Broadband Access Networks

On Fleet Size Optimization for Multi-Robot Frontier-Based Exploration

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

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

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

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

Mining Social Network Graphs

Module 5. Broadcast Communication Networks. Version 2 CSE IIT, Kharagpur

3D Drawing. Single Point Perspective with Diminishing Spaces

Y. Xiang, Constraint Satisfaction Problems

The Goldberg Rao Algorithm for the Maximum Flow Problem

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

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

ASSIGNMENT 4 PREDICTIVE MODELING AND GAINS CHARTS

A Fast Algorithm For Finding Hamilton Cycles

Network Planning and Analysis

CSE 4351/5351 Notes 7: Task Scheduling & Load Balancing

Call Admission Control and Routing in Integrated Service Networks Using Reinforcement Learning

INTEGER PROGRAMMING. Integer Programming. Prototype example. BIP model. BIP models

Problem solving and search

Degeneracy in Linear Programming

Analysis of Algorithms, I

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Internet Control Message Protocol (ICMP)

2.3 Convex Constrained Optimization Problems

Transcription:

cost = distance travelled cost = number of doors + distance () Searching Lecture - States and Searching Jesse Hoey School of Computer Science University of Waterloo May, Readings: Poole & Mackworth Chapt. (all) Often we are not given an algorithm to solve a problem, but only a specification of what is a solution we have to search for a solution. A typical problem is when the agent is in one state, it has a set of deterministic actions it can carry out, and wants to get to a goal state. Many AI problems can be abstracted into the problem of finding a path in a directed graph. Often there is more than one way to represent a problem as a graph. Directed Graphs Example Problem for Delivery Robot The robot wants to get from outside room to the inside of room. A graph consists of a set N of nodes and a set A of ordered pairs of nodes, called arcs. Node n is a neighbor of n if there is an arc from n to n. That is, if n, n A. A path is a sequence of nodes n, n,..., n k such that n i, n i A. Given a set of start nodes and goal nodes, a solution is a path from a start node to a goal node. Often there is a cost associated with arcs and the cost of a path is the sum of the costs of the arcs in the path. r o mail r9 o9 d a ts r7 r5 r r r9 storage o7 o5 o d c d c a a b b o o9 o7 r7 c o5 r5 b o r b o o o5 o7 o9 o main office stairs r r r5 r7 r9 r Graph for the Delivery Robot Topological Map of DC/MC LE MC 5 TH JO H OU H H H5 H CF H8 H6 H7 HE

Problem space search Problem space search Partial Search Space for a Video Game Grid game: collect coins C, C, C, C, don t run out of fuel, and end up at location (, ): Partial Search Space for a Video Game Grid game: collect coins C, C, C, C, don t run out of fuel, and end up at location (, ): Graph Searching Problem Solving by Graph Searching Generic search algorithm: given a graph, start nodes, and goal nodes, incrementally explore paths from the start nodes. Maintain a frontier of paths from the start node that have been explored. As search proceeds, the frontier expands into the unexplored nodes until a goal node is encountered. The way in which the frontier is expanded defines the search strategy. start node explored nodes ends of paths on frontier unexplored nodes Graph Search Algorithm Graph Search Algorithm select and remove path n,..., n k from frontier; return n,..., n k ; add n,..., n k, n to frontier; We assume that after the search algorithm returns an answer, it can be asked for more answers and the procedure continues. Which value is selected from the frontier (or how the new values are added to the frontier) at each stage defines the search strategy. The neighbors define the graph. goal defines what is a solution.

Types of Search Depth-first Search Uninformed (blind) Heuristic More sophisticated hacks Depth-first search treats the frontier as a stack It always selects one of the last elements added to the frontier. If the list of paths on the frontier is [p, p,...] p is selected. Paths that extend p are added to the front of the stack (in front of p ). p is only selected when all paths from p have been explored. Illustrative Graph Depth-first Search Complexity of Depth-first Search 5 7 5 6 Depth-first search isn t guaranteed to halt on infinite graphs or on graphs with cycles. The space complexity is linear in the size of the path being explored. Search is unconstrained by the goal until it happens to stumble on the goal (uninformed or blind) What is the worst-case time complexity of depth-first search? 6 8 9 Graph Search Algorithm - with Cycle Check Breadth-first Search select and remove path n,..., n k from frontier; return n,..., n k ; if n / n,..., n k add n,..., n k, n to frontier; Breadth-first search treats the frontier as a queue. It always selects one of the earliest elements added to the frontier. If the list of paths on the frontier is [p, p,..., p r ]: p is selected. Its neighbors are added to the end of the queue, after p r. p is selected next.

Illustrative Graph Breadth-first Search Complexity of Breadth-first Search 5 6 7 8 9 5 6 The branching factor of a node is the number of its neighbors. If the branching factor for all nodes is finite, breadth-first search is guaranteed to find a solution if one exists. It is guaranteed to find the path with fewest arcs. Time complexity is exponential in the path length: b n, where b is branching factor, n is path length. The space complexity is exponential in path length: b n. Search is unconstrained by the goal. Is it affected by cycles? Graph Search Algorithm - with Multiple Path Pruning Lowest-cost-first Search has path := {}; select and remove path n,..., n k from frontier; if n k / has path: add n k to has path ; return n,..., n k ; add n,..., n k, n to frontier; Sometimes there are costs associated with arcs. The cost of a path is the sum of the costs of its arcs. cost( n,..., n k ) = k n i, n i i= At each stage, lowest-cost-first search selects a path on the frontier with lowest cost. The frontier is a priority queue ordered by path cost. It finds a least-cost path to a goal node. When arc costs are equal = breadth-first search. Uniformed/Blind search (in that it does not take the goal into account) Complexity? Heuristic Search Example Heuristic Functions Idea: don t ignore the goal when selecting paths. Often there is extra knowledge that can be used to guide the search: heuristics. h(n) is an estimate of the cost of the shortest path from node n to a goal node. h(n) uses only readily obtainable information (that is easy to compute) about a node. h can be extended to paths: h( n,..., n k ) = h(n k ). h(n) is an underestimate if there is no path from n to a goal that has path length less than h(n). If the nodes are points on a Euclidean plane and the cost is the distance, we can use the straight-line distance from n to the closest goal as the value of h(n). If the nodes are locations and cost is time, we can use the distance to a goal divided by the maximum speed. What about Chess?

Best-first Search Illustrative Example Best First Search Idea: select the path whose end is closest to a goal according to the heuristic function. Best-first search selects a path on the frontier with minimal h-value. It treats the frontier as a priority queue ordered by h. S A B C best first: S-A-C-G (not optimal) G Graph Search Algorithm - with Multiple Path Pruning Heuristic Depth-first Search has path := {}; select and remove path n,..., n k from frontier; if n k / has path: add n k to has path ; return n,..., n k ; add n,..., n k, n to frontier; Idea: Do a depth-first seach, but add paths to the stack ordered according to h Locally does a best-first search, but agressively pursues the best looking path (even if it ends up being worse than one higher up). Suffers from the same problems as depth-first search Is often used in practice Illustrative Graph Heuristic Search Graph Search Algorithm - with Multiple Path Pruning cost of an arc is its length heuristic: euclidean distance red nodes all look better than green nodes g s has path := {}; select and remove path n,..., n k from frontier; if n k / has path: add n k to has path ; return n,..., n k ; add n,..., n k, n to frontier;

A Search A Search Algorithm A search uses both path cost and heuristic values cost(p) is the cost of path p. h(p) estimates the cost from the end of p to a goal. Let f (p) = cost(p) + h(p). f (p) estimates the total path cost of going from a start node to a goal via p. start path p estimate n goal }{{}}{{} } cost(p) {{ h(p) } f (p) A is a mix of lowest-cost-first and best-first search. It treats the frontier as a priority queue ordered by f (p). It always selects the node on the frontier with the lowest estimated distance from the start to a goal node constrained to go via that node. Illustrative Example Best First Search Admissibility of A S A B C recall best first: S-A-C-G (not optimal) A : S-A-B-C-G (optimal) G If there is a solution, A always finds an optimal solution the first path to a goal selected if the branching factor is finite arc costs are bounded above zero (there is some ɛ > such that all of the arc costs are greater than ɛ), and h(n) is a lower bound on the length (cost) of the shortest path from n to a goal node. Admissible heuristics never overestimate the cost to the goal. Why is A with admissible h optimal? Graph Search Algorithm - with Multiple Path Pruning s p'' p' p path' path assume: path is the optimal g f (p) = cost(s, p) + h(p) < cost(path) due to h being a lower bound cost(s, g) < cost(s, p ) + cost(p, g) due to optimality of path therefore cost(s, p) + h(p) = f (p) < cost(s, p ) + cost(p, g) therefore, we will never choose path while path is unexplored. A halts, as the costs of the paths on the frontier keeps increasing, and will eventually exceed any finite number. has path := {}; select and remove path n,..., n k from frontier; if n k / has path: add n k to has path ; return n,..., n k ; add n,..., n k, n to frontier;

How do we construct a heuristic? How do we construct a heuristic? Relax the game (make it simpler, easier). Can move tile from position A to position B if A is next to B (ignore whether or not position is blank). Can move tile from position A to position B if B is blank (ignore adjacency). Can move tile from position A to position B Relax the game (make it simpler, easier). Can move tile from position A to position B if A is next to B (ignore whether or not position is blank) leads to manhattan distance heuristic To solve the puzzle need to slide each tile into its final position Admissible How do we construct a heuristic? Graph for the Delivery Robot Relax the game (make it simpler, easier). Can move tile from position A to position B leads to misplaced tile heuristic To solve this problem need to move each tile into its final position Number of moves = number of misplaced tiles Admissible Topological Map of DC/MC cost = distance travelled heuristic = euclidean distance Summary of Search Strategies LE MC 5 TH JO H H OU H H H5 CF H8 Strategy Frontier Selection Halts? Space Time Depth-first Last node added No Linear Exp Breadth-first First node added Yes Exp Exp Heuristic depth-first Local min h(n) No Linear Exp Best-first Global min h(n) No Exp Exp Lowest-cost-first Minimal cost(n) Yes Exp Exp A Minimal f (n) Yes Exp Exp H6 H7 HE cost = number of doors heuristic? Locally in some region of the frontier Globally for all nodes on the frontier

Cycle Checking Multiple-Path Pruning s s A searcher can prune a path that ends in a node already on the path, without removing an optimal solution. Using depth-first methods, with the graph explicitly stored, this can be done in constant time (add a flag to each node) For other methods, the cost is linear in path length, since we have to check for cycles in the current path. Multiple path pruning: prune a path to node n that the searcher has already found a path to. Multiple-path pruning subsumes a cycle check. This entails storing all nodes it has found paths to. Want to guarantee that an optimal solution can still be found. Multiple-Path Pruning & Optimal Solutions Multiple-Path Pruning & A Problem: what if a subsequent path to n is shorter than the first path to n? remove all paths from the frontier that use the longer path. change the initial segment of the paths on the frontier to use the shorter path. ensure this doesn t happen. Make sure that the shortest path to a node is found first (lowest-cost-first search) Suppose path p to n was selected, but there is a shorter path to n. Suppose this shorter path is via path p on the frontier. Suppose path p ends at node n. cost(p) + h(n) cost(p ) + h(n ) because p was selected before p. cost(p ) + cost(n, n) < cost(p) because the path to n via p is shorter. cost(n, n) < cost(p) cost(p ) h(n ) h(n). You can ensure this doesn t occur if h(n ) h(n) cost(n, n). Monotone Restriction Iterative Deepening Heuristic function h satisfies the monotone restriction if h(m) h(n) cost(m, n) for every arc m, n. The heurstic estimate of the path cost is always less than the actual cost. If h satisfies the monotone restriction, A with multiple path pruning always finds the shortest path to a goal. This is a strengthening of the admissibility criterion. So far all search strategies that are guaranteed to halt use exponential space. Idea: let s recompute elements of the frontier rather than saving them. Look for paths of depth, then, then, then, etc. You need a depth-bounded depth-first searcher. If a path cannot be found at depth B, look for a path at depth B +. Increase the depth-bound when the search fails unnaturally (depth-bound was reached).

Iterative Deepening Complexity Depth-first Branch-and-Bound Complexity with solution at depth k & branching factor b: # times each node is expanded level breadth-first iterative deepening # nodes k b k b k b k k b k b k b k ( b b ) Way to combine depth-first search with heuristic information. Finds optimal solution. Most useful when there are multiple solutions, and we want an optimal one. Uses the space of depth-first search. Depth-first Branch-and-Bound Direction of Search Idea: maintain the cost of the lowest-cost path found to a goal so far, call this bound. If the search encounters a path p such that cost(p) + h(p) bound, path p can be pruned. If a non-pruned path to a goal is found, it must be better than the previous best path. This new solution is remembered and bound is set to its cost. The search can be a depth-first search to save space. The definition of searching is symmetric: find path from start nodes to goal node or from goal node to start nodes. Forward branching factor: number of arcs out of a node. Backward branching factor: number of arcs into a node. Search complexity is b n. Should use forward search if forward branching factor is less than backward branching factor, and vice versa. Note: sometimes when graph is dynamically constructed, you may not be able to construct the backwards graph. Bidirectional Search Island Driven Search You can search backward from the goal and forward from the start simultaneously. This wins as b k/ b k. This can result in an exponential saving in time and space. The main problem is making sure the frontiers meet. This is often used with one breadth-first method that builds a set of locations that can lead to the goal. In the other direction another method can be used to find a path to these interesting locations. Idea: find a set of islands between s and g. s i i... i m g There are m smaller problems rather than big problem. This can win as mb k/m b k. The problem is to identify the islands that the path must pass through. It is difficult to guarantee optimality. You can solve the subproblems using islands = hierarchy of abstractions.

Dynamic Programming Dynamic Programming - Example Start from goal and work backwards Compute the cost-to-goal at each node recursively Cost from n goal is Cost from m goal + cost from n to m dist(n) is cost-to-goal from node n, and cost(n, m) is cost to go from n to m { if n is goal dist(n) = min m (cost(n, m) + dist(m)) otherwise lab lab qmb hall seminar matthias () hall jesse dist(n) is a value function over nodes policy(n) is best m for each n, so best path is path(n, goal) = arg min(cost(n, m)+dist(m)), path(m, goal) m su problem: space needed to store entire graph Dynamic Programming - Example Dynamic Programming - Example lab lab qmb hall seminar () () matthias () hall jesse lab lab qmb hall seminar () () () hall matthias () jesse () su su Dynamic Programming - Example Dynamic Programming - Example () lab lab () qmb hall seminar () () () hall matthias () jesse () () lab () lab () qmb hall seminar () () () hall matthias () jesse () su () su

Next: Constraints (Poole & Mackworth chapter )