Intro to AI, Fall 2004 © L. Joskowicz 1 Introduction to Artificial Intelligence LECTURE 3: Uninformed Search Problem solving by search: definitions Graph.

Slides:



Advertisements
Similar presentations
Review: Search problem formulation
Advertisements

Announcements Course TA: Danny Kumar
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
January 26, 2003AI: Chapter 3: Solving Problems by Searching 1 Artificial Intelligence Chapter 3: Solving Problems by Searching Michael Scherger Department.
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)
G5BAIM Artificial Intelligence Methods Graham Kendall Blind Searches.
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.
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.
Uninformed Search Jim Little UBC CS 322 – Search 2 September 12, 2014
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
CS 380: Artificial Intelligence Lecture #3 William Regli.
SE Last time: Problem-Solving Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation:
Review: Search problem formulation
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2004.
Search I Tuomas Sandholm Carnegie Mellon University Computer Science Department [Read Russell & Norvig Chapter 3]
Artificial Intelligence Chapter 3: Solving Problems by Searching
Uninformed Search Reading: Chapter 3 by today, Chapter by Wednesday, 9/12 Homework #2 will be given out on Wednesday DID YOU TURN IN YOUR SURVEY?
Using Search in Problem Solving
Solving problems by searching
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.
Solving Problems by Searching
Artificial Intelligence Course outline Introduction Problem solving Generic algorithms Knowledge Representation and Reasoning Expert Systems Uncertainty.
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.
Lecture 2-2CS250: Intro to AI/Lisp Implementing Search Lecture 2-2 January 14 th /19 th, 1999 CS250.
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.
CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #3 Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam.
Artificial Intelligence
Vilalta&Eick:Uninformed Search Problem Solving By Searching Introduction Solutions and Performance Uninformed Search Strategies Avoiding Repeated States/Looping.
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
1 Solving problems by searching 171, Class 2 Chapter 3.
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.
Computer Science CPSC 322 Lecture 6 Iterative Deepening and Search with Costs (Ch: 3.7.3, 3.5.3)
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;
Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
Goal-based Problem Solving Goal formation Based upon the current situation and performance measures. Result is moving into a desirable state (goal state).
CSCI 4310 Lecture 2: Search. Search Techniques Search is Fundamental to Many AI Techniques.
Uninformed search strategies A search strategy is defined by picking the order of node expansion Uninformed search strategies use only the information.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches - Introduction.
Implementation: General Tree Search
Solving problems by searching A I C h a p t e r 3.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 CS121 – Winter 2003.
Search Part I Introduction Solutions and Performance Uninformed Search Strategies Avoiding Repeated States Partial Information Summary.
Brian Williams, Fall 041 Analysis of Uninformed Search Methods Brian C. Williams Sep 21 st, 2004 Slides adapted from: Tomas Lozano Perez,
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 by Searching
Artificial Intelligence Problem solving by searching CSC 361
Problem Solving and Searching
Problem Solving and Searching
ECE457 Applied Artificial Intelligence Fall 2007 Lecture #2
Presentation transcript:

Intro to AI, Fall 2004 © L. Joskowicz 1 Introduction to Artificial Intelligence LECTURE 3: Uninformed Search Problem solving by search: definitions Graph representation Graph properties and search issues Uninformed search methods –depth-first search, breath-first, depth-limited search, iterative deepening search, bi-directional search.

Intro to AI, Fall 2004 © L. Joskowicz 2 Problem solving by search Represent the problem as STATES and OPERATORS that transform one state into another state. A solution to the problem is an OPERATOR SEQUENCE that transforms the INITIAL STATE into a GOAL STATE. Finding the sequence requires SEARCHING the STATE SPACE by GENERATING the paths connecting the two.

Intro to AI, Fall 2004 © L. Joskowicz 3 Search by generating states > >6 2 --> > > > 4 100

