CS 151: Intelligent Agents, Problem Formulation and Search

Similar documents
AI: A Modern Approach, Chpts. 3-4 Russell and Norvig

Problem solving and search

Measuring the Performance of an Agent

SOLVING PROBLEMS BY SEARCHING

Smart Graphics: Methoden 3 Suche, Constraints

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 313]

Informed search algorithms. Chapter 4, Sections 1 2 1

An Introduction to The A* Algorithm

Y. Xiang, Constraint Satisfaction Problems

cs171 HW 1 - Solutions

Chapter 2 Intelligent Agents

Chapter 2: Intelligent Agents

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

Binary Heaps. CSE 373 Data Structures

CS MidTerm Exam 4/1/2004 Name: KEY. Page Max Score Total 139

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Course Outline Department of Computing Science Faculty of Science. COMP Applied Artificial Intelligence (3,1,0) Fall 2015

Game playing. Chapter 6. Chapter 6 1

Social Media Mining. Graph Essentials

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

Decision Trees and Networks

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

6.852: Distributed Algorithms Fall, Class 2

INTERNATIONAL JOURNAL OF COMPUTER ENGINEERING & TECHNOLOGY (IJCET)

Branch-and-Price Approach to the Vehicle Routing Problem with Time Windows

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

Binary Heaps * * * * * * * / / \ / \ / \ / \ / \ * * * * * * * * * * * / / \ / \ / / \ / \ * * * * * * * * * *

A binary heap is a complete binary tree, where each node has a higher priority than its children. This is called heap-order property

Algorithms and Data S tructures Structures Stack, Queues, and Applications Applications Ulf Leser

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Data Structure [Question Bank]

3515ICT Theory of Computation Turing Machines

A Working Knowledge of Computational Complexity for an Optimizer

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

- 1 - intelligence. showing the layout, and products moving around on the screen during simulation

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

Big O and Limits Abstract Data Types Data Structure Grand Tour.

Lecture 6 Online and streaming algorithms for clustering

Decision Making under Uncertainty

8. KNOWLEDGE BASED SYSTEMS IN MANUFACTURING SIMULATION

Midterm Practice Problems

Lecture 4 Online and streaming algorithms for clustering

Analysis of Algorithms, I

10/13/11 Solution: Minimax with Alpha-Beta Pruning and Progressive Deepening

Lecture 7: Concurrency control. Rasmus Pagh

CSC384 Intro to Artificial Intelligence

Introduction to Artificial Intelligence. Intelligent Agents

Web Data Extraction: 1 o Semestre 2007/2008

Regular Expressions and Automata using Haskell

Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

Approximation Algorithms

CAs and Turing Machines. The Basis for Universal Computation

Current California Math Standards Balanced Equations

Agents: Rationality (2)

Linear Programming for Optimization. Mark A. Schulze, Ph.D. Perceptive Scientific Instruments, Inc.

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Project and Production Management Prof. Arun Kanda Department of Mechanical Engineering Indian Institute of Technology, Delhi

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

Mining Social Network Graphs

Graph Theory Problems and Solutions

Arithmetic Coding: Introduction

The Rise of Industrial Big Data. Brian Courtney General Manager Industrial Data Intelligence

Introduction to Learning & Decision Trees

MIMO detector algorithms and their implementations for LTE/LTE-A

International Journal of Software and Web Sciences (IJSWS)

3 Abstract Data Types and Search

Fast nondeterministic recognition of context-free languages using two queues

CSE 326: Data Structures B-Trees and B+ Trees

SYSM 6304: Risk and Decision Analysis Lecture 5: Methods of Risk Analysis

Operating Systems. Virtual Memory

From Last Time: Remove (Delete) Operation

PPD: Scheduling and Load Balancing 2

Load Balancing. Load Balancing 1 / 24

Common Data Structures

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Cpt S 223. School of EECS, WSU

Introduction to LAN/WAN. Network Layer

Elevator Simulation and Scheduling: Automated Guided Vehicles in a Hospital

