Problem solving and search

Similar documents
Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 2: Search 1.

Artificial Intelligence: Search Part 1: Uninformed graph search

Problem solving and search: Chapter 3, Sections 1 5

Problem solving and search: Chapter 3, Sections 1 5

Problem solving and search

Problem solving and search

Problem solving and search

Reminders. Problem solving and search. Problem-solving agents. Outline. Assignment 0 due 5pm today

Problem-solving agents. Problem solving and search. Example: Romania. Reminders. Example: Romania. Outline. Chapter 3

Outline. Problem solving and search. Problem-solving agents. Example: Romania. Example: Romania. Problem types. Problem-solving agents.

Problem solving by search

Planning and search. Lecture 1: Introduction and Revision of Search. Lecture 1: Introduction and Revision of Search 1

Problem solving and search

Problem solving and search

Problem solving and search

Artificial Intelligence Problem Solving and Uninformed Search

Problem solving and search

Multiagent Systems Problem Solving and Uninformed Search

Problem Solving and Search. Chapter 3

Artificial Intelligence

CS:4420 Artificial Intelligence

Solving problems by searching

Solving Problems by Searching. AIMA Sections , 3.6

Outline. Solving problems by searching. Prologue. Example: Romania. Uninformed search

Outline. Solving problems by searching. Problem-solving agents. Example: Romania

Chapter 2. Blind Search 8/19/2017

Solving problems by searching

CS 380: Artificial Intelligence Lecture #3

Problem-solving agents. Solving Problems by Searching. Outline. Example: Romania. Chapter 3

Solving problems by searching. Chapter 3

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

AI: problem solving and search

Robot Programming with Lisp

Solving problems by searching

Solving problems by searching

4. Solving Problems by Searching

Week 3: Path Search. COMP9414/ 9814/ 3411: Artificial Intelligence. Motivation. Example: Romania. Romania Street Map. Russell & Norvig, Chapter 3.

Solving Problem by Searching. Chapter 3

KI-Programmierung. Basic Search Algorithms

CS 8520: Artificial Intelligence

Artificial Intelligence

A2 Uninformed Search

Example: The 8-puzzle. A2 Uninformed Search. It can be generalized to 15-puzzle, 24-puzzle, or. (n 2 1)-puzzle for n 6. Department of Computer Science

ITCS 6150 Intelligent Systems. Lecture 3 Uninformed Searches

Solving Problems by Searching

CS486/686 Lecture Slides (c) 2015 P.Poupart

CS486/686 Lecture Slides (c) 2014 P.Poupart

Artificial Intelligence Uninformed search

Artificial Intelligence

Outline. Solving Problems by Searching. Introduction. Problem-solving agents

Uninformed Search strategies. AIMA sections 3.4,3.5

Informed search algorithms

Solving problems by searching

Introduction to Artificial Intelligence. Informed Search

Informed search algorithms. Chapter 4, Sections 1 2 1

Problem Solving by Searching

AGENTS AND ENVIRONMENTS. What is AI in reality?

Uninformed Search. Problem-solving agents. Tree search algorithms. Single-State Problems

AGENTS AND ENVIRONMENTS. What is AI in reality?

Chapter 3 Solving problems by searching

Pengju XJTU 2016

Artificial Intelligence: Search Part 2: Heuristic search

Solving Problems by Searching

Solving Problems by Searching

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 3: Search 2.

CS:4420 Artificial Intelligence

COSC343: Artificial Intelligence

Planning, Execution & Learning 1. Heuristic Search Planning

Solving Problems using Search

Pengju

Solving Problems: Blind Search

Problem Solving and Search

Outline. Informed search algorithms. Best-first search. Review: Tree search. A search Heuristics. Chapter 4, Sections 1 2 4

Problem solving Basic search. Example: Romania. Example: Romania. Problem types. Intelligent Systems and HCI D7023E. Single-state problem formulation

Seminar: Search and Optimization

Informed search algorithms

Informed Search and Exploration

Informed Search and Exploration

Chapter 3. A problem-solving agent is a kind of goal-based agent. It decide what to do by finding sequences of actions that lead to desirable states.

ARTIFICIAL INTELLIGENCE SOLVING PROBLEMS BY SEARCHING. Chapter 3

PEAS: Medical diagnosis system

Search I. slides from: Padhraic Smyth, Bryan Low, S. Russell and P. Norvig

Informed Search and Exploration

Set 2: State-spaces and Uninformed Search. ICS 271 Fall 2015 Kalev Kask

Search EECS 395/495 Intro to Artificial Intelligence

Search EECS 348 Intro to Artificial Intelligence

Artificial Intelligence. Informed search methods

Chapter3. Problem-Solving Agents. Problem Solving Agents (cont.) Well-defined Problems and Solutions. Example Problems.

ARTIFICIAL INTELLIGENCE. Pathfinding and search

Artificial Intelligence

Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu. Blind Searches