Intro to AI, Fall 2004 © L. Joskowicz 4 Basic concepts (1) State: finite representation of the world at a given time. Operator: a function that transforms a state into another ( also called rule, transition, successor function, production, action). Initial state: world state at the beginning. Goal state: desired world state (can be several) Goal test: test to determine if the goal has been reached.

Intro to AI, Fall 2004 © L. Joskowicz 5 Basic concepts (2) Reachable goal: a state for which there exists a sequence of operators to reach it. State space: set of all reachable states from initial state (possibly infinite). Cost function: a function that assigns a cost to each operation. Performance: –cost of the final operator sequence –cost of finding the sequence

Intro to AI, Fall 2004 © L. Joskowicz 6 Problem formulation The first taks is to formulate the problem in terms of states and operators Some problems can be naturally defined this way, others not! Formulation makes a big difference! Examples: –water jug problem, tic-tac-toe, 8-puzzle, 8-queen problem, cryptoarithmetic –robot world, travelling salesman, part assembly

Intro to AI, Fall 2004 © L. Joskowicz 7 Example 1: water jug (1) 4 3 Given 4 and 3 liter jugs, a water pump, and a sink, how do you get exactly two liters into the 4 liter jug? State: (x,y) for liters in jugs 1 and 2, integers 0 to 4 Operations: empty jug, fill jug, pour water between jugs Initial state: (0,0); Goal state: (2,n) Jug 2Jug 1 Sink Pump

Intro to AI, Fall 2004 © L. Joskowicz 8 Water jug operations 1. (x, y | x < 4) (4, y) Fill 4 2. (x, y | y < 3) (x, 3) Fill 3 3. (x, y | x > 0) (0, y) Dump 4 4. (x, y | y > 0) (x, 0) Dump 3 5. (x, y | x+y >=4 and y>0) (4, y - (4 - x)) Pour from 3 to 4 until 4 is full 6. (x, y | x+y >=3 and x>0) (x - (3 - y), 3) Pour from 4 to 3 until 3 is full 7. (x, y | x+y 0) (x+y, 0) Pour all water from 3 to 4  move  move

Intro to AI, Fall 2004 © L. Joskowicz 9 Water Jug Problem: one solution Gallons in y Trasition Rule 2 fill 3 7 pour from 3 to 4 2 fill 3 5 pour from 3 to 4 until 4 is full 3 dump 4 7 pour from 3 to 4

Intro to AI, Fall 2004 © L. Joskowicz 10 Example 2: cryptoarithmetic F O R T Y + T E N S I X T Y Assign numbers to letters so that the sum is correct State: a matrix, with letters and numbers Operations: replace all occurrences of a letter with a digit not already there Goal test: only digits, sum is correct Solution F=2, O=9 R=7, T=8 Y=6, E=5 N=0, I=1 X=4

Intro to AI, Fall 2004 © L. Joskowicz 11 Example 3: 8-puzzle State: a matrix, with numbers and the empty space Operation: exchange tile with adjacent empty space Goal test: state matches final state; cost is # of moves 9! =362,880 states

Intro to AI, Fall 2004 © L. Joskowicz 12 Example 4: 8-queens State: any arrangement of up to 8 queens on the board Operation: add a queen (incremental), move a queen (fix-it) Goal test: no queen is attacked Improvements: only non-attacked states, one queen per column, place in leftmost non-attacked position: 2,057 possibilities. 64x63x…x57 = 3x10 14 states

Intro to AI, Fall 2004 © L. Joskowicz 13 Other search problems Path finding problems in graphs: shortest path, shortest circuit visiting each node once. Automatic assembly, protein design, Internet search s a b c d

Intro to AI, Fall 2004 © L. Joskowicz 14 Graph representation Nodes represent states G(V,E) Directed edges represent operation applications -- labels indicate operation applied Initial, goal states are start and end nodes Edge weight: cost of applying an operator Search: find a path from start to end node Graph is generated dynamically as we search

