45
Prof. Janice T. Searleman [email protected]

Prof. Janice T. Searleman jets@clarkson · 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

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Prof. Janice T. Searleman jets@clarkson · 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

Prof. Janice T. Searleman

[email protected]

Page 2: Prof. Janice T. Searleman jets@clarkson · 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

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)

Page 3: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 4: Prof. Janice T. Searleman jets@clarkson · 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

want to achieve a goal, but there is no direct way to do it

Page 5: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 6: Prof. Janice T. Searleman jets@clarkson · 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
Page 7: Prof. Janice T. Searleman jets@clarkson · 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

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?

Page 8: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 9: Prof. Janice T. Searleman jets@clarkson · 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

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.

Page 10: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 11: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 12: Prof. Janice T. Searleman jets@clarkson · 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
Page 13: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 14: Prof. Janice T. Searleman jets@clarkson · 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
Page 15: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 16: Prof. Janice T. Searleman jets@clarkson · 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

• Single-state, start in

#5. Solution?

Page 17: Prof. Janice T. Searleman jets@clarkson · 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

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?

Page 18: Prof. Janice T. Searleman jets@clarkson · 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

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?

Page 19: Prof. Janice T. Searleman jets@clarkson · 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

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]

Page 20: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 21: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 22: Prof. Janice T. Searleman jets@clarkson · 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

states? actions? goal test? path cost?

Page 23: Prof. Janice T. Searleman jets@clarkson · 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

states? integer dirt and robot location actions? Left, Right, Suck

goal test? no dirt at all locations

path cost? 1 per action

Page 24: Prof. Janice T. Searleman jets@clarkson · 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

states?

actions?

goal test?

path cost?

Page 25: Prof. Janice T. Searleman jets@clarkson · 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

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]

Page 26: Prof. Janice T. Searleman jets@clarkson · 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
Page 27: Prof. Janice T. Searleman jets@clarkson · 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

g(n) is the total cost of the path on the search tree from the root node to node n

Page 28: Prof. Janice T. Searleman jets@clarkson · 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
Page 29: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 30: Prof. Janice T. Searleman jets@clarkson · 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

Basic idea: ◦ offline, simulated exploration of state space by

generating successors of already-explored states (a.k.a.~expanding states)

Page 31: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 32: Prof. Janice T. Searleman jets@clarkson · 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
Page 33: Prof. Janice T. Searleman jets@clarkson · 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

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.

Page 34: Prof. Janice T. Searleman jets@clarkson · 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

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 ∞)

Page 35: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 36: Prof. Janice T. Searleman jets@clarkson · 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

• Expand shallowest unexpanded node

• Implementation:

– fringe is a FIFO queue, i.e., new

successors go at end

Page 37: Prof. Janice T. Searleman jets@clarkson · 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

• Expand shallowest unexpanded node

• Implementation:

– fringe is a FIFO queue, i.e., new

successors go at end

Page 38: Prof. Janice T. Searleman jets@clarkson · 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

• Expand shallowest unexpanded node

• Implementation:

– fringe is a FIFO queue, i.e., new

successors go at end

Page 39: Prof. Janice T. Searleman jets@clarkson · 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

• Expand shallowest unexpanded node

• Implementation:

– fringe is a FIFO queue, i.e., new

successors go at end

Page 40: Prof. Janice T. Searleman jets@clarkson · 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

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)

Page 41: Prof. Janice T. Searleman jets@clarkson · 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

search space is the part of the problem space considered so far

fringe == “open list”

Page 42: Prof. Janice T. Searleman jets@clarkson · 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

Failure to detect repeated states can turn a linear problem into an exponential one!

Page 43: Prof. Janice T. Searleman jets@clarkson · 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

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

Page 44: Prof. Janice T. Searleman jets@clarkson · 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

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)

Page 45: Prof. Janice T. Searleman jets@clarkson · 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

Expand deepest unexpanded node

Implementation: ◦ fringe = LIFO queue, i.e., put successors at front