General Incremental Sliding-Window Aggregation

Algorithms and Data Structures

A Non-Linear Schema Theorem for Genetic Algorithms

Lecture 2 Introduction to Data Flow Analysis

Asking Hard Graph Questions. Paul Burkhardt. February 3, 2014

Search methods motivation 1

Algorithms and Data Structures

Laboratory work in AI: First steps in Poker Playing Agents and Opponent Modeling

vii TABLE OF CONTENTS CHAPTER TITLE PAGE DECLARATION DEDICATION ACKNOWLEDGEMENT ABSTRACT ABSTRAK

Analysis of Algorithms I: Binary Search Trees

Visual Data Mining. Motivation. Why Visual Data Mining. Integration of visualization and data mining : Chidroop Madhavarapu CSE 591:Visual Analytics

Classification/Decision Trees (II)

Faster deterministic integer factorisation

Previous Lectures. B-Trees. External storage. Two types of memory. B-trees. Main principles

Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method

Transcription:

CS 151: Intelligent Agents, Problem Formulation and Search

How do we make a vacuum "smart?" Vacuum, clean the house! Um OK?? This one's got no chance

How do we represent this task? Hmmm where to begin? We want the vacuum to "clean the house." What does this mean? What's involved for the vacuum cleaner? How can we formalize this problem a bit?

Vacuum Cleaner World Percepts: location and contents, e.g., [A,Dirty] Actions: Left, Right, Suck, NoOp

Rational Agents Rational Agent = An agent (program) that does the "right" thing, given its goals, its abilities, what it perceives of its environment and its prior knowledge What do we need to know in order to decide if the vacuum cleaner is rational?

What does the agent DO? Our goal as AI programmers is develop agents that behave rationally. This means we must specify what the agent does given: Its goals Its precepts (what is perceives) Its possible actions Its prior knowledge This plan of action is the agent's policy or agent function AI Programming = Policy Design and Implementation

Defining a Policy How might we define a policy for the vacuum agent above if the goal is to clean both rooms?

Techniques for Implementing Policies Search Reasoning with knowledge and uncertainty Reasoning with Utility At the core of this class will be several techniques for Policy design and implementation Learning

Task Environments Deterministic, fully observable single-state problem Agent knows exactly which state it will be in; solution is a sequence of actions Non-observable sensorless (conformant) problem Agent may have no idea where it is; solution is a sequence Nondeterministic and/or partially observable contingency problem percepts provide new information about current state often interleave search, execution Unknown state space exploration problem

Example: vacuum world Single-state, start in #5.

Example: vacuum world Sensorless, start in {1,2,3,4,5,6,7,8} e.g., Right goes to {2,4,6,8}

Example: Vacuum world Contingency Nondeterministic: Suck may dirty a clean carpet Partially observable: location, dirt at current location. Percept: [L, Clean], i.e., start in #5 or #7

Vacuum world Search-based agent 1. Formulate problem and goal 2. Search for a sequence of actions that will lead to the goal (the policy) 3. Execute the actions one at a time

Vacuum world Search-based agent 1. Formulate problem and goal 2. Search for a sequence of actions that will lead to the goal (the policy) 3. Execute the actions one at a time Well-defined problem: (State space) Initial state Goal test Actions/Successor function Path cost

Vacuum world States: Shown above Actions: R, L, S, NoOp Successor function given by state graph (next slide) Goal test: In state 7 or 8? Path cost: +1 for each move and each suck

Vacuum world state space graph

Some example problems Toy problems and microworlds 8-Puzzle Missionaries and Cannibals Water Jug Problem Roomers NQueens Real-world problems

Another problem: 8-Puzzle

8-puzzle goal states? actions? path cost?

8-Puzzle state: all 3 x 3 configurations of the tiles on the board actions: Move Blank Square Left, Right, Up or Down. This is a more efficient encoding than moving each of the 8 distinct tiles path cost: +1 for each action

The 8-Queens Problem State transition:? Initial State:? Actions:? Goal: Place eight queens on a chessboard such that no queen attacks any other!

