CS486/686 Lecture Slides (c) 2015 P.Poupart

Similar documents
CS486/686 Lecture Slides (c) 2014 P.Poupart

Solving Problems by Searching

Outline. Solving Problems by Searching. Introduction. Problem-solving agents

AGENTS AND ENVIRONMENTS. What is AI in reality?

AGENTS AND ENVIRONMENTS. What is AI in reality?

Solving Problems by Searching

Solving Problems by Searching

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

Problem solving and search

4. Solving Problems by Searching

Problem solving and search

Artificial Intelligence: Search Part 1: Uninformed graph search

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

Problem solving and search

Introduction to Artificial Intelligence. Informed Search

Robot Programming with Lisp

PEAS: Medical diagnosis system

Problem solving and search

Artificial Intelligence. Informed search methods

Informed search algorithms

Solving Problems using Search

Overview. Path Cost Function. Real Life Problems. COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Artificial Intelligence

Solving problems by searching

Solving Problem by Searching. Chapter 3

Informed Search. Topics. Review: Tree Search. What is Informed Search? Best-First Search

Solving problems by searching

Planning and search. Lecture 1: Introduction and Revision of Search. Lecture 1: Introduction and Revision of Search 1

Informed search algorithms. Chapter 4, Sections 1 2 1

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

CS 380: Artificial Intelligence Lecture #3

Chapter 2. Blind Search 8/19/2017

Artificial Intelligence

Searching and NetLogo

Informed search algorithms

ARTIFICIAL INTELLIGENCE. Pathfinding and search

Problem solving and search: Chapter 3, Sections 1 5

Informed Search Algorithms. Chapter 4

CS:4420 Artificial Intelligence

Problem solving and search: Chapter 3, Sections 1 5

COSC343: Artificial Intelligence

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,

COMP9414/ 9814/ 3411: Artificial Intelligence. 5. Informed Search. Russell & Norvig, Chapter 3. UNSW c Alan Blair,

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

Informed Search and Exploration

Solving problems by searching

Solving problems by searching

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

KI-Programmierung. Basic Search Algorithms

Artificial Intelligence

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

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

CS:4420 Artificial Intelligence

Informed Search and Exploration

CS-E4800 Artificial Intelligence

Artificial Intelligence: Search Part 2: Heuristic search

Solving Problems by Searching. Artificial Intelligence Santa Clara University 2016

Informed search algorithms

Artificial Intelligence

Problem solving and search

Problem solving and search

Informed Search and Exploration

Solving Problems by Searching

PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE

CS 771 Artificial Intelligence. Problem Solving by Searching Uninformed search

Foundations of Artificial Intelligence

CS 8520: Artificial Intelligence

Problem Solving and Search. Chapter 3

COMP219: Artificial Intelligence. Lecture 7: Search Strategies

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

CS414-Artificial Intelligence

Planning, Execution & Learning 1. Heuristic Search Planning

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

ARTIFICIAL INTELLIGENCE SOLVING PROBLEMS BY SEARCHING. Chapter 3

Introduction to Artificial Intelligence (G51IAI)

Seminar: Search and Optimization

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

Problem Solving as Search. CMPSCI 383 September 15, 2011

Problem solving and search

Solving problems by searching. Chapter 3

TDT4136 Logic and Reasoning Systems

AI: problem solving and search

Reminders. Problem solving and search. Problem-solving agents. Outline. Assignment 0 due 5pm today

Warm- up. IteraAve version, not recursive. class TreeNode TreeNode[] children() boolean isgoal() DFS(TreeNode start)

Artificial Intelligence CS 6364

Princess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D) Computer Science Department

Search EECS 395/495 Intro to Artificial Intelligence

Search EECS 348 Intro to Artificial Intelligence

CAP 4630 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.

Problem solving and search

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

Problem solving by search

Artificial Intelligence Problem Solving and Uninformed Search

Algorithm. December 7, Shortest path using A Algorithm. Phaneendhar Reddy Vanam. Introduction. History. Components of A.

Chapter 3 Solving problems by searching

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

Vorlesung Grundlagen der Künstlichen Intelligenz

Outline. Solving problems by searching. Prologue. Example: Romania. Uninformed search

Transcription:

1

2

Solving Problems by Searching [RN2] Sec 3.1-3.5 [RN3] Sec 3.1-3.4 CS486/686 University of Waterloo Lecture 2: May 7, 2015 3

Outline Problem solving agents and search Examples Properties of search algorithms Uninformed search Breadth first Depth first Iterative Deepening 4

Introduction Search was one of the first topics studied in AI Newell and Simon (1961) General Problem Solver Central component to many AI systems Automated reasoning, theorem proving, robot navigation, VLSI layout, scheduling, game playing, 5

Problem-solving agents 6

Example: Traveling in Romania 71 Oradea Neamt Start Arad 118 75 Zerind 140 Timisoara 151 Sibiu 99 Fagaras 80 Rimnicu Vilcea 87 Iasi 92 Vaslui 111 Lugoj 97 Pitesti 211 142 70 75 Dobreta Mehadia 120 98 146 101 85 Urziceni 138 90 Craiova Giurgiu Bucharest End Hirsova 86 Eforie Formulate Goal Get to Bucharest Formulate Problem Find a solution Initial state: In(Arad) Sequence of cities: Arad, Actions: Drive between cities Sibiu, Fagaras, Bucharest Goal Test: In(Bucharest)? Path cost: Distance between cities 7

Examples of Search Problems 7 2 4 1 2 5 6 3 4 5 8 3 1 6 7 8 Start State Goal State States: Locations of 8 tiles and blank Initial State: Any state Succ Func: Generates legal states that result from trying 4 actions (blank up, down, left, right) Goal test: Does state match desired configuration Path cost: Number of steps States: Arrangement of 0 to 8 queens on the board Initial State: No queens on the board Succ Func: Add a queen to an empty space Goal test: 8 queens on board, none attacked Path cost: none 8

