Basic search
This presentation is the property of its rightful owner.
Sponsored Links
1 / 34

Lirong Xia PowerPoint PPT Presentation


  • 74 Views
  • Uploaded on
  • Presentation posted in: General

Basic search. Lirong Xia. Reminder. TA OH Joe Johnson (mainly in charge of the project): Wed 12:30-1:30 pm, Amos Eaton 217 Hongzhao Huang (everything else): Thur 12:30-1:30 pm, Amos Eaton 125 Project0 due on next Tuesday Jan 28 midnight LMS working! 2 points

Download Presentation

Lirong Xia

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Lirong xia

Basic search

Lirong Xia


Reminder

Reminder

  • TA OH

    • Joe Johnson (mainly in charge of the project): Wed 12:30-1:30 pm, Amos Eaton 217

    • HongzhaoHuang (everything else): Thur 12:30-1:30 pm, Amos Eaton 125

  • Project0 due on next Tuesday Jan 28 midnight

    • LMS working!

    • 2 points

    • submission instruction changed, if you have uploaded project 0, please re-submit it

  • Sign up on piazza by Jan 28 midnight (1 point)

  • Try your best to use piazza for Q/A

  • You are encouraged to stop me and ask questions in class


Last class

Last class


Welcome back to the earth

Welcome back to the earth


Today s schedule

Today’s schedule

  • Rational agents

  • Search problems

    • State space graph vs search trees

  • Uninformed search

    • Depth first search (DFS) algorithm

    • Breadth first search (BFS) algorithm


Rational agents

Rational Agents

Agent

  • An agent is an entity that perceives and acts.

  • A rational agent selects actions that maximize its utility function.

  • Characteristics of the percepts, environment, and action space dictate techniques for selecting rational actions.

Actuators

Sensors

Percepts

Actions

Environment


Pacman as an agent

Pacman as an Agent

Agent

Sensors

Percepts

Environment

?

Actuators

Actions


Reflex vs goal based agents

Reflex vs goal-based Agents

  • Reflex agents:

    • Act on how the world IS

    • Do not consider the future consequences of their actions

  • Goal-based agents:

    • Plan ahead

    • Act on how the world WOULD BE

    • Must have a model of how the world evolves in response to actions

  • We will be interested in goal-based agents in this class


When goal search for something

When goal = search for something


More general than you may think

More general than you may think


Can we teach agents how to search for all of these

Can we teach agents how to search for all of these?


Warning leisure time is over let s do science

WARNING: leisure time is over!Let’s do science


Search problems

Search Problems

  • A search problem consists of:

    • A state space ……

    • A successor function

      (with actions, costs)

    • A start state and a goal test

  • A solution is a sequence of actions (a plan) which transforms the start state to a goal state


What s in a state space

What’s in a State Space?

The world state specifies every last detail of the environment

A search state keeps only the details needed (abstraction)

  • Problem: Pathing

    • States: (x,y) location

    • Actions: NSEW

    • Successor: adjacent locations

    • Goal test: is (x,y) = END

  • Problem: Eat-All-Dots

    • States: {(x,y), dot booleans}

    • Actions: NSEW

    • Successor: updated location and dot booleans

    • Goal test: dots all false


State space sizes

State Space Sizes?

  • World state:

    • Agent positions: 120

    • Food count: 30

    • Ghost positions: 12

    • Agent facing: NSEW

  • How many

    • World states?

    • States for pathing?

    • States for eat-all-dots?


State space graphs

State Space Graphs

  • State space graph: A mathematical representation of a search problem

    • For every search problem, there’s a corresponding state space graph

    • The successor function is represented by arcs

  • We can rarely build this graph is memory (so we don’t)

Ridiculously tiny search graph for a tiny search problem


Search trees

Search Trees

  • A search tree:

    • This is a “what if” tree of plans and outcomes

    • Start state at the root node

    • Children correspond to successors

    • Nodes contain states, correspond to PLANS to those states

    • For most problems, we can never actually build the whole tree


Generic search algorithm

Generic search algorithm

  • Fringe = set of nodes generated but not expanded

    = nodes we know we still have to explore

  • fringe := {node corresponding to the initial state}

  • loop:

    • if fringe empty, declare failure

    • choose and remove a node v from fringe

    • check if v’s state s is a goal state; if so, declare success

    • if not, expand v, insert resulting nodes into fringe

  • Key question in search: Which of the generated nodes do we expand next?


Example 2 capital region

Example 2: Capital Region

Cohoes

  • State space:

    • Cities

  • Successor function:

    • Roads: Go to adjacent city with cost = dist

  • Start state:

    • Cohoes

  • Goal test:

    • Is state == Delmar

  • Solution?

4.4

Latham

4.1

4

Troy

3.1

5.3

10.7

Loudonville

8

4.3

Guilderland

8.7

Albany

1.5

Rensselaer

5.2

Delmar


Another search tree

Another Search Tree

