CS Fall 2016 (Shavlik©), Lecture 8, Week 5

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Knowledge Representation
Advertisements

Review: Search problem formulation
Heuristic Search techniques
Algorithms (and Datastructures) Lecture 3 MAS 714 part 2 Hartmut Klauck.
State Space Heuristic Search. Three Algorithms  Backtrack  Depth First  Breadth First All work if we have well-defined:  Goal state  Start state.
State Space 3 Chapter 4 Heuristic Search. Three Algorithms Backtrack Depth First Breadth First All work if we have well-defined: Goal state Start state.
January 26, 2003AI: Chapter 3: Solving Problems by Searching 1 Artificial Intelligence Chapter 3: Solving Problems by Searching Michael Scherger Department.
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
Review: Search problem formulation
MAE 552 – Heuristic Optimization Lecture 27 April 3, 2002
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
Using Search in Problem Solving
CS 188: Artificial Intelligence Spring 2006 Lecture 2: Queue-Based Search 8/31/2006 Dan Klein – UC Berkeley Many slides over the course adapted from either.
3.0 State Space Representation of Problems 3.1 Graphs 3.2 Formulating Search Problems 3.3 The 8-Puzzle as an example 3.4 State Space Representation using.
1 State Space of a Problem Lecture 03 ITS033 – Programming & Algorithms Asst. Prof.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l all learning algorithms,
Today’s Topics FREE Code that will Write Your PhD Thesis, a Best-Selling Novel, or Your Next Methods for Intelligently/Efficiently Searching a Space.
Graphs. Made up of vertices and arcs Digraph (directed graph) –All arcs have arrows that give direction –You can only traverse the graph in the direction.
For Monday Read chapter 4, section 1 No homework..
Lecture 3: Uninformed Search
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Today’s Topics Exam Thursday Oct 22. 5:30-7:3-pm, same room as lecture Makeup Thursday Oct 29? Or that Monday or Wednesday? Exam Covers Material through.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Lecture 3: Uninformed Search
Review: Tree search Initialize the frontier using the starting state
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
ARTIFICIAL INTELLIGENCE
BackTracking CS255.
EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS
Last time: Problem-Solving
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
Backtracking And Branch And Bound
Csc 2720 Instructor: Zhuojun Duan
Lesson Objectives Aims Understand the following “standard algorithms”:
ECE 448 Lecture 4: Search Intro
Introduction to Artificial Intelligence
i206: Lecture 13: Recursion, continued Trees
Analysis and design of algorithm
Artificial Intelligence
Uniformed Search (cont.) Computer Science cpsc322, Lecture 6
Motion Planning for a Point Robot (2/2)
CSPs: Search and Arc Consistency Computer Science cpsc322, Lecture 12
CS 188: Artificial Intelligence Spring 2007
Heuristic search INT 404.
CS 188: Artificial Intelligence Fall 2008
Problem Solving and Searching
CS Fall 2016 (Shavlik©), Lecture 9, Week 5
Artificial Intelligence
CS Fall 2016 (Shavlik©), Lecture 10, Week 6
Problem Solving and Searching
BEST FIRST SEARCH -OR Graph -A* Search -Agenda Search CSE 402
Artificial Intelligence
Artificial Intelligence
CO Games Development 1 Week 8 Depth-first search, Combinatorial Explosion, Heuristics, Hill-Climbing Gareth Bellaby.
Heuristic Search Methods
HW 1: Warmup Missionaries and Cannibals
Informed Search Idea: be smart about what paths to try.
State-Space Searches.
ARTIFICIAL INTELLIGENCE
Heuristic Search Generate and Test Hill Climbing Best First Search
State-Space Searches.
HW 1: Warmup Missionaries and Cannibals
CMSC 471 Fall 2011 Class #4 Tue 9/13/11 Uninformed Search
David Kauchak CS51A – Spring 2019
Reading: Chapter 4.5 HW#2 out today, due Oct 5th
State-Space Searches.
Informed Search Idea: be smart about what paths to try.
EMIS 8374 Search Algorithms Updated 12 February 2008
Lecture 4: Tree Search Strategies
Presentation transcript:

CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5 11/18/2018 Today’s Topics FREE Code that will Write Your PhD Thesis, a Best-Selling Novel, or Your Next Email Methods for Intelligently/Efficiently Searching a Space of Possible Solutions Depth, Breadth, Best-first Search Casting a Task as a Search Problem An Infinite Space 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

Generating Great Text is Easy, Discarding the Junk is Hard WriteMyThesis(int expectedLengthInChars) let text = “” while (random() > 1.0 / expectedLengthInChars) text += getRandomASCIIcharacter() if (acceptable(text)) return text else return WriteMyThesis(expectedLengthInChars) 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

Visualizing AI Search as Discrete Graphs Nodes: an importance aspect of the problem Directed Arcs: legal transitions between nodes Weights (optional): cost of traversing an arc Note: nodes usually a complex data structure (eg, a tree) 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

Recall: Aspects of an AI Search Algorithm Search Space Where we are looking; for now this will be a DISCRETE SPACE Operators Legal ways to move from one node to another Search Strategy How we decide which move to make next Heuristic Function Some search methods score nodes to help guide search strategy (optional) Start Node(s) Where we start (usually a single node, but could be a set) Goal Node(s) How we know we are done (sometimes we’ll have an end test, ie code that says ‘DONE!’) 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

