Uninformed Search. Remember: Implementation of search algorithms

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

KI-Programmierung. Basic Search Algorithms

Problem solving and search

AI: problem solving and search

Last time: Problem-Solving

Robot Programming with Lisp

Solving problems by searching. Chapter 3

Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu. Problem Space and Search Tree

Artificial Intelligence

Artificial Intelligence Uninformed search

Informed search algorithms

Problem solving and search

Artificial Intelligence p.1/49. n-queens. Artificial Intelligence p.2/49. Initial state: the empty board or a board with n random

Artificial Intelligence

Artificial Intelligence Search: summary&exercises. Peter Antal

Problem solving and search

Artificial Intelligence

CS:4420 Artificial Intelligence

CS 8520: Artificial Intelligence

Artificial Intelligence

Announcements. Project 0: Python Tutorial Due last night

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

Informed Search and Exploration

Problem Solving and Search

CS540 Uninformed Search

Informed Search. Dr. Richard J. Povinelli. Copyright Richard J. Povinelli Page 1

Solving Problems by Searching

CSC 2114: Artificial Intelligence Search

Artificial Intelligence Problem Solving and Uninformed Search

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

Search EECS 395/495 Intro to Artificial Intelligence

Informed Search and Exploration

Mustafa Jarrar: Lecture Notes on Artificial Intelligence Birzeit University, Chapter 3 Informed Searching. Mustafa Jarrar. University of Birzeit

Search EECS 348 Intro to Artificial Intelligence

Introduction to Artificial Intelligence. Informed Search

Problem solving and search

Solving Problems by Searching

Multiagent Systems Problem Solving and Uninformed Search

CAP 4630 Artificial Intelligence

CS 771 Artificial Intelligence. Problem Solving by Searching Uninformed search

Chapter 3: Solving Problems by Searching

Chapter 3 Solving problems by searching

CS 520: Introduction to Artificial Intelligence. Review

Informed search algorithms. Chapter 4, Sections 1 2 1

Graph Search. Chris Amato Northeastern University. Some images and slides are used from: Rob Platt, CS188 UC Berkeley, AIMA

521495A: Artificial Intelligence

Chapter 3: Informed Search and Exploration. Dr. Daisy Tang

State- space search algorithm

ARTIFICIAL INTELLIGENCE. Pathfinding and search

Informed search algorithms

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

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

Informed Search and Exploration

Problem Solving. Russell and Norvig: Chapter 3

Uninformed Search strategies. AIMA sections 3.4,3.5

CS 380: Artificial Intelligence Lecture #3

Informed search methods

Solving problems by searching

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

Informed search algorithms

CS:4420 Artificial Intelligence

Informed search algorithms

COMP219: Artificial Intelligence. Lecture 7: Search Strategies

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

CSCI 360 Introduc/on to Ar/ficial Intelligence Week 2: Problem Solving and Op/miza/on. Instructor: Wei-Min Shen

CS 380: Artificial Intelligence Lecture #4

ARTIFICIAL INTELLIGENCE SOLVING PROBLEMS BY SEARCHING. Chapter 3

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Problem solving and search

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

521495A: Artificial Intelligence

Informed search algorithms

Solving problems by searching

Problem Solving: Informed Search

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

A2 Uninformed Search

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

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

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

CS242 Uninformed Search

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

Chapter 2. Blind Search 8/19/2017

Solving Problem by Searching. Chapter 3

Informed search strategies (Section ) Source: Fotolia

Dr. Mustafa Jarrar. Chapter 4 Informed Searching. Sina Institute, University of Birzeit

Solving Problems by Searching. AIMA Sections , 3.6

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

Why Search. Things to consider. Example, a holiday in Jamaica. CSE 3401: Intro to Artificial Intelligence Uninformed Search

CS 771 Artificial Intelligence. Informed Search

Solving Problems by Searching (Blindly)

Dr. Mustafa Jarrar. Chapter 4 Informed Searching. Artificial Intelligence. Sina Institute, University of Birzeit

An Appropriate Search Algorithm for Finding Grid Resources

