Solving Problems by Searching

Similar documents
CSE373: Data Structures & Algorithms Lecture 23: Applications. Linda Shapiro Spring 2016

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.

Uninformed Search strategies. AIMA sections 3.4,3.5

Search EECS 395/495 Intro to Artificial Intelligence

Search EECS 348 Intro to Artificial Intelligence

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

Artificial Intelligence

Solving problems by searching

Uninformed Search Methods

Chapter 3: Solving Problems by Searching

Uninformed Search Strategies AIMA 3.4

CMU-Q Lecture 2: Search problems Uninformed search. Teacher: Gianni A. Di Caro

Basic Search. Fall Xin Yao. Artificial Intelligence: Basic Search

Problem Solving Agents

Search. CS 3793/5233 Artificial Intelligence Search 1

Route planning / Search Movement Group behavior Decision making

Goal-Based Agents Problem solving as search. Outline

Today s s lecture. Lecture 2: Search - 1. Examples of toy problems. Searching for Solutions. Victor R. Lesser

CAP 4630 Artificial Intelligence

CITS3001. Algorithms, Agents and Artificial Intelligence. Semester 1, 2015

Problem Spaces & Search CSE 473

Problem Solving and Search in Artificial Intelligence

HW#1 due today. HW#2 due Monday, 9/09/13, in class Continue reading Chapter 3

Vorlesung Grundlagen der Künstlichen Intelligenz

mywbut.com Uninformed Search

Solving Problems by Searching

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

Solving Problems by Searching

Search Algorithms. Uninformed Blind search. Informed Heuristic search. Important concepts:

CS 4700: Foundations of Artificial Intelligence. Bart Selman. Search Techniques R&N: Chapter 3

Uninformed search strategies (Section 3.4) Source: Fotolia

Solving Problems by Searching

Solving Problem by Searching. Chapter 3

A4B36ZUI - Introduction ARTIFICIAL INTELLIGENCE

AI: Week 2. Tom Henderson. Fall 2014 CS 5300

Last time: Problem-Solving

Informed (Heuristic) Search. Idea: be smart about what paths to try.

Solving Problems: Blind Search

Logistics. u AI Nugget presentations. u Project Team Wikis, pages. u PolyLearn: Does everybody have access? u Lab and Homework Assignments.

State Spaces

Class Overview. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 2: Search. Problem Solving Agents

ARTIFICIAL INTELLIGENCE. Pathfinding and search

Artificial Intelligence Class 3: Search (Ch ) Some material adopted from notes by Charles R. Dyer, University of Wisconsin-Madison

Chapter 3 Solving problems by searching

2. State Space Search

Intelligent Agents. Foundations of Artificial Intelligence. Problem-Solving as Search. A Simple Reflex Agent. Agent with Model and Internal State

Computer Science and Software Engineering University of Wisconsin - Platteville. 3. Search (Part 1) CS 3030 Lecture Notes Yan Shi UW-Platteville

CS-171, Intro to A.I. Mid-term Exam Fall Quarter, 2013

9/7/2015. Outline for today s lecture. Problem Solving Agents & Problem Formulation. Task environments

Graphs vs trees up front; use grid too; discuss for BFS, DFS, IDS, UCS Cut back on A* optimality detail; a bit more on importance of heuristics,

CS 771 Artificial Intelligence. Problem Solving by Searching Uninformed search

Announcements. Project 0: Python Tutorial Due last night

Lecture 3. Uninformed Search

Artificial Intelligence

Chapter 4. Uninformed Search Strategies

CPS 170: Artificial Intelligence Search

Topic 1 Uninformed Search

Problem Solving as Search. CMPSCI 383 September 15, 2011

Blind (Uninformed) Search (Where we systematically explore alternatives)

Uninformed Search. Chapter 3

AI: problem solving and search

TDDC17. Physical Symbol System Hypothesis. Designation and Interpretation. Physical Symbol Systems

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

Blind (Uninformed) Search (Where we systematically explore alternatives)

Uninformed Search (Ch )

Solving Problems by Searching

Solving Problems by Searching

CS 8520: Artificial Intelligence

AGENTS AND ENVIRONMENTS. What is AI in reality?

Problem Solving and Search

An Appropriate Search Algorithm for Finding Grid Resources

Uninformed Search. Reading: Chapter 4 (Tuesday, 2/5) HW#1 due next Tuesday

DFS. Depth-limited Search

ARTIFICIAL INTELLIGENCE SOLVING PROBLEMS BY SEARCHING. Chapter 3

Problem Solving. Russell and Norvig: Chapter 3

Uninformed Search Strategies AIMA

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

Uninformed Search Strategies

Artificial Intelligence

AGENTS AND ENVIRONMENTS. What is AI in reality?

UNINFORMED SEARCH. What to do if teammates drop? Still have 3 or more? No problem keep going. Have two or fewer and want to be merged?

Class Overview. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 2. Problem Solving Agents. Problem Solving Agents: Assumptions

A* Optimality CS4804

Search : Lecture 2. September 9, 2003

Artificial Intelligence

KI-Programmierung. Basic Search Algorithms

Informed Search CS457 David Kauchak Fall 2011

Introduction to Multi-Agent Programming

Lecture 4: Search 3. Victor R. Lesser. CMPSCI 683 Fall 2010

State Space Search. Many problems can be represented as a set of states and a set of rules of how one state is transformed to another.

CSC 2114: Artificial Intelligence Search

Artificial Intelligence Uninformed search

521495A: Artificial Intelligence

Ar#ficial)Intelligence!!

Artificial Intelligence

Solving problems by searching. Chapter 3

Uninformed (also called blind) search algorithms

Artificial Intelligence Problem Solving and Uninformed Search

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

A2 Uninformed Search

Transcription:

Solving Problems by Searching 1

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

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 x a c(a) y 3

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

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? 5

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) 6

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

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? 8

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

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

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

Search Tree Example: Fragment of 8-Puzzle Problem Space 12

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] Q Q Q Q Start state Goal state (test) Output 13

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: 14

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. 15

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. 16

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. 17

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

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. 19

Missionaries and Cannibals Problem 20

Missionaries and Cannibals Problem Left Bank Right Bank River 21

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? 22

What are all the actions? Left to right 1. MCR 2. MMR 3.? 4.? 5.? Right to left 1. MCL 2. MML 3.? 4.? 5.? 23

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

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

Assignment Implement and solve the problem 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. 26

Warning The material that follows is NOT for HW1. HW1 is to be done with a recursive, depthfirst 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. 27

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 1. What is the frontier? 2. How do we choose? 3. What does expand mean? 28

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 29

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 30

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? 31

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

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

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

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 35

Forwards vs. Backwards 36

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? 37

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. 38

Comparison of Blind Methods 39

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