Problem Solving and Search

Similar documents
Informed search algorithms

Craiova. Dobreta. Eforie. 99 Fagaras. Giurgiu. Hirsova. Iasi. Lugoj. Mehadia. Neamt. Oradea. 97 Pitesti. Sibiu. Urziceni Vaslui.

c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Introduction Slide 2

Solving Problems by Searching

COMP5211 Lecture 3: Agents that Search

Problem solving. Chapter 3, Sections 1 3

Foundations of AI. 3. Solving Problems by Searching. Problem-Solving Agents, Formulating Problems, Search Strategies

Foundations of AI. 3. Solving Problems by Searching. Problem-Solving Agents, Formulating Problems, Search Strategies

Informed Search. Read AIMA Some materials will not be covered in lecture, but will be on the midterm.

Outline for today s lecture Informed Search Optimal informed search: A* (AIMA 3.5.2) Creating good heuristic functions Hill Climbing

Artificial Intelligence Uninformed search

COMP9414/ 9814/ 3411: Artificial Intelligence. Week 2. Classifying AI Tasks

COMP9414: Artificial Intelligence Problem Solving and Search

Search then involves moving from state-to-state in the problem space to find a goal (or to terminate without finding a goal).

Solving Problems by Searching

COMP9414/ 9814/ 3411: Artificial Intelligence. 2. Environment Types. UNSW c Alan Blair,

Informed search algorithms. Chapter 3 (Based on Slides by Stuart Russell, Richard Korf, Subbarao Kambhampati, and UW-AI faculty)

Lecture 2: Problem Formulation

Artificial Intelligence

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany, Course on Artificial Intelligence,

Intelligent Agents & Search Problem Formulation. AIMA, Chapters 2,

Searching for Solu4ons. Searching for Solu4ons. Example: Traveling Romania. Example: Vacuum World 9/8/09

2. Environment Types. COMP9414/ 9814/ 3411: Artificial Intelligence. Agent Model. Agents as functions. The PEAS model of an Agent

CS 171, Intro to A.I. Midterm Exam Fall Quarter, 2016

AIMA 3.5. Smarter Search. David Cline

Experimental Comparison of Uninformed and Heuristic AI Algorithms for N Puzzle Solution

Administrivia. CS 188: Artificial Intelligence Spring Agents and Environments. Today. Vacuum-Cleaner World. A Reflex Vacuum-Cleaner

22c:145 Artificial Intelligence

Problem. Operator or successor function - for any state x returns s(x), the set of states reachable from x with one action

UMBC 671 Midterm Exam 19 October 2009

Heuristics & Pattern Databases for Search Dan Weld

Simple Search Algorithms

CS188: Section Handout 1, Uninformed Search SOLUTIONS

Artificial Intelligence. Topic 5. Game playing

Conversion Masters in IT (MIT) AI as Representation and Search. (Representation and Search Strategies) Lecture 002. Sandro Spina

A Historical Example One of the most famous problems in graph theory is the bridges of Konigsberg. The Real Koningsberg

Heuristics, and what to do if you don t know what to do. Carl Hultquist

Adversarial Search 1

Lecture 7. Review Blind search Chess & search. CS-424 Gregory Dudek

Problem 1. (15 points) Consider the so-called Cryptarithmetic problem shown below.

Name: Your EdX Login: SID: Name of person to left: Exam Room: Name of person to right: Primary TA:

Artificial Intelligence Search III

CSE 473 Midterm Exam Feb 8, 2018

CS 188: Artificial Intelligence Spring 2007

Heuristics & Pattern Databases for Search Dan Weld

: Principles of Automated Reasoning and Decision Making Midterm

Artificial Intelligence

Homework Assignment #1

UMBC CMSC 671 Midterm Exam 22 October 2012

Artificial Intelligence. Minimax and alpha-beta pruning

UNIVERSITY of PENNSYLVANIA CIS 391/521: Fundamentals of AI Midterm 1, Spring 2010