Informed/Heuristic Search

Uninformed Search Strategies AIMA 3.4

Algorithms for Data Structures: Uninformed Search. Phillip Smith 19/11/2013

Solving Problems by Searching

Solving Problems by Searching

Artificial Intelligence

CS 4100 // artificial intelligence

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.

Transcription:

Uninformed Search Lecture 4 Introduction to Artificial Intelligence Hadi Moradi moradi@usc.edu Remember: Implementation of search algorithms Function General-Search(problem, Queuing-Fn) returns a solution, or failure 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 nodes Queuing-Fn(nodes, Expand(node, Operators[problem])) end 2

2 Remember: Implementation of search algorithms Queuing-Fn(queue, elements) ) is a queuing function that inserts a set of elements into the queue and determines the order of node expansion. Varieties of the queuing function produce varieties of the search algorithm. 3 Encapsulating state information in nodes 4

3 Evaluation of search strategies 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? Evaluation of search strategies Time and space complexity are measured ed 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) 6

4 Note: Approximations In our complexity analysis, we do not take the built-in loop- detection into account. The results only formally apply to the variants of our algorithms WITHOUT loop-checks. Studying the effect of the loop-checking on the complexity is hard: overhead of the checking MAY or MAY NOT be compensated by the reduction of the size of the tree. http://www.cs.kuleuven.ac.be/~dannyd/fai/ 7 Note: Approximations Also: our analysis DOES NOT take the length (space) of representing paths into account!! 8

Uninformed search strategies Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first Depth-limited Iterative deepening 9 Breadth-first search S A D B D A E C E E B B F D F B F C E A C G G C G F G Move downwards, level by level, until goal is reached. 0

6 Example: Traveling from Arad To Bucharest Breadth-first search 2

7 Breadth-first search 3 Breadth-first search 4

8 Properties of breadth-first search Search algorithms are commonly evaluated according to the following four criteria: Completeness: Time complexity: Space complexity: Optimality: Uniform-cost search So, the queueing function keeps the node list sorted by increasing path cost, and we expand the first unexpanded node (hence with smallest path cost) A refinement of the breadth-first strategy: Breadth-first = uniform-cost with path cost = node depth 6

9 Romania with step costs in km 7 Uniform-cost search 8

0 Uniform-cost search 9 Uniform-cost search 20

Properties of uniform-cost search Completeness:? Time complexity:? Space complexity:? Optimality:? 2 Implementation of uniformcost search Initialize Queue with root node (built from start state) Repeat until Queue is empty/node has Goal state: Remove first node from front of Queue Expand node (find its children) Reject those children that have already been considered, to avoid loops Add remaining children to Queue, in a way that keeps entire queue sorted by increasing path cost If Goal was reached, return success, otherwise failure 22

2 Caution! Uniform-cost search not optimal if it is terminated when any node in the queue has goal state. Uniform cost returns the path with cost 02 (if any goal node is considered a solution), while there is a path with cost 2. 2 B 00 A S G C F 20 D 0 E 23 Question: Do we have the previous problem in this example? B 00 A S C D E F G 24

3 Note: Loop Detection In class, we saw that the search may fail or be sub-optimal if: - no loop detection: then algorithm runs into infinite cycles (A -> B-> A-> B-> ) -not queueing-up a node that has a state which we have already visited: may yield suboptimal solution 2 Note: Loop Detection - simply avoiding to go back to our parent: looks promising, but we have not proven that it works Solution? Is that enough?? 26

4 Example From: http://www.csee.umbc.edu/47/current/notes/uninformed-search/ G 27 Breadth-First Search Solution From: http://www.csee.umbc.edu/47/current/notes/uninformed-search/ 28

Uniform-Cost Search Solution From: http://www.csee.umbc.edu/47/current/notes/uninformed-search/ 29 Note: Queuing in Uniform- Cost Search Problem: wasting (but not incorrect) to queue-up three nodes with G: Although different paths, but for sure that the one with smallest path cost (9 in the example) is the first one in the queue. Solution: refine the queuing function by: Is that it?? 30

