Problem solving and search. Chapter 3. Chapter 3 1

Similar documents
Artificial Intelligence Methods. Problem solving by searching

CS:4420 Artificial Intelligence

Artificial Intelligence

Deterministic Planning and State-space Search. Erez Karpas

22c:145 Artificial Intelligence

AI Programming CS S-06 Heuristic Search

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

State Space Representa,ons and Search Algorithms

Solving Problems By Searching

Last time: Summary. Last time: Summary

Local search algorithms. Chapter 4, Sections 3 4 1

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

Game Engineering CS F-12 Artificial Intelligence

Planning and search. Lecture 6: Search with non-determinism and partial observability

Searching in non-deterministic, partially observable and unknown environments

Searching in non-deterministic, partially observable and unknown environments

Problem-Solving via Search Lecture 3

Solutions. Dynamic Programming & Optimal Control ( ) Number of Problems: 4. Use only the provided sheets for your solutions.

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

Local and Online search algorithms

Introduction to Artificial Intelligence

New rubric: AI in the news

Analysis of Uninformed Search Methods

Artificial Intelligence Prof. Dr. Jürgen Dix

Artificial Intelligence

CSE 473: Artificial Intelligence Spring 2014

DATA Search I 魏忠钰. 复旦大学大数据学院 School of Data Science, Fudan University. March 7 th, 2018

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

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

IS-ZC444: ARTIFICIAL INTELLIGENCE

Graph Search Howie Choset

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

Pengju

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

CS 188: Artificial Intelligence Spring 2007

Local search and agents

Search' How"do"we"plan"our"holiday?" How"do"we"plan"our"holiday?" Many"problems"can"be"solved"by"search:"

Uninformed Search Lecture 4

Artificial Intelligence

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

CSC242: Artificial Intelligence. Lecture 4 Local Search

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

Artificial Intelligence Prof. Dr. Jürgen Dix

Learning in State-Space Reinforcement Learning CIS 32

A.I.: Beyond Classical Search

Beyond Classical Search

Iterative improvement algorithms. Beyond Classical Search. Outline. Example: Traveling Salesperson Problem

Introduction. An Introduction to Algorithms and Data Structures

Advanced topic: Space complexity

2 GRAPH AND NETWORK OPTIMIZATION. E. Amaldi Introduction to Operations Research Politecnico Milano 1

Time Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)

CS188: Artificial Intelligence, Fall 2009 Written 2: MDPs, RL, and Probability

Notes for Lecture Notes 2

CSE 105 THEORY OF COMPUTATION

Extended breadth-first search algorithm in practice

Principles of Computing, Carnegie Mellon University. The Limits of Computing

CS 662 Sample Midterm

CS360 Homework 12 Solution

ICS 252 Introduction to Computer Design

Intelligent Agents. Formal Characteristics of Planning. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University

Problem Solving as State Space Search

SOLUTION: SOLUTION: SOLUTION:

1 Computational Problems

CP405 Theory of Computation

Sums of Products. Pasi Rastas November 15, 2005

CITS4211 Mid-semester test 2011

Parsing with Context-Free Grammars

Multi-objective branch-and-cut algorithm and multi-modal traveling salesman problem

Algorithms 2/6/2018. Algorithms. Enough Mathematical Appetizers! Algorithm Examples. Algorithms. Algorithm Examples. Algorithm Examples

Appendix of Computational Protein Design Using AND/OR Branch and Bound Search

Problem. Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26

Motivation for introducing probabilities

IE418 Integer Programming

Alpha-Beta Pruning: Algorithm and Analysis

Section #2: Linear and Integer Programming

What is SSA? each assignment to a variable is given a unique name all of the uses reached by that assignment are renamed

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

Local Search and Optimization

A brief introduction to Conditional Random Fields

Simplex method(s) for solving LPs in standard form

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

Principles of AI Planning

A Decentralized Approach to Multi-agent Planning in the Presence of Constraints and Uncertainty

NP-Complete and Non-Computable Problems. COMP385 Dr. Ken Williams

Repetition Prepar Pr a epar t a ion for fo Ex am Ex

Introduction to Arti Intelligence

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

CSC 411 Lecture 3: Decision Trees

Name: UW CSE 473 Final Exam, Fall 2014

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Principles of AI Planning

Friday Four Square! Today at 4:15PM, Outside Gates

Single Source Shortest Paths

Dynamic Call Center Routing Policies Using Call Waiting and Agent Idle Times Online Supplement

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2

Chapter 3 Deterministic planning

Alpha-Beta Pruning: Algorithm and Analysis

CS 7180: Behavioral Modeling and Decisionmaking

6.01: Introduction to EECS I. Optimizing a Search

Local Search & Optimization

Transcription:

Problem solving and search Chapter 3 Chapter 3 1