More Examples 9

Common Characteristics All of those examples are Fully observable Deterministic Sequential Static Discrete Single agent Can be tackled by simple search techniques 10

Cannot tackle these yet Chance Infinite number of states Games against an adversary Hidden states All of the above 11

Searching We can formulate a search problem Now need to find the solution We can visualize a state space search in terms of trees or graphs Nodes correspond to states Edges correspond to taking actions We will be studying search trees These trees are constructed on the fly by our algorithms 12

Data Structures for Search Basic data structure: Search Node State Parent node and operator applied to parent to reach current node Cost of the path so far Depth of the node PARENT NODE 5 6 4 1 8 ACTION = right Node DEPTH = 6 PATH COST = 6 STATE 7 3 2 13

Expanding Nodes Expanding a node Applying all legal operators to the state contained in the node and generating nodes for all corresponding successor states (a) The initial state Arad Sibiu Timisoara Zerind Arad Fagaras Oradea Rimnicu Vilcea Arad Lugoj Arad Oradea (b) After expanding Arad Arad Sibiu Timisoara Zerind Arad Fagaras Oradea Rimnicu Vilcea Arad Lugoj Arad Oradea (c) After expanding Sibiu Arad Sibiu Timisoara Zerind Arad Fagaras Oradea Rimnicu Vilcea Arad Lugoj Arad Oradea 14

Generic Search Algorithm 1. Initialize search algorithm with initial state of the problem 2. Repeat 1. If no candidate nodes can be expanded, return failure 2. Choose leaf node for expansion, according to search strategy 3. If node contains a goal state, return solution 4. Otherwise, expand the node, by applying legal operators to the state within the node. Add resulting nodes to the tree 15

Implementation Details We need to keep track only of nodes that need to be expanded (fringe) Done by using a (prioritized) queue 1. Initialize queue by inserting the node corresponding to the initial state of the problem 2. Repeat 1. If queue is empty, return failure 2. Dequeue a node 3. If the node contains a goal state, return solution 4. Otherwise, expand node by applying legal operators to the state within. Insert resulting nodes into queue Search algorithms differ in their queuing function! 16

Breadth-first search All nodes on a given level are expanded before any nodes on the next level are expanded. Implemented with a FIFO queue A A A A B C B C B C B C D E F G D E F G D E F G D E F G A B,C C,D,E D,E,F,G 17

Evaluating search algorithms Completeness: Is the algorithm guaranteed to find a solution if a solution exists? Optimality: Does the algorithm find the optimal solution (Lowest path cost of all solutions) Time complexity Space complexity Variables b d m Branching factor Depth of shallowest goal node Maximum length of any path in the state space 18

Complete: Yes, if b is finite Optimal: Judging BFS Yes, if all costs are the same Time: 1+b+b 2 +b 3 + +b d = O(b d ) Space: O(b d ) All uninformed search methods will have exponential time complexity 19

Uniform Cost Search A variation of breadth-first search Instead of expanding shallowest node it expands the node with lowest path cost Implemented using a priority queue C* is cost of optimal solution is minimum action cost Optimal Yes Time: O(b ceiling(c*/ ) ) Complete if > 0 Space: O(b ceiling(c*/ ) ) 20

Depth-first search The deepest node in the current fringe of the search tree is expanded first. Implemented with a stack (LIFO queue) 21

Depth-first search The deepest node in the current fringe of the search tree is expanded first. Implemented with a stack (LIFO queue) 22

Depth-first search The deepest node in the current fringe of the search tree is expanded first. Implemented with a stack (LIFO queue) 23

Depth-first search The deepest node in the current fringe of the search tree is expanded first. Implemented with a stack (LIFO queue) 24

Depth-first search The deepest node in the current fringe of the search tree is expanded first. Implemented with a stack (LIFO queue) 25

Depth-first search The deepest node in the current fringe of the search tree is expanded first. Implemented with a stack (LIFO queue) 26

Judging DFS Complete: No, might get stuck going down a long path Optimal: No, might return a solution which is deeper (i.e. more costly) than another solution Time: O(b m ), m might be larger than d Space: O(bm) Do not use DFS if you suspect a large tree depth 27

Depth-limited search 28

Iterative-deepening General strategy that repeatedly does depthlimited search, but increases the limit each time 29

Iterative-deepening IDS is not as wasteful as one might think. Note, most nodes in a tree are at the bottom level. It does not matter if nodes at a higher level are generated multiple times. Breadth first search : 1 + b + b 2 + + b d-1 + b d E.g. b=10, d=5: 1+10+100+1,000+10,000+100,000 = 111,111 Iterative deepening search : (d+1)*1 + (d)*b + (d-1)*b 2 + + 2b d-1 + 1b d E.g. 6+50+400+3000+20,000+100,000 = 123,456 Complete, Optimal, O(b d ) time, O(bd) space 30

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 Assume no knowledge about the problem (general but expensive) Mainly differ in the order in which they consider the states Criteria BFS Uniform DFS DLS IDS Complete Yes Yes No No Yes Time O(b d ) O(b ceiling(c*/ ) ) O(b m ) O(b l ) O(b d ) Space O(b d ) O(b ceiling(c*/ ) ) O(bm) O(bl) O(bd) Optimal Yes Yes No No Yes 31

Summary Iterative deepening uses only linear space and not much more time than other uninformed search algorithms Use IDS when there is a large state space and the maximum depth of the solution is unknown Things to think about: What about searching graphs? Repeated states? 32