Intro to AI, Fall 2004 © L. Joskowicz 15 Graph characteristics A tree, directed acyclic graph, or graph with cycles -- depends on state repetitions Number of states (n) –size of problem space, possibly infinite Branching factor (b) – # of operations that can be applied at each state –maximum number of outgoing edges Depth level (d) – number of edges from the initial state

Intro to AI, Fall 2004 © L. Joskowicz 16 Water jug problem: tree (0,0) (0,3) (4,0) (0,0) (1,3) (4,3) (0,0) (3,0) (0,3) (1,0) (4,0) (4,3)     (2,0) (2,3)

Intro to AI, Fall 2004 © L. Joskowicz 17 Water jug problem: graph (0,0) (0,3) (4,0) (1,3) (4,3) (3,0)

Intro to AI, Fall 2004 © L. Joskowicz 18 Data structures State: structure with world parameters Node: –state, depth level –# of predecesors, list of ingoing edges –# of successors, list of outgoing edges Edge: from and to state, operation number, cost Operation: from state to state, matching function Hash table of operations Queue to keep states to be expanded

Intro to AI, Fall 2004 © L. Joskowicz 19 General search algorithm function General-Search(problem) returns solution nodes := Make-Queue(Make-Node(Initial-State(problem)) loop do if nodes is empty then return failure node := Remove-Front (nodes) if Goal-Test[problem] applied to State(node) succeeds then return node new-nodes := Expand (node, Operators[problem])) nodes := Insert-In-Queue(new-nodes) end

Intro to AI, Fall 2004 © L. Joskowicz 20 Search issues: graph generation Tree vs. graph –how to handle state repetitions? –what to do with infinite branches? How to select the next state to expand –uninformed vs. informed heuristic search Direction of expansion –from start to goal, from goal to start, both. Efficiency –What is the most efficient way to search?

Intro to AI, Fall 2004 © L. Joskowicz 21 Properties of search strategies Completeness –guarantees to find a solution if a solution exists, or return fail if none exists Optimality –Does the strategy find the optimal solution Time complexity – # of operations applied in the search Space complexity –# of nodes stored during the search

Intro to AI, Fall 2004 © L. Joskowicz 22 Factors that affect search efficiency I G G G 1. More start or goal states? Move towards the larger set I G I I

Intro to AI, Fall 2004 © L. Joskowicz 23 Factors that affect search efficiency 2. Branching factor: move in the direction with the lower branching factor I G I G

Intro to AI, Fall 2004 © L. Joskowicz 24 Factors that affect search efficiency 3. Explanation generation, execution: depends on which type is more intuitive and can be executed Directions: must be given from start to end, not vice-versa Diagnosis: “the battery was replaced because..”

Intro to AI, Fall 2004 © L. Joskowicz 25 Uninformed search methods No a-priori knowledge on which node is best to expand (ex: crypto-arithmetic problem) Methods –Depth-first search (DFS) –Breath-first search (BFS) –Depth-limited search –Iterative deepening search –Bidirectional search

Intro to AI, Fall 2004 © L. Joskowicz 26 A graph search problem... S ABC DEF G G

Intro to AI, Fall 2004 © L. Joskowicz 27 … becomes a tree S AD BDAE CEEBBF DFBFCEACG GCGF G25 11

Intro to AI, Fall 2004 © L. Joskowicz 28 Depth first search Dive into the search tree as far as you can, backing up only when there is no way to proceed function Depth-First-Search(problem) returns solution nodes := Make-Queue(Make-Node(Initial-State(problem)) loop do if nodes is empty then return failure node := Remove-Front (nodes) if Goal-Test[problem] applied to State(node) succeeds then return node new-nodes := Expand (node, Operarors[problem])) nodes := Insert-At-Front-of-Queue(new-nodes) end

Intro to AI, Fall 2004 © L. Joskowicz 29 Depth-first search S AD BDAE CEEBBF DFBFCEACG GCGF G25 11