Cohoes

Latham

Troy

Cohoes

Troy

Loudonville

Cohoes

Latham

Loudonville

La

T

C

La

Lo

A

  • Search:

    • Expand out possible plans

    • Maintain a fringe of unexpanded plans

    • Try to expand as few tree nodes as possible


State graphs vs search trees

State Graphs vs. Search Trees

State

graph

Search

trees

  • State graphs: a representation of the search problem

    • each node is an abstract of the state of the world

  • Search tree: a tool that helps us to find the solution

    • each node represents an entire path in the graph

    • tree nodes are constructed on demand and we construct as little as possible


States vs nodes

States vs. Nodes

  • Nodes in state space graphs are problem states:

    • Represent an abstracted state of the world

    • Have successors, can be goal/non-goal, have multiple predecessors

  • Nodes in search trees are plans

    • Represent a plan (sequence of actions) which results in the node’s state

    • Have a problem state and one parent, a path length, a depth and a cost

    • The same problem state may be achieved by multiple search tree nodes

Problem States

Search Nodes


Uninformed search

Uninformed search

  • Uninformed search: given a state, we only know whether it is a goal state or not

  • Cannot say one nongoal state looks better than another nongoal state

  • Can only traverse state space blindly in hope of somehow hitting a goal state at some point

    • Also called blind search

    • Blind does not imply unsystematic!


Breadth first search

Breadth-first search


Example

Example

b

a

Start

c

d

e

GOAL


Properties of breadth first search

Properties of breadth-first search

  • Ignores the cost

  • May expand more nodes than necessary

  • BFS is complete: if a solution exists, one will be found

  • BFS finds a shallowest solution

    • Not necessarily an optimal solution

  • If every node has b successors (the branching factor), shallowest solution is at depth d, then fringe size will be at least bd at some point

    • This much space (and time) required 


Fixed bfs

Fixed BFS

  • Never expand a node whose state has been visited

  • Fringe can be maintained as a First-In-First-Out (FIFO) queue (class Queue in util.py)

  • Maintain a set of visited states

  • fringe := {node corresponding to initial state}

  • loop:

    • if fringe empty, declare failure

    • choose and remove the top node v from fringe

    • check if v’s state s is a goal state; if so, declare success

    • if v’s state has been visited before, skip

    • if not, expand v, insert resulting nodes whose states have not been visited into fringe

  • This is the BFS you should implement in project 1


Depth first search

Depth-first search


Example1

Example

b

a

Start

c

d

e

GOAL


Properties of depth first search

Properties of depth-first search

  • Ignores cost

  • Not complete (might cycle through nongoal states)

  • If solution found, generally not optimal/shallowest

  • If every node has b successors (the branching factor), and we search to at most depth m, fringe is at most bm

    • Much better space requirement 

    • Actually, generally don’t even need to store all of fringe

  • Time: still need to look at every node

    • bm + bm-1 + … + 1 (for b>1, O(bm))

    • Inevitable for uninformed search methods…


Fixed dfs

Fixed DFS

  • Never expand a node whose state has been visited

  • Fringe can be maintained as a Last-In-First-Out (LIFO) queue (class Stack in util.py)

  • Maintain a set of visited states

  • fringe := {node corresponding to initial state}

  • loop:

    • if fringe empty, declare failure

    • choose and remove the top node v from fringe

    • check if v’s state s is a goal state; if so, declare success

    • if v’s state has been visited before, skip

    • if not, expand v, insert resulting nodes whose states have not been visited into fringe

  • This is the DFS you should implement in project 1


You can start to work on project 1 now

You can start to work on Project 1 now

  • Read the instructions on course website and the comments in search.py first

  • Q1: DFS

    • LIFO

  • Q2: BFS

    • FIFO

  • Due in two weeks (Feb 7)

  • Check util.py for LIFO and FIFO implementation

  • Use piazza for Q/A


Dodging the bullets

Dodging the bullets

  • The auto-grader is very strict

    • 0 point for expanding more-than-needed states

    • no partial credit

  • Hint 1: do not include print "Start:", problem.getStartState() in your formal submission

    • comment out all debuging commands

  • Hint 2: remember to check if a state has been visited before

  • Hint 3: return a path from start to goal. You should pass the local test before submission (details and instructions on project 1 website)


Reminder1

Reminder

  • TA OH

    • Joe Johnson (mainly in charge of the project): Wed 12:30-1:30 pm, Amos Eaton 217

    • HongzhaoHuang (everything else): Thur 12:30-1:30 pm, Amos Eaton 125

  • Project0 due on next Tuesday Jan 28 midnight

    • LMS working!

    • 2 points

    • submission instruction changed, if you have uploaded project 0, please re-submit it

  • Project1 due on Feb 7 midnight

  • Sign up on piazza by Jan 28 midnight (1 point)

  • Try your best to use piazza for Q/A

  • You are encouraged to stop me and ask questions in class


  • Login