Date post: | 16-Jan-2016 |
Category: |
Documents |
Upload: | kelley-watkins |
View: | 215 times |
Download: | 0 times |
Computer Science CPSC 322
Lecture 4
Search: Intro
(textbook Ch: 3.0-3.4)
1
Announcements
(1) Reminder on Slide Posting
• I post a version of the lecture slides by 2:30pm
• after class (by the end of the day usually) I’ll post the version
with material filled-in in class.
So you’ll always have to double check the posted slides after class
if you want to have the most up-to-date copy
(2) Office hours are posted on the class syllabus
2
Course OverviewEnvironment
Problem Type
Query
Planning
Deterministic Stochastic
Constraint Satisfaction Search
Arc Consistency
Search
Search
Logics
STRIPS
Vars + Constraints
Value Iteration
Variable
Elimination
Belief Nets
Decision Nets
Markov Processes
Static
Sequential
Representation
ReasoningTechnique
Variable
Elimination
First Part of the Course 3
Course OverviewEnvironment
Problem Type
Query
Planning
Deterministic Stochastic
Constraint Satisfaction Search
Arc Consistency
Search
Search
Logics
STRIPS
Vars + Constraints
Value Iteration
Variable
Elimination
Belief Nets
Decision Nets
Markov Processes
Static
Sequential
Representation
ReasoningTechnique
Variable
Elimination
We’ll focus on Search 4
(Adversarial) Search: Checkers
Source: IBM Research
• Early learning work in 1950s by
Arthur Samuel at IBM
• Chinook program by Jonathan Schaeffer
(UofA)
• Search explores the space of
possible moves and their
consequence
1994: world champion
2007: declared unbeatable
5
Slide 6
(Adversarial) Search: Chess In 1997, Gary Kasparov, the chess grandmaster and
reigning world champion played against Deep Blue, a program written by researchers at IBM
Source: IBM Research
Slide 7
(Adversarial) Search: Chess• Deep Blue’s won 3 games, lost 2, tied 1
• 30 CPUs + 480 chess processors• Searched 126.000.000 nodes per sec• Generated 30 billion positions per move
reaching depth 14 routinely
Today’s Lecture
• Simple Search Agent
• Examples
• General Search Procedure (time permitting)
8
• Often we are not given an algorithm to solve a problem, but only a specification of what a solution is
we have to search for a solution.
– Enumerate a set of potential partial solutions
– Check to see if they are solutions or could lead to one
Search
9
Simple Search Agent
Deterministic, goal-driven agent • Agent is in a start state• Agent is given a goal (subset of possible states)• Environment changes only when the agent acts• Agent perfectly knows:
• actions that can be applied in any given state• the state it is going to end up in when an action is applied in
a given state• The sequence of actions (and appropriate ordering) taking the
agent from the start state to a goal state is the solution
10
Definition of a search problem• Initial state(s)
• Set of actions (operators) available to the agent• An action function that, given a state and an action,
returns a new state • Goal state(s)
• Search space: set of states that will be searched for a path from initial state to goal, given the available actions• states are nodes and actions are links between them.• Not necessarily given explicitly (state space might be infinite)
• Path Cost (we ignore this for now)
11
Today’s Lecture
• Simple Search Agent
• Examples
• General Search Procedure (time permitting)
12
Slide 13
Three examples1. The delivery robot planning the route it will take in a
bldg. to get from one room to another (Ch 1.6)
2. Vacuum cleaner world
3. Solving an 8-puzzle
Environment for Delivery Robot (ch.1.6)
Simplified• Consider only bold
locations here
• Limits in direction of movement (e.g., can only move in the direction a door opens, can’t go back to previous location, etc.)
• Start: o103
• Goal: r123
14
Search Space for the Delivery Robot
15
Slide 16
Example: vacuum world
Possible start state Possible goal state
• States• Two rooms: r1, r2
• Each room can be either dirty or not
• Vacuuming agent can be in either in r1 or r2
Slide 17
Example: vacuum world
• States• Two rooms: r1, r2
• Each room can be either dirty or not
• Vacuuming agent can be in either in r1 or r2
Feature-based representation: - Features?- how many states?
Possible start state Possible goal state
Suppose we have the same problem with k rooms.
The number of states is….
D. 2 * kk
A. k3
C. k * 2k
B. k * 2k
…..
18
Cleaning Robot
• States – one of the eight states in the picture
• Actions –left, right, suck• Possible Goal – no dirt
19
Search Space
20
• Actions – left, right, suck - Successor states in the graph describe the effect of each action
applied to a given state
• Possible Goal – no dirt
Search Space
21
• Actions – left, right, suck - Successor states in the graph describe the effect of each action
applied to a given state
• Possible Goal – no dirt
Search Space
22
• Actions– left, right, suck - Successor states in the graph describe the effect of each action
applied to a given state
• Possible Goal – no dirt
Search Space
23
• Actions – left, right, suck - Successor states in the graph describe the effect of each action
applied to a given state
• Possible Goal – no dirt
Search Space
24
• Actions – left, right, suck - Successor states in the graph describe the effect of each action
applied to a given state
• Possible Goal – no dirt
Eight Puzzle
25
Eight Puzzle
States:
Actions:
Goal:26
Eight Puzzle
States: each state specifies which number/blank occupies each of the 9 tiles HOW MANY STATES ?
Actions: blank moves left, right, up down
Goal: configuration with numbers in right sequence
9!
27
Slide 28
Search space for 8puzzle
Slide 29
Search space for 8puzzle
Slide 30
How can we find a solution?
• How can we find a sequence of actions and their appropriate ordering that lead to the goal?
• Need smart ways to search the space graph
Today’s Lecture
• Simple Search Agent
• Examples
• General Search Procedure (time permitting)
31
Slide 32
Search: Abstract Definition
How to search• Start at the start state• Evaluate the effect of taking different actions starting from
states that have been encountered in the search so far• Stop when a goal state is encountered
To make this more formal, we'll use the formal definition of a graph that you reviewed for today
• A directed graph consists of a set N of nodes (vertices) and a set A of ordered pairs of nodes, called edges (arcs).
• Node n2 is a neighbor of n1 if there is an arc from n1 to n2. That is, if n1, n2 A.
• A path is a sequence of nodes n0, n1,..,nk such that ni-1, ni A.
• A cycle is a non-empty path such that the start node is the same as the end node.
• A directed acyclic graph (DAG) is a graph with no cycles
• Given a set of start nodes and goal nodes, a solution is a path from a start node to a goal node
Graphs
33
Graph specification for the Delivery Robot
N={mail, ts, o103, b3, o109,...}
A={ ⟨ts,mail , ⟩ ⟨o103,ts , o103,b3 , o103,o109 , ⟩ ⟨ ⟩ ⟨ ⟩ ...}
One of several solution paths:
⟨o103, o109, o119, o123, r123⟩
34
• Generic search algorithm: given a graph, start nodes, and goal nodes,
incrementally explore paths from the start nodes.
Maintain a frontier of paths from the start node that have been explored.
As search proceeds, the frontier expands into the unexplored nodes until a goal node is encountered.
• The way in which the frontier is expanded defines the search strategy.
Graph Searching
35
Problem Solving by Graph Searching
36
Input: - a graph - a set of start nodes - Boolean procedure goal(n) testing if
n is a goal node
frontier:= [<s>: s is a start node]; While frontier is not empty: select and remove path <no,….,nk>
from frontier; If goal(nk)
return <no,….,nk>;
For every neighbor n of nk,
add <no,….,nk, n> to frontier;
end
Generic Search Algorithm
37
• The forward branching factor of a node is the number of arcs going out of the node
• The backward branching factor of a node is the number of arcs going into the node
• If the forward branching factor of a node is b and the graph is a tree, how many nodes are n steps away from that node?
Branching Factor (you reviewed this for today)
38
C. nb
A. nb
B. bn
D. n/b
• The forward branching factor of a node is the number of arcs going out of the node
• The backward branching factor of a node is the number of arcs going into the node
• If the forward branching factor of a node is b and the graph is a tree, how many nodes are n steps away from that node?
Branching Factor (you reviewed this for today)
39
B. bn
Slide 40
Comparing Searching Algorithms: Will it find a solution? the best one?
Def. : A search algorithm is complete if
whenever there is at least one solution, the algorithm is guaranteed to find it within a finite amount of time.
Def.: A search algorithm is optimal if
when it finds a solution, it is the best one
Slide 41
Comparing Searching Algorithms: Complexity
Def.: The time complexity of a search algorithm is
the worst- case amount of time it will take to run, expressed in terms of
• maximum path length m • maximum branching factor b.
Def.: The space complexity of a search algorithm is
the worst-case amount of memory that the algorithm will use (i.e., the maximum number of nodes on the frontier),
also expressed in terms of m and b.
Branching factor b of a node is the number of arcs going out
of the node
Slide 42
• Search is a key computational mechanism in many AI agents • We will study the basic principles of search on the simple
deterministic search agent model• Generic search approach:
• define a search space graph• start from initial state state, • incrementally explore paths from current state until goal state is reached.
The way in which the frontier is expanded defines the search strategy.
To Summarize
Learning Goals for today’s class
• Identify real world examples that make use of deterministic, goal-driven search agents
• Assess the size of the search space of a given search problem.
• Implement the generic solution to a search problem.
• Define completeness, optimality, time complexity and space complexity for search algorithms
TODO for Wednesday
44
• Uninformed search strategies (read textbook Sec. 3.5)
• First Practice Exercise 3.A• http://www.aispace.org/
exercises.shtml