Post on 31-Mar-2015
transcript
Computer Science CPSC 322
Lecture 22
Finish Planning as CSP and Planning Wrap-up
(Ch 8.4)
Announcements• Take flyer on volunteering for cool UBC CS event• Assignment 3 will be available by Monday at the latest
• Useful to do practice Exercise 7 before Assignment 3.• Midterm solutions available in Vista• Midterm marks available early next week
2
Lecture Overview
• Recap Lecture 21
• CSP planning
- Details on CSP representation
- Solving the CSP planning problem
• Time permitting: Intro to Logic
3
• “Open-up” the representation of states, goals and actions– States and goals as set of features– Actions as preconditions and effects defined on state
features
STRIPS representation: an action has two parts:
1. Preconditions: a set of assignments to features that must be satisfied in order for the action to be legal
2. Effects: a set of assignments to features that are caused by the action
Key Idea of Planning
• STRIPS lends itself to solve planning problems either
• As pure search problems• As CSP problems
• We looked at Forward Planning as a basic technique to solve planning problems as pure search problems
• We started looking at Planning as CSP
Solving planning problems
Planning as a CSP
• An alternative approach to planning is to set up a planning problem as a CSP
• We simply reformulate a STRIPS model as a set of variables and constraints
Planning as a CSP: General Idea• Action preconditions and effects are virtually constraints
between • the action, • the states in which it can be applied • the states that it can generate
• Thus, we can make both states and actions into the variables of our CSP formulations
• However, constraints based on action preconditions and effects relate to states at a given time t, the corresponding valid actions and the resulting states at t +1
• need to have as many state and action variables as there are planning steps
Lecture Overview
• Recap Lecture 21
• CSP planning
- Details on CSP representation
- Solving the CSP planning problem
• Time permitting: Intro to Logic
8
Planning as a CSP: General Idea• Both features and actions are CSP variables• Action preconditions and effects are constraints among
• the action, • the states in which it can be applied • the states that it can generate
Planning as a CSP: General Idea• These action constraints relate to states at a given time t, the
corresponding valid actions and the resulting states at t +1• we need to have as many state and action variables as we have planning
steps
Planning as a CSP: Variables• We need to ‘unroll the plan’ for a fixed number of steps: this is called
the horizon k• To do this with a horizon of k:
• construct a CSP variable for each STRIPS state variable at each time step from 0 to k
• construct a boolean CSP variable for each STRIPS action at each time step from 0 to k - 1.
Initial State(s) and Goal(s)• How can we represent the initial state(s) and the goal(s)
with this representation?e.g. Initial state with Sam wanting coffee and Rob at the coffee
shop, with no coffee and no mailGoal: Sam does not want coffee
Initial and Goal Constraints
• initial state constraints: unary constraints on the values of the state variables at time 0
• goal constraints: unary constraints on the values of the state variables at time k
CSP Planning: Precondition Constraints precondition constraints
• between state variables at time t and action variables at time t• specify when actions may be taken
E.g. robot can only pick up coffee when Loc=cs (coffee shop) and RHC = false (don’t have coffee already)
RLoc0 RHC0 PUC0
cs T
cs F
cs F
mr *
lab *
off *Need to allow for the option of *not* taking an action even when it is valid
F
F
F
F
F
T
Truth table for this constraint: list allowed combinations of values
CSP Planning: Effect ConstraintsEffect constraints
• Between action variables at time t and state variables at time t+1• Specify the effects of an action• Also depends on state variables at time t (frame rule!)
E.g. let’s consider RHC at time t and t+1Let’s fill in a few rows in this table
RHCt DelCi PUCi RHCt+1
T T T
T T F
T F T
T F F
F T T
F T F
F F T
F F F16
Effect Constraints• For each row in the constraint table, the value of a state variable
at t+1 is computed considering that all actions = T in that row• Action sequencing depends on both the value of that state variable at t, as
well as the actions preconditions and effects
• For instance, in the row below• When RHC = T, only DecC can apply, with the effect of making
RHC = T
• At this point, PUC can apply, with the effect of making RHC = T again
RHCt DelCi PUCi RHCt+1
T T T
CSP Planning: Effect ConstraintsEffect constraints
• Between action variables at time t and state variables at time t+1• Specify the effects of an action• Also depends on state variables at time t (frame rule!)
E.g. let’s consider RHC at time t and t+1Let’s fill in a few rows in this table
RHCt DelCi PUCi RHCt+1
T T T T
T T F F
T F T T
T F F T
F T T
F T F
F F T
F F F18F
T
F
F
Additional constraints in CSP Planning Other constraints we may want are action constraints:
• specify which actions cannot occur simultaneously• these are often called mutual exclusion (mutex)
constraints
DelMi
DelCi
E.g. in the Robot domainDelM and DelC can occur in any sequence (or simultaneously)But we can enforce that they do not happen simultaneously
19
20
Handling mutex constraints in Forward Planning
E.g., let’s say we don’t want DelM and DelC to occur simultaneously
How would we encode this into STRIPS for forward planning?
Via the actions’ preconditions (how?)
No need to enforce this constraint in Forward Planning
Via the actions’ effects (how?)
None of the above
DelMi
DelCi
T F
TF
F F
21
Handling mutex constraints in Forward Planning
E.g., let’s say we don’t want DelM and DelC to occur simultaneously
How would we encode this into STRIPS for forward planning?
Because forward planning gives us a sequence of actions:only one action is carried out at a time anyways
No need to enforce this constraint in Forward Planning
DelMi
DelCi
T F
TF
F F
22
Additional constraints in CSP PlanningOther constraints we may want are state constraints
• hold between variables at the same time step• they can capture physical constraints of the system (e.g.,
robot cannot hold coffee and mail)
RHCi RHMi
23
Handling state constraints in Forward Planning
RHCi RHMi
T F
F T
F F
Via the actions’ preconditions (how?)
No need to enforce this constraint in Forward Planning (why?)
Via the actions’ effects (how?)
None of the above
How could we handle these constraints in STRIPS forforward planning?
How could we handle these constraints in STRIPS forforward planning?
We need to use preconditions• Robot can pick up coffee only if
it does not have coffee and it does not have mail• Robot can pick up mail only if
it does not have mail and it does not have coffee 24
Handling state constraints in Forward Planning
RHCi RHMi
T F
F T
F F
Lecture Overview
• Recap Lecture 21
• CSP planning
- Details on CSP representation
- Solving the CSP planning problem
• Time permitting: Intro to Logic
25
CSP Planning: Solving the problem
26
Map STRIPS Representation for horizon 1, 2, 3, …, until solution found Run arc consistency and search or stochastic local search!
k = 0Is State0 a goal?If yes, DONE!If no,
CSP Planning: Solving the problem
27
Map STRIPS Representation for horizon k =1Run arc consistency and search or stochastic local search!
k = 1Is State1 a goalIf yes, DONE!If no,
CSP Planning: Solving the problem
28
Map STRIPS Representation for horizon k = 2Run arc consistency, search, stochastic local search!
k = 2: Is State2 a goalIf yes, DONE!If no….continue
Solve Planning as CSP: pseudo code
29
solved = falsehorizon = 0While solved = false map STRIPS into CSP with horizon solve CSP -> solution if solution then solved = T else horizon = horizon + 1
Return solution
Solving Planning as CSP: pseudo code
solved = falsefor horizon h=0,1,2,… map STRIPS into a CSP csp with horizon h solve that csp if solution exists then return solution else horizon = horizon + 1end
Which method would you use to solve each of these CSPs?
Stochastic Local Search Arc consistency + domain splitting
Solving Planning as CSP: pseudo code
31
solved = falsefor horizon h=0,1,2,… map STRIPS into a CSP csp with horizon h solve that csp if solution exists then return solution else horizon = horizon + 1end
Which method would you use to solve each of these CSPs?
Not SLS! SLS cannot determine that no solution exists!
Arc consistency + domain splitting
STRIPS to CSP Conversion applet
32
Allows you:• to specify a planning problem in STRIPS• to map it into a CSP for a given horizon• the CSP translation is automatically loaded into the CSP
applet where it can be solved
Under “Main Tools” in the AISpace Home Page
We will try it out on the “Coffee delivery” Problem (simplified version of the Coffee and Mail delivery problem we saw earlier)
Also used in Assignment 3
Learning Goals for Planning
• STRIPS• Represent a planning problem with the STRIPS representation • Explain the STRIPS assumption
• Forward planning• Solve a planning problem by search (forward planning). Specify states,
successor function, goal test and solution.• Construct and justify a heuristic function for forward planning
• CSP planning• Translate a planning problem represented in STRIPS into a
corresponding CSP problem (and vice versa)• Solve a planning problem with CSP by expanding the horizon
West
North
East
South
62
8Q
QJ65
97
AK53
A9
Some applications of planning
• Emergency Evacuation• Robotics• Space Exploration• Manufacturing Analysis• Games (e.g., Bridge)?• Generating Natural language
• Product Recommendations ….
You know the key ideas!
• Ghallab, Nau, and Traverso
Automated Planning: Theory and PracticeWeb site:
http://www.laas.fr/planning
Also has lecture notes
35
You know
You know a little