The KEY Question of AI Search Given a set of search-space nodes, which one should we ‘consider’ next? The youngest (most recently created)? This is DEPTH-FIRST SEARCH (DFS) The oldest (least recently created)? This is BREATH-FIRST SEARCH (BFS) A random choice? SIMULATED ANNEALING (SA) does this The best (need some scoring function)? This is BEST-FIRST SEARCH (BEST) 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

Another Task Viewed as AI Search – the ‘8 Puzzle’ Possible heuristic (for scoring nodes)? 1 3 5 6 7 2 4 8 Start State i) Count of #’s in wrong cell ii) Sum of moves if ‘collisions’ allowed Legal moves: slide number into empty cell (‘state space’ drawn on blackboard) In AI we build the state space as we go, and rarely generate the whole space. In HWs and textbooks, we often are given the WHOLE space, but that is misleading. 1 2 3 4 5 6 7 8 Goal State 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5 Designing Heuristics One good method is to think of a ‘relaxed’ (ie, simplified version) of the task This guides the search algo, while the search algo works out the details of the unrelaxed version Eg, in ROUTE PLANNING, assume one can ‘drive as the crow flies’ directly to the goal state (aka, ‘straight-line’ or Euclidean distance) 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

General Pseudocode for Searching The following is the basic outline for the various search algorithms (some steps need to be modified depending on the specifics of the search being used).   OPEN = { startNode } // Nodes under consideration. CLOSED = { } // Nodes that have been expanded. While OPEN is not empty Remove the first item from OPEN. Call this item X. If goalState?(X) return the solution found. // Expand node X if it isn’t a goal state. Add X to CLOSED. // Prevents infinite loops. Generate the immediate neighbors (i.e., children) of X. Eliminate those children already in OPEN or CLOSED. Based on the search strategy, insert the remaining children into OPEN. Return FAILURE // Failed if OPEN exhausted w/o a goal found. Called ‘expanding’ a node 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

Variations of “Return Solution” CS 540 Fall 2015 (Shavlik) 11/18/2018 Variations of “Return Solution” Might simply return SUCCESS Or return the GOAL node (this is what ID3 does) Or return PATH found from START to GOAL eg, if planning a route to travel in a GPS Proper choice is problem specific 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

Data Structures for OPEN Breadth-first Use a ‘queue’ (first in, first out; FIFO) OPEN  OPEN + RemainingChildren Depth-first Use a ‘stack’ (last in, first out; LIFO) OPEN  RemainingChildren + OPEN Best-first Use a ‘priority queue’ OPEN  sort(OPEN + RemainingChildren) 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

Example (via blackboard) - assume LOWER scores are better Start score = 9 B score = 11 C score = 8 D score = 4 Use these headers for HW2, Problem 2 Goal score = 0 E score = 3 Step# OPEN CLOSED X CHILDREN RemainingCHILDREN (this part done on blackboard for BFS, DFS, and BEST) 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5 BFS - remember we fill out line n+1 while working on line n Step# OPEN CLOSED X CHILDREN RemainingCHILDREN 1 { S } { } S { S, B, C} { B, C } 2 { B, C } { S } B { D } { D } 3 { C, D } { S, B } C { G } { G } 4 { D, G } { S, B, C} D { C, E } { E } 5 { G, E} { S, B, C, D} G DONE - note we check for GOALS upon removal from OPEN in order to get SHORTEST PATHS in later algo’s BEST - we now need to record the heuristic score and sort OPEN 1 { S9 } { } S9 { S9, B11, C8} { B11, C8 } 2 { C8, B11 } { S9 } C8 { G0 } { G0 } 3 { G0, B11 } { S9, C8} G0 DONE 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5 DFS - remember we fill out line n+1 while working on line n Step# OPEN CLOSED X CHILDREN RemainingCHILDREN 1 { S } { } S { SS, BS, CS} { BS, CS } 2 { BS, CS } { S } BS { DB } { DB } 3 { DB, CS } { S, BS } DB { CD, ED } { ED } 4 { ED, CS } { S, BS, DB} ED { GE } { GE } 5 { GE, CS } {S,BS,DB,ED} GE DONE Notice we did not get the shortest path here (BFS did, though) We might want to also record the PARENT of each node reached, so we can easily extract the path from START to GOAL. This was done in the above using SUPERSCRIPTs 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

Think before you compute! LOWER Better or Worse? Need to carefully check if lower scores are better or worse Our default is lower is better, because often the score is ‘estimated distance to goal’ For algo’s where HIGHER is better (hill climbing, simulated annealing), use scoretoUse = - scoreoriginal Think before you compute! 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

A ‘Blocks World’ Example Initial State Goal State A B A B C C ‘Preconditions’ of a legal move(?x, ?y) action: clearTop(?x) ˄ clearTop(?y) ˄ ?x ≠ ?y Heuristic? One possibility: # blocks in correct final position 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5 An INFINITE Space Legal actions: A) add TWO blocks (from an infinite bin) to an existing tower B) add ONE block to an existing tower Initial state: ONE block on the table (ie, a tower of height 1) Goal state: a tower of height TWO What might go wrong? might produce tower of height 3, of height 5, … 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5

A (Hollywood) Famous AI Puzzle Task: put exactly 4 gallons of water in a 5 gallon jug, given a hose and an infinite supply of water a 3 gallon jug (no ‘depth’ markings on the jug) a 5 gallon jug Operators Can fully empty or fill either jug Can pour Jug ?A into Jug ?B until ?A empty or ?B full From the movie ‘Die Hard’ 10/4/16 CS 540 - Fall 2016 (Shavlik©), Lecture 8, Week 5