Solving Problems by Searching

Slides:



Advertisements
Similar presentations
Cooperating Intelligent Systems
Advertisements

Uninformed search strategies
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
1 Lecture 3 Uninformed Search. 2 Uninformed search strategies Uninformed: While searching you have no clue whether one non-goal state is better than any.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
CS 480 Lec 3 Sept 11, 09 Goals: Chapter 3 (uninformed search) project # 1 and # 2 Chapter 4 (heuristic search)
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 Blind (Uninformed) Search (Where we systematically explore alternatives) R&N: Chap. 3, Sect. 3.3–5.
Solving Problem by Searching Chapter 3. Outline Problem-solving agents Problem formulation Example problems Basic search algorithms – blind search Heuristic.
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.
CSC 423 ARTIFICIAL INTELLIGENCE
Artificial Intelligence (CS 461D)
Feng Zhiyong Tianjin University Fall  datatype PROBLEM ◦ components: INITIAL-STATE, OPERATORS, GOAL- TEST, PATH-COST-FUNCTION  Measuring problem-solving.
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.
CS 380: Artificial Intelligence Lecture #3 William Regli.
Review: Search problem formulation
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2004.
Artificial Intelligence
Toy Problem: Missionaries and Cannibals
Artificial Intelligence Chapter 3: Solving Problems by Searching
1 Solving Problems by Searching. 2 Terminology State State Space Initial State Goal Test Action Step Cost Path Cost State Change Function State-Space.
Problem Spaces & Search CSE 473. © Daniel S. Weld Topics Agents & Environments Problem Spaces Search & Constraint Satisfaction Knowledge Repr’n.
1 Lecture 3 Uninformed Search. 2 Complexity Recap (app.A) We often want to characterize algorithms independent of their implementation. “This algorithm.
1 Lecture 3 Uninformed Search
For Friday Finish chapter 3 Homework: –Chapter 3, exercise 6 –May be done in groups. –Clarification on part d: an “action” must be running the program.
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 Problem Solving and Searching CS 171/271 (Chapter 3) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Solving Problems by Searching CPS Outline Problem-solving agents Example problems Basic search algorithms.
Problem Solving and Search Andrea Danyluk September 11, 2013.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
CS.462 Artificial Intelligence SOMCHAI THANGSATHITYANGKUL Lecture 02 : Search.
Search Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Dan Klein, Stuart Russell, Andrew Moore, Svetlana Lazebnik,
Artificial Intelligence
AI in game (II) 권태경 Fall, outline Problem-solving agent Search.
For Friday Finish reading chapter 4 Homework: –Lisp handout 4.
For Monday Read chapter 4, section 1 No homework..
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
Lecture 3: Uninformed Search
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
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 by search Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
For Friday Read chapter 4, sections 1 and 2 Homework –Chapter 3, exercise 7 –May be done in groups.
1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;
Goal-based Problem Solving Goal formation Based upon the current situation and performance measures. Result is moving into a desirable state (goal state).
Solving problems by searching 1. Outline Problem formulation Example problems Basic search algorithms 2.
Uninformed search strategies A search strategy is defined by picking the order of node expansion Uninformed search strategies use only the information.
Problem Solving as Search. Problem Types Deterministic, fully observable  single-state problem Non-observable  conformant problem Nondeterministic and/or.
1 Solving Problems by Searching. 2 Terminology State State Space Goal Action Cost State Change Function Problem-Solving Agent State-Space Search.
Implementation: General Tree Search
Ch. 3 – Search Supplemental slides for CSE 327 Prof. Jeff Heflin.
Solving problems by searching A I C h a p t e r 3.
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
Problem Solving Agents
CSE 473 Artificial Intelligence Oren Etzioni
Problem Solving by Searching
Artificial Intelligence (CS 370D)
Searching for Solutions
Problem Spaces & Search
HW 1: Warmup Missionaries and Cannibals
Problem Spaces & Search
HW 1: Warmup Missionaries and Cannibals
Presentation transcript:

Solving Problems by Searching

Terminology State State Space Initial State Goal Test Action Step Cost Path Cost State Change Function State-Space Search

Formal State-Space Model Problem = (S, s, A, f, g, c) S = state space s = initial state A = set of actions f = state change function g = goal test function c = cost function a c(a) x y

State-Space Model (cont) Problem = (S, s, A, f, g, c) How do we define a solution? How about an optimal solution?

3 Coins Problem A Very Small State Space Problem There are 3 (distinct) coins: coin1, coin2, coin3. The initial state is H H T The legal operations are to turn over exactly one coin. 1 (flip coin1), 2 (flip coin2), 3 (flip coin3) There are two goal states: H H H T T T What are S, s, A, f, g, c ?

3 Coins Problem: Get from HHT to either HHH or TTT via operators: flip coin 1, flip coin 2, and flip coin 3 (flip = turn over) S s A f g c

State-Space Graph 1 HHT THT 3 2 3 THH HTT 2 1 1 2 3 HHH TTT 2 3 TTH HTH 1 What are some solutions? What if the problem is changed to allow only 3 actions?

Modified State-Space Problem How would you define a state for the new problem requiring exactly 3 actions? How do you define the operations (1, 2, 3) with this new state definition?

Modified State-Space Problem What do the paths to the goal states look like now? (H,H,T,0) ->

How do we build a search tree for the modified 3 coins problem? initial state 1 2 3

The 8-Puzzle Problem 1 2 3 8 B 4 7 6 5 B 1 2 3 4 5 6 7 8 one initial 1 2 3 8 B 4 7 6 5 B 1 2 3 4 5 6 7 8 one initial state goal state B=blank What data structure easily represents a state? How many possible states are there? How would you specify the state-change function? What is the path cost function? uniform cost (=1) 5. What is the complexity of the search?

Search Tree Example: Fragment of 8-Puzzle Problem Space

Another Example: N Queens Place exactly one Q in each column so that no two Q’s are in the same row or diagonal Input: Set of states Operators [and costs] Start state Goal state (test) Output Q

Example: Route Planning Find the shortest route from the starting city to the goal city given roads and distances. Input: Set of states Operators [and costs] Start state Goal state (test) Output: States = cities Start state = starting city Goal state test = is state the destination city? Operators = move to an adjacent city; cost = distance Output: a shortest path from start state to goal state SUPPOSE WE REVERSE START AND GOAL STATES?

Search in AI Search in Data Structures You’re given an existent tree. You search it in different orders. It resides in memory. Search in Artificial Intelligence The tree does not exist. You have to generate it as you go. For realistic problems, it does not fit in memory.

Search Strategies (Ch 3) Uninformed Search The search is blind, only the order of search is important. Informed Search The search uses a heuristic function to estimate the goodness of each state.

Depth-First Search by Recursion Depth-First Search by Recursion* You will use this for Missionary-Cannibal Problem. Search is a recursive procedure that is called with the start node and has arg s. It checks first if s is the goal. It also checks if s is illegal or too deep. If neither, it generates the list L of successors of its argument s. It iterates through list L, calling itself recursively for each state in L.

Depth-First Search by Recursion start state (root) successor list of root successor list of first successor of root

The Missionaries and Cannibals Problem (from text problem 3.9) Three missionaries and three cannibals are on one side (left) of a river, along with a boat that can hold one or two people. If there are ever more cannibals than missionaries on one side of the river, the cannibals will eat the missionaries. (We call this a “dead” state.) Find a way to get everyone to the other side (right), without ever leaving a group of missionaries in one place (left or right) outnumbered by the cannibals in that place, ie. without anyone getting eaten.

Missionaries and Cannibals Problem

Missionaries and Cannibals Problem Left Bank Right Bank River