eminders ssignment 0 due 5pm today ssignment 1 posted, due 2/9 Section 105 will move to 9-10am starting next week Chapter 3 2

Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms Outline Chapter 3 3

Problem-solving agents estricted form of general agent: function Simple-Problem-Solving-gent( percept) returns an action static: seq, an action sequence, initially empty state, some description of the current world state goal, a goal, initially null problem, a problem formulation state Update-State(state, percept) if seq is empty then goal Formulate-Goal(state) problem Formulate-Problem(state, goal) seq Search( problem) action ecommendation(seq, state) seq emainder(seq, state) return action Note: this is offline problem solving; solution executed eyes closed. Online problem solving involves acting without complete knowledge. Chapter 3 4

Example: omania On holiday in omania; currently in rad. Flight leaves tomorrow from Bucharest Formulate goal: be in Bucharest Formulate problem: states: various cities actions: drive between cities Find solution: sequence of cities, e.g., rad, Sibiu, Fagaras, Bucharest Chapter 3 5

75 rad 118 Example: omania 71 Oradea Neamt Zerind 151 87 140 Sibiu 99 Fagaras Iasi 92 Timisoara 111 Lugoj 70 Mehadia 75 Dobreta 120 80 imnicu Vilcea Pitesti 211 97 146 101 85 138 Craiova Bucharest 90 Giurgiu 142 98 Urziceni Vaslui Hirsova 86 Eforie Chapter 3 6

Problem types Deterministic, fully observable = single-state problem gent knows exactly which state it will be in; solution is a sequence Non-observable = conformant problem gent may have no idea where it is; solution (if any) is a sequence Nondeterministic and/or partially observable = contingency problem percepts provide new information about current state solution is a contingent plan or a policy often interleave search, execution Unknown state space = exploration problem ( online ) Chapter 3 7

Example: vacuum world Single-state, start in #5. Solution?? 1 2 3 4 5 6 7 8 Chapter 3 8

Example: vacuum world Single-state, start in #5. Solution?? [ight, Suck] 1 2 Conformant, start in {1, 2, 3, 4, 5, 6, 7, 8} e.g., ight goes to {2, 4, 6, 8}. Solution?? 3 4 5 6 7 8 Chapter 3 9

Example: vacuum world Single-state, start in #5. Solution?? [ight, Suck] 1 2 Conformant, start in {1, 2, 3, 4, 5, 6, 7, 8} e.g., ight goes to {2, 4, 6, 8}. Solution?? [ight, Suck, Left, Suck] Contingency, start in #5 Murphy s Law: Suck can dirty a clean carpet Local sensing: dirt, location only. Solution?? 3 4 5 6 7 8 Chapter 3 10

Example: vacuum world Single-state, start in #5. Solution?? [ight, Suck] 1 2 Conformant, start in {1, 2, 3, 4, 5, 6, 7, 8} e.g., ight goes to {2, 4, 6, 8}. Solution?? [ight, Suck, Left, Suck] Contingency, start in #5 Murphy s Law: Suck can dirty a clean carpet Local sensing: dirt, location only. Solution?? [ight, if dirt then Suck] 3 4 5 6 7 8 Chapter 3 11

Single-state problem formulation problem is defined by four items: initial state e.g., at rad successor function S(x) = set of action state pairs e.g., S(rad) = { rad Zerind, Zerind,...} goal test, can be explicit, e.g., x = at Bucharest implicit, e.g., N odirt(x) path cost (additive) e.g., sum of distances, number of actions executed, etc. c(x, a, y) is the step cost, assumed to be 0 solution is a sequence of actions leading from the initial state to a goal state Chapter 3 12

Selecting a state space eal world is absurdly complex state space must be abstracted for problem solving (bstract) state = set of real states (bstract) action = complex combination of real actions e.g., rad Zerind represents a complex set of possible routes, detours, rest stops, etc. For guaranteed realizability, any real state in rad must get to some real state in Zerind (bstract) solution = set of real paths that are solutions in the real world Each abstract action should be easier than the original problem! Chapter 3 13

Example: vacuum world state space graph L L S S L L L L S S S S L L S S states?? actions?? goal test?? path cost?? Chapter 3 14

Example: vacuum world state space graph L L S S L L L L S S S S L L S S states??: integer dirt and robot locations (ignore dirt amounts etc.) actions?? goal test?? path cost?? Chapter 3 15

Example: vacuum world state space graph L L S S L L L L S S S S L L S S states??: integer dirt and robot locations (ignore dirt amounts etc.) actions??: Left, ight, Suck, NoOp goal test?? path cost?? Chapter 3 16

Example: vacuum world state space graph L L S S L L L L S S S S L L S S states??: integer dirt and robot locations (ignore dirt amounts etc.) actions??: Left, ight, Suck, NoOp goal test??: no dirt path cost?? Chapter 3 17