1. Compare between monotonic and commutative production system. 2. What is uninformed (or blind) search and how does it differ from informed (or

ARTIFICIAL INTELLIGENCE (CS 370D)

Artificial Intelligence Adversarial Search

Adversarial Search. Human-aware Robotics. 2018/01/25 Chapter 5 in R&N 3rd Ø Announcement: Slides for this lecture are here:

Artificial Intelligence Lecture 3

Games and Adversarial Search II

Overview PROBLEM SOLVING AGENTS. Problem Solving Agents

the question of whether computers can think is like the question of whether submarines can swim -- Dijkstra

Past questions from the last 6 years of exams for programming 101 with answers.

State-Space Search Artificial Intelligence Programming in Prolog Lecturer: Tim Smith Lecture 8 18/10/04 18/10/04 AIPP Lecture 8: State-Space Search 1

Adverserial Search Chapter 5 minmax algorithm alpha-beta pruning TDDC17. Problems. Why Board Games?

Adversarial Search and Game- Playing C H A P T E R 6 C M P T : S P R I N G H A S S A N K H O S R A V I

Recent Progress in the Design and Analysis of Admissible Heuristic Functions

CITS3001. Algorithms, Agents and Artificial Intelligence. Semester 2, 2016 Tim French

Today. Types of Game. Games and Search 1/18/2010. COMP210: Artificial Intelligence. Lecture 10. Game playing

CS61B Lecture #22. Today: Backtracking searches, game trees (DSIJ, Section 6.5) Last modified: Mon Oct 17 20:55: CS61B: Lecture #22 1

CS 771 Artificial Intelligence. Adversarial Search

E190Q Lecture 15 Autonomous Robot Navigation

I am not claiming this report is perfect, or that it is the only way to do a high-quality project. It is simply an example of high-quality work.

10/5/2015. Constraint Satisfaction Problems. Example: Cryptarithmetic. Example: Map-coloring. Example: Map-coloring. Constraint Satisfaction Problems

Game playing. Chapter 5, Sections 1 6

CPS331 Lecture: Heuristic Search last revised 6/18/09

CSE 573 Problem Set 1. Answers on 10/17/08

Programming Project 1: Pacman (Due )

Adversary Search. Ref: Chapter 5

DIT411/TIN175, Artificial Intelligence. Peter Ljunglöf. 2 February, 2018

Heuristic Search with Pre-Computed Databases

Practice Session 2. HW 1 Review

Announcements. Homework 1. Project 1. Due tonight at 11:59pm. Due Friday 2/8 at 4:00pm. Electronic HW1 Written HW1

Artificial Intelligence

Searching To Solve Problems. Paul Dunne GMIT

Set 4: Game-Playing. ICS 271 Fall 2017 Kalev Kask

Artificial Intelligence Ph.D. Qualifier Study Guide [Rev. 6/18/2014]

Lecture 14. Questions? Friday, February 10 CS 430 Artificial Intelligence - Lecture 14 1

CSE 40171: Artificial Intelligence. Adversarial Search: Games and Optimality

5.1 State-Space Search Problems

CS 188 Fall Introduction to Artificial Intelligence Midterm 1

HUJI AI Course 2012/2013. Bomberman. Eli Karasik, Arthur Hemed

Games CSE 473. Kasparov Vs. Deep Junior August 2, 2003 Match ends in a 3 / 3 tie!

Introduction Solvability Rules Computer Solution Implementation. Connect Four. March 9, Connect Four 1

Game Playing State of the Art

A Memory-Efficient Method for Fast Computation of Short 15-Puzzle Solutions

Algorithms for Data Structures: Search for Games. Phillip Smith 27/11/13

COMP9414: Artificial Intelligence Adversarial Search

COMP219: COMP219: Artificial Intelligence Artificial Intelligence Dr. Annabel Latham Lecture 12: Game Playing Overview Games and Search

CS 188: Artificial Intelligence Spring Announcements

Announcements. CS 188: Artificial Intelligence Spring Game Playing State-of-the-Art. Overview. Game Playing. GamesCrafters

Games (adversarial search problems)

CSE 40171: Artificial Intelligence. Adversarial Search: Game Trees, Alpha-Beta Pruning; Imperfect Decisions

Transcription:

Artificial Intelligence Topic 3 Problem Solving and Search Problem-solving and search Search algorithms Uninformed search algorithms breadth-first search uniform-cost search depth-first search iterative deepening search bidirectional search Reading: Russell and Norvig, Chapter 3 c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 35

1. Problem Solving and Search Seen that an intelligent agent has: knowledge of the state of the world a notion of how actions or operations change the world some goals, or states of the world, it would like to bring about Finding a sequence of operations that changes the state of the world to a desired goal state is a search problem (or basic planning problem). Search algorithms are the cornerstone of AI In this section we see some examples of how the above is encoded, and look at some common search strategies. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 36

1.1 States, Operators, Graphs and Trees state description of the world at a particular time impossible to describe the whole world need to abstract those attributes or properties that are important. Examples Example 1: Say we wish to drive from to Bucharest. First we discretise the problem: states map of cities + our location operators drive from one city to the next start state driver located at goal state driver located at Bucharest Find solution: sequence of cities, e.g.,, Sibiu, Fagaras, Bucharest c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 37

1.1 States, Operators, Graphs and Trees The states and operators form a graph states form nodes, operators form arcs or edges... Oradea Neamt Zerind Iasi Sibiu Fagaras Vaslui Timisoara Rimnicu Vilcea Lugoj Pitesti Mehadia Urziceni Hirsova Dobreta Craiova Bucharest Giurgiu Eforie c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 38

1.1 States, Operators, Graphs and Trees Example 2: The eight puzzle 5 4 51 42 3 6 1 8 68 84 7 3 2 7 6 25 Start State Goal State states description of the positions of the numbered squares operators some alternatives... (a) move a numbered square to an adjacent place, or (b) move blank left, right, up or down far fewer operators c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 39

1.1 States, Operators, Graphs and Trees Example 3: Missionaries and Cannibals start state 3 missionaries, 3 cannibals, and a boat that holds two people, on one side of river goal state all on other side states description of legal configurations (ie. where no-one gets eaten) of where the missionaries, cannibals, and boat are operators state changes possible using 2-person boat c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 40

1.1 States, Operators, Graphs and Trees <{MMMCCCB},{}> <{MMCC},{MCB}> <{MMMC},{CCB}> <{MMMCC},{CB}> <[MMMCCB},{C}> <{MMM},{CCCB}> <{MMMCB},{CC}> <{MC},{MMCCB}> <{MMCCB},{MC}> <{CC},{MMMCB}> <{CCCB},{MMM}> <{C},{MMMCCB}> <{CCB},{MMMC}> <{MCB},{MMCC}> <{},{MMMCCCB}> c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 41

1.2 Operator costs Graphs may also contain the cost of getting from one node to another (ie. associated with each operator, or each arc). 71 Oradea Neamt 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 Bucharest 90 Craiova Giurgiu Hirsova 86 Eforie cost of path = sum of the costs of arcs making up the path c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 42

1.2 Operator costs Usually concerned not just with finding a path to the goal, but finding a cheap path. shortest path problem find the cheapest path from a start state to a goal state Where operator costs are not given, all operators are assumed to have unit cost. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 43

1.3 Problem formulation A problem is defined by four items: initial state e.g., at operators (or successor function S(x)) e.g., Zerind Sibiu etc. goal test, can be explicit, e.g., x = at Bucharest implicit, e.g., world peace path cost (additive) e.g., sum of distances, number of operators executed, etc. A solution is a sequence of operators leading from the initial state to a goal state. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 44

2. Search algorithms Basic idea: offline, simulated exploration of state space by generating successors of already-explored states (a.k.a. expanding states) function General-Search(problem, strategy) returns a solution, or failure initialize the search tree using the initial state of problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to strategy if the node contains a goal state then return the corresponding solution else expand node and add resulting nodes to the search tree end c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 45

2.1 General search example Zerind Sibiu Timisoara Oradea Fagaras Rimnicu Vilcea Sibiu Bucharest c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 46

2.2 General search in more detail General search algorithm Given a start state s 0 S, a goal function g(s) {true,false}, and an (optional) terminal condition t(s) {true,false}: Initialise a set U = {s 0 } of unvisited nodes containing just the start state, and an empty set V = {} of visited nodes. 1. If U is empty halt and report no goal found. 2. Select, according to some (as yet undefined) strategy, a node s from U. 3. (Optional) If s V discard s and repeat from 1. 4. If g(s) = true halt and report goal found. 5. (Optional) If t(s) = true discard s and repeat from 1. 6. Otherwise move s to the set V, and add to U all the nodes reachable from s. Repeat from 1. Step 3 is an occurs check for cycles. Some search strategies will still work without this trade-off work to check if visited vs work re-searching same nodes again. Others may cycle forever. With these cycles removed, the graph becomes a search tree. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 47

2.3 Comparing search strategies The search strategy is crucial determines in which order the nodes are expanded. Concerned with: completeness does the strategy guarantee finding a solution if there is one optimality does it guarantee finding the best solution time complexity how long does it take space complexity how much memory is needed to store states Time and space complexity are often measured in terms of b maximum branching factor of the search tree d depth of the least-cost solution m maximum depth of the state space (may be ) c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 48

2.4 Implementation of search algorithms Many strategies can be implemented by placing unvisited nodes in a queue (Step 6) and always selecting the next node to expand from the front of the queue (Step 2) the way the children of expanded nodes are placed in the queue determines the search strategy. Many different strategies have been proposed. We ll look at some of the most common ones... c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 49

3. Uninformed search strategies Uninformed strategies use only the information available in the problem definition Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search Bidirectional search Later we will look at informed stategies that use additional information. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 50

3.1 Breadth-first search Expand shallowest unexpanded node Implementation: QueueingFn = put successors at end of queue Zerind Sibiu Timisoara Oradea Oradea Rimnicu Fagaras Vilcea Lugoj expand all nodes at one level before moving on to the next c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 51

3.1 Breadth-first search Complete? Yes (if b is finite) Time? O(1 + b + b 2 + b 3 +... + b d ) = O(b d ), i.e., exponential in d Space? O(b d ) (all leaves in memory) Optimal? Yes (if cost = 1 per step); not optimal in general Space is the big problem; can easily generate nodes at 1MB/sec so 24hrs = 86GB. Good example of computational explosion... Assume branching factor of 10, 1000 nodes/sec, 100 bytes/node. Depth Nodes Time Memory 0 1 1 millisecond 100 bytes 2 111.1 seconds 11 kilobytes 4 11,111 11 seconds 1 megabyte 6 10 6 18 minutes 111 megabytes 8 10 8 31 hours 11 gigabytes 10 10 10 128 days 1 terabyte 12 10 12 35 years 111 terabytes 14 10 14 3500 years 11,111 terabytes Welcome to AI! c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 52

3.2 Uniform-cost search Problem: Varying cost operations eg. Romania with step costs in km... 71 Oradea Neamt 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 Bucharest 90 Craiova Giurgiu Hirsova 86 Eforie c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 53

3.2 Uniform-cost search Expand least total cost unexpanded node Implementation: QueueingFn = insert in order of increasing path cost 75 140 118 Zerind Sibiu Timisoara 75 71 118 111 Oradea Lugoj c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 54

3.2 Uniform-cost search Complete? Yes (if step cost 0) Time? # of nodes with path cost g cost of optimal solution Space? # of nodes with g cost of optimal solution Optimal? Yes (if step cost 0) c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 55

3.3 Depth-first search Follow one path until you can go no further, then backtrack to last choice point and try another alternative. Implementation: QueueingFn = insert successors at front of queue (or use recursion queueing performed automatically by internal stack) Zerind Sibiu Timisoara Oradea Zerind Sibiu Timisoara Occurs check or terminal condition needed to prevent infinite cycling. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 56

3.3 Depth-first search Finite tree example... c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 57

c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 58

3.3 Depth-first search Complete? No: fails in infinite-depth spaces. complete for finite tree (in particular, require cycle check). Time? O(b m ). may do very badly if m is much larger than d may be much faster than breadth-first if solutions are dense Space? O(bm), i.e., linear space! Optimal? No Space performance is big advantage. Time, completeness and optimality can be big disadvantages. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 59

3.4 Depth-limited search = depth-first search with depth limit l Implementation: Nodes at depth l have no successors. Can be implemented by our terminal condition. Sometimes used to apply depth-first to infinite (or effectively infinite) search spaces. Take best solution found with limited resources. (See Game Playing... ) Also in... c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 60

3.5 Iterative deepening search Probe deeper and deeper (often bounded by available resources). Zerind Sibiu Timisoara Oradea Oradea Fagaras Rimnicu Vilcea Lugoj c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 61

3.5 Iterative deepening search Summary view... c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 62

3.5 Iterative deepening search Complete? Yes Time? (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d O(b d ) Space? O(bd) Optimal? Yes, if step cost = 1 Can also be modified to explore uniform-cost tree How do the above compare with breadth-first? depth-first? c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 63

3.6 Bidirectional search Start Goal Tends to expand fewer nodes than unidirectional, but raises other difficulties eg. how long does it take to check if a node has been visited by other half of search? c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 64

4. Summary Problem formulation usually requires abstracting away real-world details to define a state space that can feasibly be explored. Abstraction reveals states and operators. Evaluation by goal or utility function. Strategy implemented by queuing function (or similar). Variety of uninformed search strategies... Iterative deepening search uses only linear space and not much more time than other uninformed algorithms. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 65

The End c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Problem Solving and Search Slide 66