19
Practical Practical Planning: Planning: Scheduling and Scheduling and Hierarchical Task Hierarchical Task Networks Networks Chapter 12.1-12.2 CS 63 CS 63 Adapted from slides by Tim Finin and Marie desJardins.

Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Embed Size (px)

Citation preview

Page 1: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Practical Planning:Practical Planning:Scheduling and Hierarchical Scheduling and Hierarchical

Task NetworksTask Networks

Chapter 12.1-12.2

CS 63CS 63

Adapted from slides byTim Finin andMarie desJardins.

Page 2: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Outline

• Intelligent scheduling• Hierarchical task network (HTN) planning• Increasing expressivity

Page 3: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Real-world planning domains

• Real-world domains are complex and don’t satisfy the assumptions of STRIPS or partial-order planning methods

• Some of the characteristics we may need to deal with:– Modeling and reasoning about resources– Representing and reasoning about time– Planning at different levels of abstractions– Conditional outcomes of actions– Uncertain outcomes of actions– Exogenous events– Incremental plan development– Dynamic real-time replanning

} a.k.a. scheduling!

Page 4: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Planning vs. scheduling

• Planning: given one or more goals, generate a sequence of actions to achieve the goal(s)

• Scheduling: given a set of actions and constraints, allocate resources and assign times to the actions so that no constraints are violated

• Traditionally, planning is done with specialized logical reasoning methods

• Traditionally, scheduling is done with constraint satisfaction, linear programming, or OR methods

• However, planning and scheduling are closely interrelated and can’t always be separated

Page 5: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Hierarchical decomposition

• Hierarchical decomposition, or hierarchical task network (HTN) planning, uses abstract operators to incrementally decompose a planning problem from a high-level goal statement to a primitive plan network

• Primitive operators represent actions that are executable, and can appear in the final plan

• Non-primitive operators represent goals (equivalently, abstract actions) that require further decomposition (or operationalization) to be executed

• There is no “right” set of primitive actions: One agent’s goals are another agent’s actions!

Page 6: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

HTN operator: Example

OPERATOR decomposePURPOSE: ConstructionCONSTRAINTS: Length (Frame) <= Length (Foundation), Strength (Foundation) > Wt(Frame) + Wt(Roof) + Wt(Walls) + Wt(Interior) + Wt(Contents)PLOT: Build (Foundation)

Build (Frame) PARALLEL Build (Roof) Build (Walls) END PARALLEL Build (Interior)

Page 7: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

HTN planning: example

Page 8: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

SIPE-2

• SIPE-2 is an HTN planner with many advanced features:– Plan critics

– Resource reasoning

– Constraint reasoning (complex numerical or symbolic variable and state constraints)

– Interleaved planning and execution

– Interactive plan development

– Sophisticated truth criterion

– Conditional effects

– Parallel interactions in partially ordered plans

– Replanning if failures occur during execution

Page 9: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

SIPE-2

Image from: http://www.ai.sri.com/~sipe/architecture.html

Page 10: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Blocksworld in SIPE-2

;;some colored blocks for other problems(ON R1 B1)(ON B1 TABLE)(ON B2 TABLE)(ON R2 TABLE)

;true in all problems(CLEAR TABLE)

END PREDICATESSTOP

OPERATOR: PUTON1ARGUMENTS: BLOCK1, OBJECT1 IS NOT BLOCK1;PURPOSE: (ON BLOCK1 OBJECT1)PLOT:PARALLEL BRANCH 1:

GOALS: (CLEAR OBJECT1) BRANCH 2:

GOALS: (CLEAR BLOCK1)END PARALLEL

PROCESS ACTION: PUTON; ARGUMENTS: BLOCK1,OBJECT1 RESOURCES: BLOCK1 EFFECTS: (ON BLOCK1 OBJECT1)END PLOTEND OPERATOR

Excerpt taken from http://www.ai.sri.com/~sipe/blocks-sipe.txtImage taken from http://www.ai.sri.com/~sipe/sussman-derivation.html

Sussman AnomalyExcerpt from SIPE-2Blocksworld Definition

Page 11: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

HTN operator representation

• Russell & Norvig explicitly represent causal links; these can also be computed dynamically by using a model of preconditions and effects (this is what SIPE-2 does)

• Dynamically computing causal links means that actions from one operator can safely be interleaved with other operators, and subactions can safely be removed or replaced during plan repair

• Russell & Norvig’s representation only includes variable bindings, but more generally we can introduce a wide array of variable constraints

Page 12: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Truth criterion

• Determining whether a formula is true at a particular point in a partially ordered plan is, in the general case, NP-hard

• Intuition: there are exponentially many ways to linearize a partially ordered plan

• In the worst case, if there are N actions unordered with respect to each other, there are N! linearizations

• Ensuring soundness of the truth criterion requires checking the formula under all possible linearizations

• Use heuristic methods instead to make planning feasible

• Check later to be sure no constraints have been violated

Page 13: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Truth criterion in SIPE-2

• Heuristic: prove that there is one possible ordering of the actions that makes the formula true – but don’t insert ordering links to enforce that order

• Such a proof is efficient– Suppose you have an action A1 with a precondition P

– Find an action A2 that achieves P (A2 could be initial world state)

– Make sure there is no action necessarily between A2 and A1 that negates P

• Applying this heuristic for all preconditions in the plan can result in infeasible plans

Page 14: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Increasing expressivity

• Conditional effects– Instead of having different operators for different conditions, use a

single operator with conditional effects– Move (block1, from, to) and MoveToTable (block1, from) collapse

into one Move (block1, from, to):• Op(ACTION: Move(block1, from, to),

PRECOND: On (block1, from) ^ Clear (block1) ^ Clear (to)EFFECT: On (block1, to) ^ Clear (from) ^ ~On(block1, from) ^ ~Clear(to) when to≠Table

• There’s a problem with this operator: can you spot what it is?

• Negated and disjunctive goals• Universally quantified preconditions and effects

Page 15: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Reasoning about resources

• Introduce numeric variables that can be used as measures• These variables represent resource quantities, and change

over the course of the plan• Certain actions may produce (increase the quantity of)

resources• Other actions may consume (decrease the quantity of)

resources• More generally, may want different types of resources

– Continuous vs. discrete– Sharable vs. nonsharable– Reusable vs. consumable vs. self-replenishing

Page 16: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Other real-world planning issues

• Conditional planning

• Partial observability

• Information gathering actions

• Execution monitoring and replanning

• Continuous planning

• Multi-agent (cooperative or adversarial) planning

Page 17: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Planning summary• Planning representations

– Situation calculus– STRIPS representation: Preconditions and effects

• Planning approaches– State-space search (STRIPS, forward chaining, ….)– Plan-space search (partial-order planning, HTN, …)– Constraint-based search (GraphPlan, SATplan, …)

• Search strategies– Forward planning– Goal regression – Backward planning– Least-commitment– Nonlinear planning

Page 18: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Applications of PlanningApplications of Planning

• Military operations

• Autonomous space operations

• Construction tasks

• Machining tasks

• Mechanical assembly

• Design of experiments in genetics

• Command sequences for satellite

Most applied systems use extended representation languages, nonlinear

planning techniques, and domain-specificheuristics

Page 19: Practical Planning: Scheduling and Hierarchical Task Networks Chapter 12.1-12.2 CS 63 Adapted from slides by Tim Finin and Marie desJardins

Oil-Spill Response in SIPE-2

Image taken from http://www.ai.sri.com/~sipe/oil.html