Intro to AI, Fall 2004 © L. Joskowicz 30 Breath-first search Expand the tree in successive layers, uniformly looking at all nodes at level n before progressing to level n+1 function Breath-First-Search(problem) returns solution nodes := Make-Queue(Make-Node(Initial-State(problem)) loop do if nodes is empty then return failure node := Remove-Front (nodes) if Goal-Test[problem] applied to State(node) succeeds then return node new-nodes := Expand (node, Operators[problem])) nodes := Insert-At-End-of-Queue(new-nodes) end

Intro to AI, Fall 2004 © L. Joskowicz 31 Breath-first search S AD BDAE CEEBBF DFBFCEACG GCGF G25 11

Intro to AI, Fall 2004 © L. Joskowicz 32 Depth-limited search Like DFS, but the search is limited to a predefined depth. The depth of each state is recorded as it is generated. When picking the next state to expand, only those with depth less or equal than the current depth are expanded. Once all the nodes of a given depth are explored, the current depth is incremented. Combination of DFS and BFS. Change the Insert-Queue function in the algorithm above.

Intro to AI, Fall 2004 © L. Joskowicz 33 Depth-limited search S AD BDAE CEEBBF DFBFCEACG GCGF G25 11 depth = 3 3 6

Intro to AI, Fall 2004 © L. Joskowicz 34 IDS: Iterative deepening search Problem: what is a good depth limit? Answer: make it adaptive! Generate solutions at depth 1, 2, …. function Iterative-Deepening-Search(problem) returns solution nodes := Make-Queue(Make-Node(Initial-State(problem) for depth := 0 to infinity if Depth-Limited-Search(problem, depth) succeeds then return its result end return failure

Intro to AI, Fall 2004 © L. Joskowicz 35 Iterative deepening search S S AD S S AD S S AD BDAE Limit = 0 Limit = 1 Limit = 2

Intro to AI, Fall 2004 © L. Joskowicz 36 Iterative search is not as wasteful as it might seem The root subtree is computed every time instead of storing it! Most of the solutions are in the bottom leaves anyhow: b + b 2 + …+ b d = O(b d ) Repeating the search takes: (d+1)1 + (d)b + (d - 1)b 2 + … (1)b d = O(b d ) For b = 10 and d = 5 the number of nodes searched up to level 5 is 111,111 vs. repeated 123,450 (only 11% more) !!

Intro to AI, Fall 2004 © L. Joskowicz 37 Bidirectional search Expand nodes from the start and goal state simultaneously. Check at each stage if the nodes of one have been generated by the other. If so, the path concatenation is the solution The operators must be reversible single start, single goal Efficient check for identical states Type of search that happens in each half

Intro to AI, Fall 2004 © L. Joskowicz 38 Bidirectional search S AD BDAE CEEBBF DFBFCEACG GCGF G25 11 Forward Backwards

Intro to AI, Fall 2004 © L. Joskowicz 39 Comparing search strategies b d+1 b C/e

Intro to AI, Fall 2004 © L. Joskowicz 40 Repeated states Repeated states can the source of great inefficiency: identical subtrees will be explored many times! B B CCC C A A B C How much effort to invest in detecting repetitions?

Intro to AI, Fall 2004 © L. Joskowicz 41 Strategies for repeated states Do not expand the state that was just generated –constant time, prevents cycles of length one, ie., A,B,A,B…. Do not expand states that appear in the path –depth of node, prevents some cycles of the type A,B,C,D,A Do not expand states that were expanded before –can be expensive! Use hash table to avoid looking at all nodes every time.

Intro to AI, Fall 2004 © L. Joskowicz 42 Summary: uninformed search Problem formulation and representation is key! Implementation as expanding directed graph of states and transitions Appropriate for problems where no solution is known and many combinations must be tried Problem space is of exponential size in the number of world states -- NP-hard problems Fails due to lack of space and/or time.