Example: vacuum world state space graph L L S S L L L L S S S S L L S S states??: integer dirt and robot locations (ignore dirt amounts etc.) actions??: Left, ight, Suck, NoOp goal test??: no dirt path cost??: 1 per action (0 for NoOp) Chapter 3 18

states?? actions?? goal test?? path cost?? 7 5 8 Example: The 8-puzzle 2 4 51 2 3 6 4 5 6 3 1 7 8 Start State Goal State Chapter 3 19

Example: The 8-puzzle 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State states??: integer locations of tiles (ignore intermediate positions) actions?? goal test?? path cost?? Chapter 3 20

Example: The 8-puzzle 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State states??: integer locations of tiles (ignore intermediate positions) actions??: move blank left, right, up, down (ignore unjamming etc.) goal test?? path cost?? Chapter 3 21

Example: The 8-puzzle 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State states??: integer locations of tiles (ignore intermediate positions) actions??: move blank left, right, up, down (ignore unjamming etc.) goal test??: = goal state (given) path cost?? Chapter 3 22

Example: The 8-puzzle 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State states??: integer locations of tiles (ignore intermediate positions) actions??: move blank left, right, up, down (ignore unjamming etc.) goal test??: = goal state (given) path cost??: 1 per move [Note: optimal solution of n-puzzle family is NP-hard] Chapter 3 23

Example: robotic assembly P states??: real-valued coordinates of robot joint angles parts of the object to be assembled actions??: continuous motions of robot joints goal test??: complete assembly with no robot included! path cost??: time to execute Chapter 3 24

Tree search algorithms Basic idea: offline, simulated exploration of state space by generating successors of already-explored states (a.k.a. expanding states) function Tree-Search( problem, strategy) returns a solution, or failure initialize the search tree using the initial state of problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to strategy if the node contains a goal state then return the corresponding solution else expand the node and add the resulting nodes to the search tree end Chapter 3 25

Tree search example rad Sibiu Timisoara Zerind rad Fagaras Oradea imnicu Vilcea rad Lugoj rad Oradea Chapter 3 26

Tree search example rad Sibiu Timisoara Zerind rad Fagaras Oradea imnicu Vilcea rad Lugoj rad Oradea Chapter 3 27

Tree search example rad Sibiu Timisoara Zerind rad Fagaras Oradea imnicu Vilcea rad Lugoj rad Oradea Chapter 3 28

Implementation: states vs. nodes state is a (representation of) a physical configuration node is a data structure constituting part of a search tree includes parent, children, depth, path cost g(x) States do not have parents, children, depth, or path cost! parent, action State 5 4 Node depth = 6 g = 6 6 1 8 state 7 3 2 The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states. Chapter 3 29

Implementation: general 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 emove-front(fringe) if Goal-Test(problem, State(node)) then return node fringe Insertll(Expand(node, problem), fringe) function Expand( node, problem) returns a set of nodes successors the empty set for each action, result in Successor-Fn(problem, State[node]) do s a new Node Parent-Node[s] node; ction[s] action; State[s] result Path-Cost[s] Path-Cost[node] + Step-Cost(node, action, s) Depth[s] Depth[node] + 1 add s to successors return successors Chapter 3 30

Search strategies strategy is defined by picking the order of node expansion Strategies are evaluated along the following dimensions: completeness does it always find a solution if one exists? time complexity number of nodes generated/expanded space complexity maximum number of nodes in memory optimality does it always find a least-cost solution? Time and space complexity are measured in terms of b maximum branching factor of the search tree d depth of the least-cost solution m maximum depth of the state space (may be ) Chapter 3 31

Uninformed search strategies Uninformed strategies use only the information available in the problem definition Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search Chapter 3 32

Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end D E F G Chapter 3 33

Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end D E F G Chapter 3 34

Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end D E F G Chapter 3 35

Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end D E F G Chapter 3 36

Complete?? Properties of breadth-first search Chapter 3 37

Properties of breadth-first search Complete?? Yes (if b is finite) Time?? Chapter 3 38

Properties of breadth-first search Complete?? Yes (if b is finite) Time?? 1 + b + b 2 + b 3 +... + b d + b(b d 1) = O(b d+1 ), i.e., exp. in d Space?? Chapter 3 39

Properties of breadth-first search Complete?? Yes (if b is finite) Time?? 1 + b + b 2 + b 3 +... + b d + b(b d 1) = O(b d+1 ), i.e., exp. in d Space?? O(b d+1 ) (keeps every node in memory) Optimal?? Chapter 3 40