Missionary and Cannibals Notes Define your state as (M,C,S) M: number of missionaries on left bank C: number of cannibals on left bank S: side of the river that the boat is on When the boat is moving, we are in between states. When it arrives, everyone gets out. (3,3,L)  (3,1,R) What action did I apply?

What are all the actions? Left to right MCR MMR ? Right to left MCL MML

When is a state considered “DEAD”? There are more cannibals than missionaries on the left bank. (Bunga-Bunga) There are more cannibals than missionaries on the right bank. (Bunga-Bunga) There is an ancestor state of this state that is exactly the same as this state. (Why?)

Same Ancestor State Stack (3,3,L) (3,1,R) (3,3,L) (3,1,R) (3,3,L) X

Assignment Implement and solve the problem You must use Python You MUST use recursive depth-first blind search. You must detect illegal states (cannibals can eat missionaries) and repeated states along a path. You must keep going and print out all four solutions. You must use Python Full instructions will be on the assignment page.

Warning The material that follows is NOT for HW1. HW1 is to be done with a recursive, depth-first search. It does not use the general paradigm we are about to go into. It is a beginning exercise. You will use the more general framework along with a heuristic in HW2.

General Search Paradigm (Figure 3.7 in text) function TREE-SEARCH(problem) returns solution or failure initialize frontier using the initial state of problem loop do if frontier is empty then return failure choose a leaf node and remove it from frontier if the node contains a goal state then return the solution expand the node, adding the resulting nodes to frontier What is the frontier? How do we choose? What does expand mean?

General Search Paradigm (Figure 3.7 in text) function GRAPH-SEARCH(problem) returns solution or failure initialize frontier using the initial state of problem initialize the explored set to be empty loop do if frontier is empty then return failure choose a leaf node and remove it from frontier if the node contains a goal state then return the solution add the node to the explored set expand the node, adding the resulting nodes to frontier only if they are not in the frontier or the explored set OPEN CLOSED

Basic Idea Start with the initial state Maintain a (general) queue of states to visit Depth-First search: the queue is LIFO (stack) Breadth-First search: the queue is FIFO (queue) Uniform-Cost search: the queue is ordered by lowest path cost g (path from start to node) Depth-Limited search: DFS with a depth limit Iterative-Deepening search: DFS with depth limit sequence 1, 2, 3, …. till memory runs out Bidirectional Search

Performance Criteria Completeness: Does it find a solution when there is one? Optimality: Does it find the optimal solution in terms of cost? Time complexity: How long does it take to find a solution Space Complexity: How much memory is needed?

Breadth-First Search Maintain FIFO queue of nodes to visit Evaluation (branching factor b; solution at depth d) Complete? Time Complexity? Space? a Yes (if enough memory) b c O(b^d) g h d e f O(b^d)

Depth-First Search Maintain stack of nodes to visit Evaluation (branching factor b; solution at depth d) Complete? Time Complexity? Space ? a Not for infinite spaces b e O(b^d) g h c d f O(d)

Iterative Deepening Search DFS with depth limit; incrementally grow limit l = 0, 1, 2, ... Evaluation (for solution at depth d) Complete? Time Complexity? Space Complexity? a b e Yes, if l >= d c f d i O(b^d) g h j k l O(d)

Cost of Iterative Deepening b ratio IDS to DFS 2 3:1 3 2:1 5 1.5:1 10 1.2:1 25 1.08:1 100 1.02:1

Forwards vs. Backwards start end

vs. Bidirectional Replace the goal test with a check to see if the frontiers of the two searches intersect. How might this be done efficiently?

Uniform-Cost Search Expand the node n with the lowest path cost g(n) Implement by storing the frontier as a priority queue ordered by g(n). Apply the goal test when the node is selected for expansion If a newly generated node n is already on the frontier as node n´ and if pathcost(n) < pathcost(n´), then replace n’ with n.

Comparison of Blind Methods

Problem All these blind methods are too slow for real applications Solution  add guidance  “informed search”