SEARCH David Kauchak CS30 – Spring 2016. Admin Assignment 6 graded Assignment 7  1 extra day: Due 3/26 at 6pm  If you turn it in by the original due.

Slides:



Advertisements
Similar presentations
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
Advertisements

CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 03 / 27 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
Uninformed Search Jim Little UBC CS 322 – Search 2 September 12, 2014
SEARCH ALGORITHMS David Kauchak CS30 – Spring 2015.
UNINFORMED SEARCH Problem - solving agents Example : Romania  On holiday in Romania ; currently in Arad.  Flight leaves tomorrow from Bucharest.
CS112: Course Overview George Mason University. Today’s topics Go over the syllabus Go over resources – Marmoset – Blackboard – Piazza – Textbook Highlight.
SEARCH APPLICATIONS David Kauchak CS30 – Spring 2015.
Backtracking COP Backtracking  Backtracking is a technique used to solve problems with a large search space, by systematically trying and eliminating.
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
CSE332: Data Abstractions Lecture 16: Topological Sort / Graph Traversals Tyler Robison Summer
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 11 / 10 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 03 / 30 / 2007 Instructor: Michael Eckmann.
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
CS 206 Introduction to Computer Science II 03 / 30 / 2009 Instructor: Michael Eckmann.
Today’s quiz on 8.2 A Graphing Worksheet 1 will be given at the end of class. You will have 12 minutes to complete this quiz, which will consist of one.
Please open your laptops, log in to the MyMathLab course web site, and open Daily Quiz 16. IMPORTANT NOTE: If you have time left out of your five minutes.
For Friday Finish chapter 3 Homework: –Chapter 3, exercise 6 –May be done in groups. –Clarification on part d: an “action” must be running the program.
Make sure you know the day and time of the final exam for this section of Math 110: Day: ______ Date:______ Time: ______ to _______ All Math 110 finals.
PHP and SQL Server: Queries IST2101. Project Report 4 SQL Queries Due Sunday, 4/5 at 11:59pm Instructions on how to access team webspace and SQL database.
Extending MATLAB Write your own scripts and/or functions Scripts and functions are plain text files with extension.m (m-files) To execute commands contained.
Go to our website, and click on the eMedia Catalog link To find books, either click on the advanced search (which I will.
Please open Daily Quiz 34. A scientific calculator may be used on this quiz. You can keep your yellow formula sheets out when you take the quiz. Remember.
CS 106 Introduction to Computer Science I 04 / 13 / 2007 Friday the 13 th Instructor: Michael Eckmann.

Backtracking. N-Queens The object is to place queens on a chess board in such a way as no queen can capture another one in a single move –Recall that.
CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
1 Solving problems by searching This Lecture Chapters 3.1 to 3.4 Next Lecture Chapter 3.5 to 3.7 (Please read lecture topic material before and after each.
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
BackTracking CS335. N-Queens The object is to place queens on a chess board in such as way as no queen can capture another one in a single move –Recall.
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.
SEARCH David Kauchak CS30 – Spring Admin Assignment 7 due tomorrow Assignment 8 out soon Talk today 4:15 in Rose Hills Theatre.
Please get out your completed 8.2B Graphing Worksheet 2 and pass it to the center aisle to be collected by the TA.
Diagnostic Pathfinder for Instructors. Diagnostic Pathfinder Local File vs. Database Normal operations Expert operations Admin operations.
“Planning is bringing the future into the present so that you can do something about it now.” – Alan Lakein Thought for the Day.
+ Review CS302 Spring 2013 David Kauchak. + Admin Final posted on the course web page on Monday due Sunday at 11:59pm time-boxed (3-4 hours) You may use:
C++ crash course Class 8 statements, sort, flight times program.
Please snarf the code for today’s class. Then think about the famous 8-Queen’s Puzzle. The question is: is there a way to arrange 8 queens on a (8x8) chessboard.
For Monday Read chapter 4, section 1 No homework..
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
Intro to CS ACO 101 Lab Rat. Academic Integrity What does that mean in programming? Log into Blackboard and take the test titled “Applied Computing Course.
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Problem solving by search Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
CS112: Course Overview George Mason University. Today’s topics Go over the syllabus Go over resources – Marmoset – Blackboard – Piazza – Textbook Highlight.
Breadth-first and depth-first traversal Prof. Noah Snavely CS1114
Computer/Human Interaction Spring 2013 Northeastern University1 Name of Interface Tagline if you have one (80 chars max, including spaces) Team member.
Breadth-first and depth-first traversal CS1114
Object Orientated Programming in Perl Simulated Models of Termites.
Graphs + Shortest Paths David Kauchak cs302 Spring 2013.
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
ARTIFICIAL INTELLIGENCE
BackTracking CS255.
David Kauchak CS52 – Spring 2016
Using a Stack Chapter 6 introduces the stack data type.
Some Tips for Using Eclipse
GDSS – Digital Signature
Data Structures – Stacks and Queus
Using a Stack Chapter 6 introduces the stack data type.
CMSC201 Computer Science I for Majors Lecture 19 – Recursion
Debugging Taken from notes by Dr. Neil Moore
Using a Stack Chapter 6 introduces the stack data type.
Using a Stack Chapter 6 introduces the stack data type.
Debugging Taken from notes by Dr. Neil Moore
Graph Algorithms "A charlatan makes obscure what is clear; a thinker makes clear what is obscure. " - Hugh Kingsmill CLRS, Sections 22.2 – 22.4.
Scripts In Matlab.
David Kauchak CS51A – Spring 2019
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
Presentation transcript:

SEARCH David Kauchak CS30 – Spring 2016

Admin Assignment 6 graded Assignment 7  1 extra day: Due 3/26 at 6pm  If you turn it in by the original due date (3/25 at 6pm), 5% extra credit Assignment 8 out soon Office hours end today at 3:40 (instead of 4)

A few last things about classes Look at rectangle3.py code  Taking objects of the same type as parameters (e.g. equals)  Calling methods inside the class  Instance variables do NOT have to be the same thing as the parameters for the constructor

Assignment 7 comments Think about how you want to use the objects (i.e. your program) and let that motivate the class design, i.e. the methods, etc. Class names should be capitalized  CamelCase class names that are multiple words class PomonaStudent class WalkieTalkie class StarWarsCreature “pass”

Assignment 7 comments If your program requires a file to work (i.e. to read data from):  create a folder: first-last-assign7  put both the.py file and the.txt file in there  zip of the folder and submit that Be careful about filenames!  files have extensions (that are sometimes hidden by the OS). On mac, you can do CMD+i to get information about the file, including the full filename  We’re only reading.txt file (other files have formatting information!) Wing saves files just as text files automatically (though you’ll need to make sure to include the.txt extension) TextEdit: Format -> Make Plain Text Windows: Use notepad (or in Word, “Save as…” and select.txt

Other ways of reading from a file reader = open(“myfile.txt”, “r”) Read the whole file: next_line = reader.readline() Read one line of the file: for line in reader: # do something with each line of the file

Think like a human Cognitive Modeling Think rationally Logic-based Systems Act like a human Turing Test Act rationally Rational Agents What is AI? Rest of the semester

Think like a human Cognitive Modeling Think rationally Logic-based Systems Act like a human Turing Test Act rationally Rational Agents What is AI? Next couple of weeks

Solve the maze!

How did you figure it out?

One approach What now?

One approach Three choices

One approach What now? Pick one!

One approach Still three options! Which would you explore/pick?

One approach Most people go down a single path until they realize that it’s wrong

One approach Keep exploring

One approach Keep exploring

One approach What now?

One approach Are we stuck? No. Red positions are just possible options we haven’t explored

One approach How do we know not to go left?

One approach Have to be careful and keep track of where we’ve been if we can loop

One approach Now what?

One approach Now what?

One approach

Search problems What information do we need to figure out a solution?

Search problems Where to start Where to finish (goal) What the “world” (in this case a maze) looks like  We’ll define the world as a collection of discrete states  States are connected if we can get from one state to another by taking a particular action  This is called the “state space”

State space example

… … …

For a given problem, still could have different state-spaces How many more states are there?

State space example

Solving the maze

How what?

Solving the maze

How what?

Solving the maze How what?

Solving the maze Could we have found it any other way?

Search algorithm Keep track of a list of states that we could visit, we’ll call it “to_visit” General idea:  take a state off the to_visit list  if it’s the goal state we’re done!  if it’s not the goal state Add all of the successive states to the to_visit list repeat

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat How do we start?

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat Add start not to to_visit 1

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat Add start not to to_visit

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat Is it a goal state?

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat Which one?

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat 3434 Is it a goal state?

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat 3434 Where should we add them in the list?

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat Let’s add them to the front

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat 3434

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat 3434 What do we do here?

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat 3434 list keeps track of where to go next, i.e. the states we know about but haven’t explored

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat 4

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat 7474

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat 4

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat What type of structure/list is the to_visit list? It’s a stack!!! (LIFO)

to_visit take a state off the to_visit list - if it’s the goal state we’re done! - if it’s not the goal state Add all of the successive states to the to_visit list repeat What would happen if it was a queue? 1

Search algorithms add the start state to to_visit Repeat  take a state off the to_visit list  if it’s the goal state we’re done!  if it’s not the goal state Add all of the successive states to the to_visit list

Search algorithms add the start state to to_visit Repeat  take a state off the to_visit list  if it’s the goal state we’re done!  if it’s not the goal state Add all of the successive states to the to_visit list Depth first search (DFS): to_visit is a stack Breadth first search (BFS): to_visit is a queue

N-queens problem Place N queens on an N by N chess board such that none of the N queens are attacking any other queen. Solution(s)?

N-queens problem Place N queens on an N by N chess board such that none of the N queens are attacking any other queen.

N-queens problem Place N queens on an N by N chess board such that none of the N queens are attacking any other queen. Solution(s)?

N-queens problem Place N queens on an N by N chess board such that none of the N queens are attacking any other queen. How do we solve this with search: What is a state? What is the start state? What is the goal? How do we transition from one state to the next?

Search algorithm add the start state to to_visit Repeat  take a state off the to_visit list  if it’s the goal state we’re done!  if it’s not the goal state Add all of the successive states to the to_visit list Any problem that we can define these three things can be plugged into the search algorithm! Is this a goal state? What states can I get to from the current state?

N queens problem