Problem solving and search

Slides:



Advertisements
Similar presentations
Artificial Intelligent
Advertisements

Solving problems by searching Chapter 3. Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms.
INTRODUÇÃO AOS SISTEMAS INTELIGENTES
Additional Topics ARTIFICIAL INTELLIGENCE
Announcements Course TA: Danny Kumar
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
Artificial Intelligence Problem Solving Eriq Muhammad Adams
Blind Search1 Solving problems by searching Chapter 3.
Search Strategies Reading: Russell’s Chapter 3 1.
May 12, 2013Problem Solving - Search Symbolic AI: Problem Solving E. Trentin, DIISM.
1 Chapter 3 Solving Problems by Searching. 2 Outline Problem-solving agentsProblem-solving agents Problem typesProblem types Problem formulationProblem.
Solving Problem by Searching Chapter 3. Outline Problem-solving agents Problem formulation Example problems Basic search algorithms – blind search Heuristic.
Solving problems by searching Chapter 3. Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms.
Touring problems Start from Arad, visit each city at least once. What is the state-space formulation? Start from Arad, visit each city exactly once. What.
Artificial Intelligence for Games Uninformed search Patrick Olivier
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt.
UNINFORMED SEARCH Problem - solving agents Example : Romania  On holiday in Romania ; currently in Arad.  Flight leaves tomorrow from Bucharest.
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
CHAPTER 3 CMPT Blind Search 1 Search and Sequential Action.
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
CS 380: Artificial Intelligence Lecture #3 William Regli.
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
Solving problems by searching
1 Solving problems by searching Chapter 3. 2 Why Search? To achieve goals or to maximize our utility we need to predict what the result of our actions.
Solving problems by searching This Lecture Read Chapters 3.1 to 3.4 Next Lecture Read Chapter 3.5 to 3.7 (Please read lecture topic material before and.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
1 Solving problems by searching This Lecture Chapters 3.1 to 3.4 Next Lecture Chapter 3.5 to 3.7 (Please read lecture topic material before and after each.
AI in game (II) 권태경 Fall, outline Problem-solving agent Search.
Carla P. Gomes CS4700 CS 4700: Foundations of Artificial Intelligence Prof. Carla P. Gomes Module: Search I (Reading R&N: Chapter.
1 Solving problems by searching 171, Class 2 Chapter 3.
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
SOLVING PROBLEMS BY SEARCHING Chapter 3 August 2008 Blind Search 1.
A General Introduction to Artificial Intelligence.
Problem Solving Agents
Solving problems by searching 1. Outline Problem formulation Example problems Basic search algorithms 2.
CPSC 420 – Artificial Intelligence Texas A & M University Lecture 3 Lecturer: Laurie webster II, M.S.S.E., M.S.E.e., M.S.BME, Ph.D., P.E.
Pengantar Kecerdasan Buatan
Problem Solving as Search. Problem Types Deterministic, fully observable  single-state problem Non-observable  conformant problem Nondeterministic and/or.
Problem Solving by Searching
Solving problems by searching A I C h a p t e r 3.
WEEK 5 LECTURE -A- 23/02/2012 lec 5a CSC 102 by Asma Tabouk Introduction 1 CSC AI Basic Search Strategies.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Artificial Intelligence Solving problems by searching.
Lecture 3: Uninformed Search
Solving problems by searching
Problem Solving Agents
EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS
ECE 448 Lecture 4: Search Intro
Uninformed Search Chapter 3.4.
Uninformed Search Strategies
Problem Solving as Search
AI I: problem-solving and search
Artificial Intelligence
Solving problems by searching
Solving problems by searching
Lecture 1B: Search.
Problem Solving and Searching
Searching for Solutions
Artificial Intelligence
Problem Solving and Searching
Solving problems by searching
Solving problems by searching
Solving problems by searching
Solving Problems by Searching
CS440/ECE 448 Lecture 4: Search Intro
Solving problems by searching
Presentation transcript:

Problem solving and search

Objective In which we see how an agent can find a sequence of actions that achieves its goals when no single action will do.

Revision Definition of AI? Turing Test? Intelligent Agents: Anything that can be viewed as perceiving its environment through sensors and acting upon that environment through its effectors to maximize progress towards its goals. PAGE (Percepts, Actions, Goals, Environment) Described as a Perception (sequence) to Action Mapping: f : P* A Using look-up-table, closed form, etc. Agent Types: Reflex, goal-based, utility-based Rational Action: The action that maximizes the expected value of the performance measure given the percept sequence to date

Outline Problem-Solving Agents Searching for Solutions Uninformed Search Strategies Informed Search Strategies Heuristic Functions

Problem-Solving Agents Example: Measuring problem Problem: Using these three buckets, measure 7 liters of water. 9L 5L 3L

Example: Measuring problem One solution 9L a b c Start 3 5L 3L

Example: Measuring problem Another solution 9L a b c Start 5 5L 3L

Which solution to choose? a b c Start 3 6 1 5 7 a b c Start 5 3 2 7

Problem-Solving Agents function Simple-Problem-Solving-Agent( 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.

Example: Buckets Measure 7 liters of water using a 3-liter, a 5-liter, and a 9- liter buckets. Formulate goal: Have 7 liters of water in 9-liter bucket —Formulate problem: States: amount of water in the buckets Operators: Fill bucket from source, empty bucket Find solution: sequence of operators that bring you from current state to the goal state

Example: Romania On holiday in Romania; currently in Arad. 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., Arad, Sibiu, Fagaras, Bucharest

Example: Romania

Problem types Deterministic, fully observable  single-state problem Agent knows exactly which state it will be in; solution is a sequence Non-observable  conformant problem Agent 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")

Example: vacuum world Single-state, start in #5. Solution??

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

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

Problem Formulation A search problem consists of: A state space A successor function A start state and a goal test A solution is a sequence of actions (a plan) which transforms the start state to a goal state

Single-state problem formulation A problem is defined by four items: initial state e.g., “at Arad" successor function S(x) = set of action-state pairs e.g., S(Arad) = { (Arad  Zerind;Zerindi) … } goal test, can be explicit, e.g., x = “at Bucharest" implicit, e.g., NoDirt(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 A solution is a sequence of actions leading from the initial state to a goal state

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

Example: vacuum world state space graph Actions?? Goal test?? Path cost??

Example: vacuum world state space graph States?? integer dirt and robot locations (ignore dirt amounts etc.) Actions?? Left, Right, Suck, NoOp Goal test?? no dirt Path cost?? 1 per action (0 for NoOp)

Example: The 8-puzzle States?? Actions?? Goal test?? Path cost??

Example: The 8-puzzle 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

Example: The 8-puzzle Why search algorithms? 8-puzzle has 362,880 states 15-puzzle has 10^12 states 24-puzzle has 10^25 states So, we need a principled way to look for a solution in these huge search spaces…

Example: robotic assembly 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

Search trees A search tree: This is a “what if” tree of plans and outcomes Start state at the root node Children correspond to successors Nodes labeled with states, correspond to PLANS to those states For most problems, can never build the whole tree So, have to find ways to use only the important parts!

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 frontier using the initial state of problem loop do if the frontier is empty then return failure choose a leaf node for expansion according to strategy if the node contains a goal state then return the corresponding solution expand the chosen node, adding the resulting nodes to the tree end

Tree search example

Tree search example

Tree search example

Implementation: states vs. nodes A state is a (representation of) a physical configuration A 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! The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states.

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  InsertAll(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; Action[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

Evaluation of search strategies A 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 infinity)

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

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

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

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

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

Properties of breadth-first search Complete?? Yes (if b is finite) Time?? 1 + b + b2 + b3 + … + bd + b(bd-1) = O(b1d+), i.e., exp. in d Space?? O(bd+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. — Search algorithms are commonly evaluated according to the following four criteria: ◦ Completeness: does it always find a solution if one exists? ◦ Time complexity: how long does it take as function of num. of nodes? ◦ Space complexity: how much memory does it require? ◦ Optimality: does it guarantee the least-cost solution?   — Time and space complexity are measured in terms of: ◦ b – max branching factor of the search tree ◦ d – depth of the least-cost solution ◦ m – max depth of the search tree (may be infinity)

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, where C* is the cost of the optimal solution Space?? # of nodes with g ≤ cost of optimal solution, Optimal?? Yes -- nodes expanded in increasing order of g(n)

Romania with step costs in km

Uniform-cost search

Uniform-cost search

Uniform-cost search

Depth-first Search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first Search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first Search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first Search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

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(bm): 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

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

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

Iterative deepening search l = 0

Iterative deepening search l = 1

Iterative deepening search l = 2

Iterative deepening search l = 3

Properties of iterative deepening search Complete?? Yes Time?? (d + 1)b0 + db1 + (d -1)b2 + : : : + bd = O(bd) 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

Bi-Directional Search Both search forward from initial state, and backwards from goal. Stop when the two searches meet in the middle.  Problem: how do we search backwards from goal?? predecessor of node n = all nodes that have n as successor this may not always be easy to compute! if several goal states, apply predecessor function to them just as we applied successor (only works well if goals are explicitly known; may be difficult if goals only characterized implicitly).

Bi-Directional Search Problem: how do we search backwards from goal?? (cont.) ◦ … ◦ for bidirectional search to work well, there must be an efficient way to check whether a given node belongs to the other search tree. select a given search algorithm for each half.

Bi-Directional Search Queue 1 : path only containing the root Queue 2 : path only containing the goal While both queues are not empty and both queues do not share a state Do remove their first paths create their new paths (to all children); reject their new paths with loops; add their new paths to back; IF QUEUE1 and QUEUE2 share a state Then success Else failure

Bi-Directional Search Completeness: Yes,   Time complexity: 2*O(b d/2) = O(b d/2) Space complexity: O(b d/2) Optimality: Yes  To avoid one by one comparison, we need a hash table of size O(b d/2) If hash table is used, the cost of comparison is O(1)

Bi-Directional Search

Bi-Directional Search — Bidirectional search merits: ◦ Big difference for problems with branching factor b in both directions – A solution of length d will be found in O(2bd/2) = O(bd/2) – For b = 10 and d = 6, only 2,222 nodes are needed instead of 1,111,111 for breadth-first search

Bi-Directional Search — Bidirectional search issues ◦ Predecessors of a node need to be generated – Difficult when operators are not reversible ◦ What to do if there is no explicit list of goal states? ◦ For each node: check if it appeared in the other search – Needs a hash table of O(bd/2) ◦ What is the best search strategy for the two searches?

Comparison

Repeated states Failure to detect repeated states can turn a linear problem into an exponential one!

Graph Search

Graph Search In BFS we shouldn’t bother expanding the filled-out nodes (why?)

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