Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Recap: Agents Introduction to Search Agents State-based Search Uninformed (blind) search algorithms
HW#1 posted, due Wednesday, 9/04
Reading Assignment: Chapter 3 Solving Problems by Searching Nao demo: Tuesday, 9/3, COSI (SC336), 1:30 – 3:30 IDEA/SIGGRAPH meeting: tonight, 9/2, 7:00 pm, CEC (Snell 130, in back)
Agent = architecture + program
Maps a Perception (sequence) to Action f : P* A
Four basic agent programs:
◦ Simple reflex agents
◦ Model-based reflex agents
◦ Goal-based agents
◦ Utility-based agents
Other types of agents:
◦ mobile
◦ information
Learning agents
want to achieve a goal, but there is no direct way to do it
In the middle of taking the GREs, your only #2 pencil breaks
15-puzzle
Instant Insanity – build a tower of 4 blocks so that each of the 4 colors shows on each of the 4 sides of the tower
Typographical Rebus (“wacky wordies”)
Monk on the Mountain
One day an old monk decides to leave his monastery at
precisely 6:00 am to climb to the top of a mountain so
he can enjoy its solitude. He travels at various speeds
and takes several rests before arriving at the mountain
peak at precisely 5:00 pm. He spends the night in
prayer and meditation, and starts back down the
mountain using the same trail the next day at precisely
6:00 am, again traveling at different speeds and
stopping often for periods of rest. At precisely 5:00 pm
he reaches his starting point back at the monastery. Is
there some point along the mountain trail that he passes
at precisely the same time each day?
1. Goal formulation – what is desired
- may have a set of constraints or measures that should be optimized
- can specify a goal by describing a state in which it is achieved, or by giving a goal-test function
2. Problem formulation – what actions & states to consider
3. Search algorithm – takes a problem as input & returns a solution in the form of a sequence of actions to take
4. Execution – carry out the actions
Representation is a key issue in problem solving. How a problem is formulated determines what means can be brought to bear to solve the problem (and possibly whether or not it can be solved).
For example, consider designing the cross-sectional shape of an airplane wing. Possibilities include:
- model the wing using mathematical techniques
- build a mockup of the wing and test it in a wind tunnel
- create a model in virtual reality
- etc.
Original
Problem
Analogous
Problem “Model”
A representation is not just a way of encoding the
knowledge of a problem:
• it determines what “means” are available for
working on the problem
• it determines how “expensive” processing is
• it may determine whether or not all “relevant”
knowledge can be encoded
algorithm to solve the problem may be known, but is intractible (e.g. chess)
no algorithm is known (e.g. playing ping pong)
algorithms assume complete and consistent data
On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest Formulate goal: ◦ be in Bucharest
Formulate problem: ◦ states: various cities ◦ actions: drive between cities
Find solution: ◦ sequence of cities, e.g., Arad, Sibiu, Fagaras,
Bucharest
Deterministic, fully observable single-state problem
◦ Agent knows exactly which state it will be in; solution is a sequence
Non-observable sensorless problem (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
• Single-state, start in
#5. Solution?
Single-state, start in #5. Solution? [Right, Suck]
Sensorless, start in {1,2,3,4,5,6,7,8 } e.g., Right goes to {2,4,6,8 } Solution?
Sensorless, start in {1,2,3,4,5,6,7,8} e.g., Right goes to {2,4,6,8} Solution? [Right,Suck,Left,Suck]
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
Solution?
Sensorless, start in {1,2,3,4,5,6,7,8} e.g., Right goes to {2,4,6,8} Solution? [Right,Suck,Left,Suck]
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
Solution? [Right, if dirt then Suck]
A problem is defined by four items: 1. initial state e.g., "at Arad" 2. actions or successor function S(x) = set of
action–state pairs ◦ e.g., S(Arad) = {<Arad Zerind, Zerind>, … }
3. goal test, can be ◦ explicit, e.g., x = "at Bucharest" ◦ implicit, e.g., Checkmate(x)
4. path cost (additive) ◦ e.g., sum of distances, number of actions
executed, etc. ◦ c(x,a,y) is the step cost, assumed to be ≥ 0
A solution is a sequence of actions leading from the initial state to a goal state
Real world is absurdly complex
state space must be abstracted for problem solving
(Abstract) state = set of real states
(Abstract) action = complex combination of real
actions
◦ e.g., "Arad Zerind" represents a complex set of possible
routes, detours, rest stops, etc.
For guaranteed realizability, any real state "in Arad“
must get to some real state "in Zerind"
(Abstract) solution =
◦ set of real paths that are solutions in the real world
Each abstract action should be "easier" than the
original problem
states? actions? goal test? path cost?
states? integer dirt and robot location actions? Left, Right, Suck
goal test? no dirt at all locations
path cost? 1 per action
states?
actions?
goal test?
path cost?
states? locations of tiles actions? move blank left, right, up, down goal test? = goal state (given) path cost? 1 per move
[Note: optimal solution of n-Puzzle family is NP-hard]
g(n) is the total cost of the path on the search tree from the root node to node n
states?: real-valued coordinates of robot joint angles parts of the object to be assembled
actions?: continuous motions of robot joints goal test?: complete assembly path cost?: time to execute
Basic idea: ◦ offline, simulated exploration of state space by
generating successors of already-explored states (a.k.a.~expanding states)
Offline, simulated exploration of state space by generating successors of already-explored states
Search algorithms have the following basic form:
do until terminating condition is met
if chosen node is a goal then return success;
if no more nodes to consider then return fail;
select node; {choose a node (leaf) on the tree}
expand node; {generate successors & add to tree}
A search strategy is defined by picking the order of node expansion
key idea: order the branches under each node so that the “most promising” ones are explored first
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.
A search strategy is defined by picking the order of node expansion
Strategies are evaluated along the following dimensions: ◦ completeness: does it always find a solution if one
exists? ◦ time complexity: number of nodes generated ◦ space complexity: maximum number of nodes in
memory ◦ optimality: does it always find a least-cost solution?
Time and space complexity are measured in terms of ◦ b: maximum branching factor of the search tree ◦ d: depth of the least-cost solution ◦ m: maximum depth of the state space (may be ∞)
Uninformed search strategies use only the information available in the problem definition
Breadth-first search ◦ Uniform-cost search
Depth-first search ◦ Depth-limited search
◦ Iterative deepening search
• Expand shallowest unexpanded node
• Implementation:
– fringe is a FIFO queue, i.e., new
successors go at end
• Expand shallowest unexpanded node
• Implementation:
– fringe is a FIFO queue, i.e., new
successors go at end
• Expand shallowest unexpanded node
• Implementation:
– fringe is a FIFO queue, i.e., new
successors go at end
• Expand shallowest unexpanded node
• Implementation:
– fringe is a FIFO queue, i.e., new
successors go at end
Complete? Yes (if b is finite) Time? 1+b+b2+b3+… +bd + b(bd-1) = O(bd+1) Space? O(bd+1) (keeps every node in memory) Optimal? Yes (if cost = 1 per step)
Space is the bigger problem (more than time,
but time is still a problem)
search space is the part of the problem space considered so far
fringe == “open list”
Failure to detect repeated states can turn a linear problem into an exponential one!
idea: order the branches under each node so that the “most promising” ones are explored first
g(n) is the total cost of the path on the search tree from the root node to node n
sort the open list by increasing g(), that is, consider the shortest partial path first
Expand least-cost unexpanded node Implementation: ◦ fringe = queue ordered by path cost
Equivalent to breadth-first if step costs all equal Complete? Yes, if step cost ≥ ε Time? # of nodes with g ≤ cost of optimal solution,
O(bceiling(C*/ ε)) where C* is the cost of the optimal solution
Space? # of nodes with g ≤ cost of optimal solution,
O(bceiling(C*/ ε)) Optimal? Yes – nodes expanded in increasing order of g(n)
Expand deepest unexpanded node
Implementation: ◦ fringe = LIFO queue, i.e., put successors at front