Missionaries and Cannibals Three missionaries and three cannibals wish to cross the river. They have a small boat that will carry up to two people. Everyone can navigate the boat. If at any time the Cannibals outnumber the Missionaries on either bank of the river, they will eat the Missionaries. Find the smallest number of crossings that will allow everyone to cross the river safely.

Water Jug Problem Given a full 5-gallon jug and a full 2-gallon jug, fill the 2-gallon jug with exactly one gallon of water. 5 2

Roomers: Baker, Cooper, Fletcher, Miller, and Smith live on different floors of an apartment house that contains only five floors. Baker does not live on the top floor. Cooper does not live on the bottom floor. Fletcher does not live on either the top or the bottom floor. Miller lives on a higher floor than does Cooper. Smith does not live on a floor adjacent to Fletcher s. Fletcher does not " live on a floor adjacent to Cooper s. Where does everyone live? " " [Taken verbatim from Abelson and Sussman, Structure and Interpretation of " Computer Programs, second edition, M.I.T. Press, 1996. The authors attribute " the puzzle to Dinesman, Superior Mathematical Puzzles, Simon and Schuster, " 1968.] "

Some real-world problems Route finding directions, maps computer networks airline travel VLSI layout Touring (traveling salesman) Agent planning

Search-based agent 1. Formulate problem and goal 2. Search for a sequence of actions that will lead to the goal (the policy) 3. Execute the actions one at a time

Search algorithms We ve defined the problem Now we want to find the solution! Use search techniques offline, simulated exploration of state space by generating successors of already-explored states (a.k.a. expanding states) Start at the initial state and search for a goal state What are candidate search techniques? BFS DFS

Finding the path: Tree search algorithms Basic idea: offline, simulated exploration of state space by generating successors of already-explored states (a.k.a. expanding states) def TreeSearch(problem, strategy): initialize search tree using information in the problem while true: if there are no candidates for expansion, return failure choose a leaf node for expansion according to strategy if node contains goal state, return solution else expand node and add resulting nodes to search tree

Careful! states vs. nodes A state is a (representation of) a physical configuration A node is a data structure constituting part of a search tree includes state, parent node, action, path cost g(x), depth The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states.

Implementation: general tree search

Tree Search Algorithm 1. Add the initial state (root) to the <fringe> 2. Choose a node (curr) to examine from the <fringe> (if there is nothing in <fringe> - FAILURE) 3. Is curr a goal state? If so, SOLUTION If not, continue 4. Expand curr by applying all possible actions (add the new resulting states to the <fringe>) 5. Go to step 2

Search strategies A search strategy is defined by picking the order of node expansion How to evaluate a strategy?

Uninformed search strategies Uninformed search strategies use only the information available in the problem definition Depth First Search Breadth First Search

Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end

Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end

Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end

Breadth-first search Expand shallowest unexpanded node Implementation: fringe is a FIFO queue, i.e., new successors go at end

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Depth-first search Expand deepest unexpanded node Implementation: fringe = LIFO queue, i.e., put successors at front

Search algorithm properties Time (using Big-O) approximate the number of nodes generated (not necessarily examined) Space (using Big-O) the max # of nodes stored in memory at any time Complete If a solution exists, will we find it? Optimal If we return a solution, will it be the best/optimal (really just shallowest) solution

Activity Analyze DFS and BFS according to the criteria time, space, completeness and optimality (for time and space, analyze in terms of b, d, and m (max depth); for complete and optimal - simply YES or NO) Which strategy would you use and why? Brainstorm improvements to DFS and BFS

BFS Time: O(b d+1 ) Space: O(b d+1 ) Complete = YES Optimal = YES

Time and Memory requirements for BFS Depth Nodes Time Memory 2 1100.11 sec 1 MB 4 111,100 11 sec 106 MB 6 10 7 19 min 10 GB 8 10 9 31 hours 1 terabyte 10 10 11 129 days 101 terabytes 12 10 13 35 years 10 petabytes 14 10 15 3,523 years 1 exabyte BFS with b=10, 10,000 nodes/sec; 10 bytes/node