Properties of breadth-first search Complete?? Yes (if b is finite) Time?? 1 + b + b 2 + b 3 +... + b d + b(b d 1) = O(b d+1 ), i.e., exp. in d Space?? O(b d+1 ) (keeps every node in memory) Optimal?? Yes (if cost = 1 per step); not optimal in general Space is the big problem; can easily generate nodes at 100MB/sec so 24hrs = 8640GB. Chapter 3 41

Uniform-cost search Expand least-cost unexpanded node Implementation: fringe = queue ordered by path cost, lowest first Equivalent to breadth-first if step costs all equal Complete?? Yes, if step cost ɛ Time?? # of nodes with g cost of optimal solution, O(b C /ɛ ) where C is the cost of the optimal solution Space?? # of nodes with g cost of optimal solution, O(b C /ɛ ) Optimal?? Yes nodes expanded in increasing order of g(n) Chapter 3 42

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 43

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 44

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 45

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 46

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 47

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 48

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 49

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 50

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 51

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 52

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 53

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front D E F G H I J K L M N O Chapter 3 54

Complete?? Properties of depth-first search Chapter 3 55

Properties of depth-first search Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time?? Chapter 3 56

Properties of depth-first search Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time?? O(b m ): terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first Space?? Chapter 3 57

Properties of depth-first search Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time?? O(b m ): terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first Space?? O(bm), i.e., linear space! Optimal?? Chapter 3 58

Properties of depth-first search Complete?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path complete in finite spaces Time?? O(b m ): terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first Space?? O(bm), i.e., linear space! Optimal?? No Chapter 3 59

Depth-limited search = depth-first search with depth limit l, i.e., nodes at depth l have no successors ecursive implementation: function Depth-Limited-Search( problem, limit) returns soln/fail/cutoff ecursive-dls(make-node(initial-state[problem]), problem, limit) function ecursive-dls(node, problem, limit) returns soln/fail/cutoff cutoff-occurred? false if Goal-Test(problem, State[node]) then return node else if Depth[node] = limit then return cutoff else for each successor in Expand(node, problem) do result ecursive-dls(successor, problem, limit) if result = cutoff then cutoff-occurred? true else if result failure then return result if cutoff-occurred? then return cutoff else return failure Chapter 3 60

Iterative deepening search function Iterative-Deepening-Search( problem) returns a solution inputs: problem, a problem for depth 0 to do result Depth-Limited-Search( problem, depth) if result cutoff then return result end Chapter 3 61

Iterative deepening search l = 0 Limit = 0 Chapter 3 62

Iterative deepening search l = 1 Limit = 1 Chapter 3 63

Iterative deepening search l = 2 Limit = 2 D E F G D E F G D E F G D E F G D E F G D E F G D E F G D E F G Chapter 3 64

Iterative deepening search l = 3 Limit = 3 D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O Chapter 3 65

Properties of iterative deepening search Complete?? Chapter 3 66

Properties of iterative deepening search Complete?? Yes Time?? Chapter 3 67

Properties of iterative deepening search Complete?? Yes Time?? (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space?? Chapter 3 68

Properties of iterative deepening search Complete?? Yes Time?? (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space?? O(bd) Optimal?? Chapter 3 69

Properties of iterative deepening search Complete?? Yes Time?? (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space?? O(bd) Optimal?? Yes, if step cost = 1 Can be modified to explore uniform-cost tree Numerical comparison for b = 10 and d = 5, solution at far right leaf: N(IDS) = 50 + 400 + 3, 000 + 20, 000 + 100, 000 = 123, 450 N(BFS) = 10 + 100 + 1, 000 + 10, 000 + 100, 000 + 999, 990 = 1, 111, 100 IDS does better because other nodes at depth d are not expanded BFS can be modified to apply goal test when a node is generated Chapter 3 70

Summary of algorithms Criterion Breadth- Uniform- Depth- Depth- Iterative First Cost First Limited Deepening Complete? Yes Yes No Yes, if l d Yes Time b d+1 b C /ɛ b m b l b d Space b d+1 b C /ɛ bm bl bd Optimal? Yes Yes No No Yes Chapter 3 71

epeated states Failure to detect repeated states can turn a linear problem into an exponential one! B B B C C C C C D Chapter 3 72

Graph search function Graph-Search( problem, fringe) returns a solution, or failure closed an empty set fringe Insert(Make-Node(Initial-State[problem]), fringe) loop do if fringe is empty then return failure node emove-front(fringe) if Goal-Test(problem, State[node]) then return node if State[node] is not in closed then add State[node] to closed fringe Insertll(Expand(node, problem), fringe) end Chapter 3 73

Summary Problem formulation usually requires abstracting away real-world details to define a state space that can feasibly be explored Variety of uninformed search strategies Iterative deepening search uses only linear space and not much more time than other uninformed algorithms Graph search can be exponentially more efficient than tree search Chapter 3 74