Search. Intelligent agents. Problem-solving. Problem-solving agents. Road map of Romania. The components of a problem. that will take me to the goal!

ARTIFICIAL INTELLIGENCE (CSC9YE ) LECTURES 2 AND 3: PROBLEM SOLVING

TDT4136 Logic and Reasoning Systems

COMP9414/ 9814/ 3411: Artificial Intelligence. 5. Informed Search. Russell & Norvig, Chapter 3. UNSW c Alan Blair,

Overview. Path Cost Function. Real Life Problems. COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Solving Problems by Searching (Blindly)

Solving Problems by Searching. Artificial Intelligence Santa Clara University 2016

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Transcription:

Problem solving and search hapter 3 hapter 3 1

Outline Problem-solving agents Problem types Problem formulation Example problems asic search algorithms hapter 3 3

Restricted form of general agent: Problem-solving agents 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 Recommendation(seq, state) seq Remainder(seq, state) return action Note: this is offline problem solving; solution executed eyes closed. Online problem solving involves acting without complete knowledge. hapter 3 4

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

71 Oradea Example: Romania Neamt Zerind 75 rad 140 118 Timisoara 111 70 75 Dobreta 151 Sibiu 99 Fagaras 80 Rimnicu Vilcea Lugoj Mehadia 120 Pitesti 211 97 146 101 85 138 ucharest raiova 90 Giurgiu 87 Iasi 92 142 98 Urziceni Vaslui Hirsova 86 Eforie hapter 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 ) hapter 3 7

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 ucharest 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 hapter 3 12

Selecting a state space Real 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! hapter 3 13

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?? actions?? goal test?? path cost?? hapter 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?? hapter 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?? hapter 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?? hapter 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] hapter 3 23

Example: robotic assembly P R R R R R 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 hapter 3 24

Tree search algorithms asic 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 hapter 3 25

Tree search example rad Sibiu Timisoara Zerind rad Fagaras Oradea Rimnicu Vilcea rad Lugoj rad Oradea hapter 3 26

Tree search example rad Sibiu Timisoara Zerind rad Fagaras Oradea Rimnicu Vilcea rad Lugoj rad Oradea hapter 3 27

Tree search example rad Sibiu Timisoara Zerind rad Fagaras Oradea Rimnicu Vilcea rad Lugoj rad Oradea hapter 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 6 4 1 8 Node depth = 6 g = 6 7 3 2 state The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states. hapter 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 Remove-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-ost[s] Path-ost[node] + Step-ost(node, action, s) Depth[s] Depth[node] + 1 add s to successors return successors hapter 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 ) hapter 3 31

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

Expand shallowest unexpanded node readth-first search Implementation: fringe is a FIFO queue, i.e., new successors go at end hapter 3 33

Expand shallowest unexpanded node readth-first search Implementation: fringe is a FIFO queue, i.e., new successors go at end hapter 3 34

Expand shallowest unexpanded node readth-first search Implementation: fringe is a FIFO queue, i.e., new successors go at end hapter 3 35

Expand shallowest unexpanded node readth-first search Implementation: fringe is a FIFO queue, i.e., new successors go at end hapter 3 36

Properties of breadth-first search omplete?? hapter 3 37

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

Properties of breadth-first search omplete?? 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?? hapter 3 39

Properties of breadth-first search omplete?? 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?? hapter 3 40

Properties of breadth-first search omplete?? 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 100M/sec so 24hrs = 8640G. hapter 3 41

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

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

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

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

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

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

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

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

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

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

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

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

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

Properties of depth-first search omplete?? hapter 3 55

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

Properties of depth-first search omplete?? 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?? hapter 3 57

Properties of depth-first search omplete?? 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?? hapter 3 58

Properties of depth-first search omplete?? 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 hapter 3 59

Depth-limited search = depth-first search with depth limit l, i.e., nodes at depth l have no successors Recursive implementation: function Depth-Limited-Search( problem, limit) returns soln/fail/cutoff Recursive-DLS(Make-Node(Initial-State[problem]), problem, limit) function Recursive-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 Recursive-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 hapter 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 hapter 3 61

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

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

Iterative deepening search l = 2 Limit = 2 hapter 3 64

Iterative deepening search l = 3 Limit = 3 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 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 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 hapter 3 65

omplete?? Properties of iterative deepening search hapter 3 66

Properties of iterative deepening search omplete?? Yes Time?? hapter 3 67

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

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

Properties of iterative deepening search omplete?? 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 an 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(FS) = 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 FS can be modified to apply goal test when a node is generated hapter 3 70

Summary of algorithms riterion readth- Uniform- Depth- Depth- Iterative First ost First Limited Deepening omplete? Yes Yes No Yes, if l d Yes Time b d+1 b /ɛ b m b l b d Space b d+1 b /ɛ bm bl bd Optimal? Yes Yes No No Yes hapter 3 71

Repeated states Failure to detect repeated states can turn a linear problem into an exponential one! D hapter 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 Remove-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 hapter 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 hapter 3 74