DFS Time: O(b m ) Space: O(bm) Complete = YES, if space is finite (and no circular paths), NO otherwise Optimal = NO

Problems with BFS and DFS BFS memory! DFS Not optimal And not even necessarily complete!

Ideas? Can we combined the optimality and completeness of BFS with the memory of DFS? + =

Depth limited DFS DFS, but with a depth limit L specified nodes at depth L are treated as if they have no successors we only search down to depth L Time? O(b^L) Space? O(bL) Complete? No, if solution is longer than L Optimal No, for same reasons DFS isn t

Ideas?

Iterative deepening search For depth 0, 1,., run depth limited DFS if solution found, return result Blends the benefits of BFS and DFS searches in a similar order to BFS but has the memory requirements of DFS Will find the solution when L is the depth of the shallowest goal

Iterative deepening search L =0

Iterative deepening search L =1

Iterative deepening search L =2

Iterative deepening search L =3

Time? L = 0: 1 L = 1: 1 + b L = 2: 1 + b + b 2 L = 3: 1 + b + b 2 + b 3 L = d: 1 + b + b 2 + b 3 + + b d Overall: d(1) + (d-1)b + (d-2)b 2 + (d-3)b 3 + + b d O(b d ) the cost of the repeat of the lower levels is subsumed by the cost at the highest level

Properties of iterative deepening search Space? O(bd) Complete? Yes Optimal? Yes

Missionaries and Cannibals Solution Near side Far side! 0 Initial setup: MMMCCC B -! 1 Two cannibals cross over: MMMC B CC! 2 One comes back: MMMCC B C! 3 Two cannibals go over again: MMM B CCC! 4 One comes back: MMMC B CC! 5 Two missionaries cross: MC B MMCC! 6 A missionary & cannibal return: MMCC B MC! 7 Two missionaries cross again: CC B MMMC! 8 A cannibal returns: CCC B MMM! 9 Two cannibals cross: C B MMMCC! 10 One returns: CC B MMMC! 11 And brings over the third: - B MMMCCC!

Water Jug Problem Operator table 5 2 State = (x,y), where x is the number of gallons of water in the 5-gallon jug and y is # of gallons in the 2-gallon jug Initial State = (5,2) Goal State = (*,1), where * means any amount Name Cond. Transition Effect Empty5 (x,y) (0,y) Empty 5-gal. jug Empty2 (x,y) (x,0) Empty 2-gal. jug 2to5 x 3 (x,2) (x+2,0) Pour 2-gal. into 5-gal. 5to2 x 2 (x,0) (x-2,2) Pour 5-gal. into 2-gal. 5to2part y < 2 (1,y) (0,y+1) Pour partial 5-gal. into 2- gal.

The 8-Queens Problem State transition:? Initial State:? Actions:? Goal: Place eight queens on a chessboard such that no queen attacks any other!

Roomers: Baker, Cooper, Fletcher, Miller, and Smith live on different floors of an apartment house that contains only five floors. Baker does not live on the top floor. Cooper does not live on the bottom floor. Fletcher does not live on either the top or the bottom floor. Miller lives on a higher floor than does Cooper. Smith does not live on a floor adjacent to Fletcher s. Fletcher does not " live on a floor adjacent to Cooper s. Where does everyone live? " " [Taken verbatim from Abelson and Sussman, Structure and Interpretation of " Computer Programs, second edition, M.I.T. Press, 1996. The authors attribute " the puzzle to Dinesman, Superior Mathematical Puzzles, Simon and Schuster, " 1968.] "

Breadth-first search of the 8-puzzle - # of node denotes order in which the nodes are visited.

Depth-first search of the 8-puzzle with a depth bound of 5 (order on node denotes the order in which the nodes are examined - this pic is missing some nodes that were added but not examined).

Two heuristics applied to states in the 8-puzzle.

The heuristic f applied to states in the 8-puzzle.

State space generated in heuristic search of the 8- puzzle graph.