6 A Clean Robust Algorithm Function UniformCost-Search(problem, Queuing-Fn) returns a solution, or failure open make-queue(make-node(initial-state[problem])) closed [empty] loop do if open is empty then return failure currnode Remove-Front(open) if Goal-Test[problem] applied to State(currnode) then return currnode children Expand(currnode, Operators[problem]) while children not empty [ see next slide ] end closed Insert(closed, currnode) open Sort-By-PathCost(open) end 3 A Clean Robust Algorithm [ see previous slide ] children Expand(currnode, Operators[problem]) while children not empty child Remove-Front(children) if no node in open or closed has child s state open Queuing-Fn(open, child) else if there exists node in open that has child s state if PathCost(child) < PathCost(node) open Delete-Node(open, node) open Queuing-Fn(open, child) else if there exists node in closed that has child s state if PathCost(child) < PathCost(node) closed Delete-Node(closed, node) open Queuing-Fn(open, child) end [ see previous slide ] 32

7 B 00 Example A S C F G D E # State Depth Cost Parent S 0 0-33 B 00 Example A G S C F D E # State Depth Cost Parent S 0 0-2 A 3 C Black = open queue Grey = closed queue #: The step in which the node expanded Insert expanded nodes Such as to keep open queue sorted 34

8 B 00 Example A G S C F D E # State Depth Cost Parent S 0 0-2 A 4 B 2 2 2 3 C Node 2 has 2 successors: one with state B and one with state S. We have node # in closed with state S; but its path cost 0 is smaller than the path cost obtained by expanding from A to S. So we do not queue-up the successor of node 2 that has state S. 3 B 00 Example A G S C F D E # State Depth Cost Parent S 0 0-2 A 4 B 2 2 2 C 3 3 4 6 G 3 02 4 Node 4 has a successor with state C and Cost smaller than node #3 in open that Also had state C; so we update open To reflect the shortest path. 36

9 B 00 Example A G S C F D E # State Depth Cost Parent S 0 0-2 A 4 B 2 2 2 C 3 3 4 7 D 4 8 6 G 3 02 4 37 B 00 Example A G S C D E F # State Depth Cost Parent S 0 0-2 A 4 B 2 2 2 C 3 3 4 7 D 4 8 8 E 3 7 6 G 3 02 4 38

20 B 00 Example A G S C F D E # State Depth Cost Parent S 0 0-2 A 4 B 2 2 2 C 3 3 4 7 D 4 8 8 E 3 7 9 F 6 8 8 6 G 3 02 4 39 B 00 Example A G S C F D E # State Depth Cost Parent S 0 0-2 A 4 B 2 2 2 C 3 3 4 7 D 4 8 8 E 3 7 9 F 6 8 8 0 G 7 23 9 6 G 3 02 4 40

2 B 00 Example A G S C F D E # State Depth Cost Parent S 0 0-2 A 4 B 2 2 2 C 3 3 4 7 D 4 8 8 E 3 7 9 F 6 8 8 0 G 7 23 9 6 G 3 02 4 Goal reached 4 More examples See the great demos at: http://pages.pomona.edu/~jbm04747/courses/spring20 0/cs/Search/Strategies.html 42

22 Depth-first search S A B C E D F G 43 Romania with step costs in km 44

23 Depth-first search 4 Depth-first search 46

24 Depth-first search 47 Properties of depth-first search Completeness:? Time complexity:? Space complexity:? Optimality:? Remember: b = branching factor m = max depth of search tree 48

2 Avoiding repeated states In increasing order of effectiveness and computational overhead:. do not return to state we come from, i.e., expand function will skip possible successors that are in same state as node s parent. 49 Avoiding repeated states 2. do not create paths with cycles, i.e., expand function will skip possible successors that are in same state as any of node s ancestors. 3. do not generate any state that was ever generated before, by keeping track (in memory) of every state generated, unless the cost of reaching that state is lower than last time we reached it. 0

26 Examples: Avoiding repeated states Assembly example