You are on page 1of 34

Planning and Search

Planning with Time and Resources

Planning with Time and Resources

Outline
Time and resources Optimal and satiscing plans Scheduling actions PDDL 2.1 Integrating planning and scheduling

Planning with Time and Resources

Time
In classical planning we assumed that actions are instantaneous Action preconditions must hold before the action is executed and the eects of the action persist indenitely Many planning domains are more complex: actions take time to executehow long an action takes to execute may depend on the preconditions preconditions may need to hold when the action begins, or throughout the execution of the action eects may not be true immediately and their eects may persist for only a limited timean action can have multiple eects on a uent at dierent times

Planning with Time and Resources

Examples
Example: if I need a laptop in order to write a lecture, I need to continue to have the laptop while I am writing the lecture (I cant lend it to a friend) Example: if I push the lift button, the lift may take time to arrive, and when it does the door will remain open for only a limited time In some cases, actions have to be performed concurrently Example: if a fuse blows, I have to strike a match and walk to the fusebox while the match is burning When planning with time, we usually want a goal to be true at or before a given time, or over a given interval

Planning with Time and Resources

Resources
Time is a particular instance of a resource A resource is any quantity or (set of) object(s) whose value or availability determines whether an action can be executed Examples: money, electrical power, equipment, vehicles, etc. Resources may be consumable (examples: money, fuel) or reusable (example: a car which becomes available again after a trip) In some cases, actions may produce resources (examples: refueling, hiring more sta etc) When planning with resources, a solution is dened as a plan that achieves the goals while allocating resources to actions so that all resource constraints are satised Many planners (and PDDL) treat time as a special case

Planning with Time and Resources

Optimal vs satiscing plans


As with search problems, we can distinguish between optimal and satiscing solutions A satiscing plan is one that achieves the goal(s) without violating any temporal or resource constraints An optimal plan is one that achieves the goal(s) while minimising (or maximising) some metricmetric is often dened in terms of resource usage

Planning with Time and Resources

Scheduling actions
One approach is to plan rst and schedule later Split the overall problem into: a planning phase in which actions are selected and partially ordered to achieve the goal(s); and a scheduling phase in which temporal information is added to the plan to ensure it meets resource and deadline constraints Assumes that plans have minimal ordering constraints required for correctness (e.g., as produced by partial order planning)

Planning with Time and Resources

Example: assembling cars


Problem is to plan and schedule the assembly of two cars Assembling a car involves three actions: add the engine, add the wheels and then inspect the resulting car Each action has a duration and requires a set of resources constraints which must be satised for the action to be performed Each resource constraint species the type of resource, the number of the resource required and whether the resource is consumable or reusable Solutions are evaluated using a simple cost fuctionthe total duration of the plan (called the makespan in scheduling)

Planning with Time and Resources

Example: assembling cars


Jobs({AddEngine1 AddWheels1 Inspect1 }, {AddEngine2 AddWheels2 Inspect2 }) Resources(EngineHoists(1), WheelStations(1), Inspectors(2), LugNuts(500)) Action(AddEngine1, Duration: 30, Use: EngineHoists(1)) Action(AddEngine2, Duration: 60, Use: EngineHoists(1)) Action(AddWheels1, Duration: 30, Consume: LugNuts(30), Use: WheelStations(1)) Action(AddWheels2, Duration: 15, Consume: LugNuts(20), Use: WheelStations(1)) Action( Inspecti, Duration: 10, Use: Inspectors(1)) A B means that action A must precede action B

Planning with Time and Resources

Temporal constraints
To minimise the plan duration, we must nd the earliest start times for all actions consistent with the ordering constraints in the plan We can use the critical path method to nd the possible start and end times for each action A path through a partially ordered plan is a linearly ordered sequence of actions beginning with Start and ending with F inish The critical path is the path with the longest total duration Actions not on the critical path have a window of time in which the can be executed: LS ES is known as the slack for the action (ES earliest possible start time, LS latest possible start time) Together the ES and LS times for all the actions constitute a schedule for the problem

Planning with Time and Resources

10

Computing ES and LS for actions


ES(Start) = 0 ES(B) = maxAB ES(A) + Duration(A) LS(F inish) = ES(F inish) LS(A) = minBA LS(B) Duration(A) Complexity of computing ES and LS is O(N b) where N is the number of actions and b is the maximum branching factor into or out of an action

Planning with Time and Resources

11

Example: assembling cars (critical path)

[0, 15] AddEngine1 30 [0, 0] Start

[30, 45] AddWheels1 30

[60, 75] Inspect1 10 [85, 85] Finish

[0, 0] AddEngine2 60

[60, 60] AddWheels2 15

[75, 75] Inspect2 10

Planning with Time and Resources

12

Example: assembling cars (critical path)

AddWheels1

AddEngine1

Inspect1

AddEngine2

Inspect2

AddWheels2

10

20

30

40

50

60

70

80

90

Planning with Time and Resources

13

Resource constraints
Critical path problems are easy to solve because they are dened by a conjunction of linear inequalities on start and end times Any action can be executed in parallel with any other unless this is prohibited by the partial order specied in the plan Resource constraints impose additional restrictions on the ordering of actions not explicitly present in the original planactions which require the same resources cant be executed at the same time Problem is now dened by a disjunction of linear inequalities Scheduling with resource constraints is NP-hard

Planning with Time and Resources

14

Example: assembling cars (resources)

EngineHoists(1)

AddEngine1

AddEngine2

WheelStations(1)

AddWheels1

AddWheels2

Inspectors(2)

Inspect1

Inspect2

10

20

30

40

50

60

70

80

90

100

110

120

Planning with Time and Resources

15

Integrating planning and scheduling


So far, we produced a plan rst, and schedule the actions next However, while this approach is simple, it is not complete Intuitively obvious that it may be necessary to take resources into account when choosing which actions to perform For completeness, we need to integrate planning and schedulingconsider the time and resource implications of choosing a particular action when generating a plan

Planning with Time and Resources

16

PDDL in a bit more detail


Components of a PDDL planning task Objects: things in the world relevant to the planning problem Predicates: relevant properties of objectscan be true or false Initial state: the state of the world when planning begins Goal specication: the state of the world we want to achieve Actions: operations we can perform to change the state of the world Domain le species predicates and actions Problem le species objects, initial state, and goal

Planning with Time and Resources

17

PDDL domain le
Domain les look like this: (define (domain <domain name>) <PDDL code for predicates> <PDDL code for first action> [...] <PDDL code for last action> )

Planning with Time and Resources

18

PDDL problem le
(define (problem <problem name>) (:domain <domain name>) <PDDL code for objects> <PDDL code for initial state> <PDDL code for goal specification> )

Planning with Time and Resources

19

PDDL 2.1
Extends simple PDDL with time and resources Actions Can have xed or variable duration Preconditions can be at start or over all (throughout the duration) Eects can be at start or at end and can update resources either at the start or end of the action, or continuously during the execution of the action Goals Achievement goals are specied by a list pi, ti where ti is the time by which pi should hold Persist goals are specied by a condition and an interval over which it should hold

Planning with Time and Resources

20

PDDL 2.1 continued


Plans A plan consists of a set of actions and their start times (or a set of simple temporal constraints on the set of actions) Plan metrics Part of problem description (which resource usage has to be minimised...) Specify the basis on which a plan will be evaluated for a particular problem total-time: time required to execute the plan

Planning with Time and Resources

21

Plan metrics continued


Other values must be computed from primitive numeric expressions dened within a domain and manipulated by the actions of the domain Example: sum of action (resource) costscan be split into multiple dimensions, one corresponding to each resource To dene a metric in terms of a particular quantity, that quantity must be instrumented in the domain descriptione.g., for a metric fuel-used, a fuel-used quantity is updated every time an action consumes fuel The same initial and goal states may result in dierent optimal plans given dierent plan metrics

Planning with Time and Resources

22

PDDL 2.1 levels


PDDL 2.1 is structured as a number of levels Level 1: STRIPS Level 2: adds numeric valued uents (resources) Level 3: adds discrete durative actions Level 4: adds continuous durative actions Introducing numeric valued uents makes the planning problem undecidable

Planning with Time and Resources

23

PDDL 2.1 example


(define (domain jug-pouring) (:requirements :typing :fluents) (:types jug) (:functions (amount ?j - jug) (capacity ?j - jug)) (:action pour :parameters (?jug1 ?jug2 - jug) :precondition (>=(-(capacity ?jug2)(amount ?jug2))(amount ?jug1)) :effect (and (assign (amount ?jug1) 0) (increase (amount ?jug2) (amount ?jug1))) )

Planning with Time and Resources

24

Translation...
An action of pouring from jug1 into jug2: P our(j1, j2): Precond: Effect: Capacity(j2) Amount(j2) Amount(j1) Amount(j1) = 0 Amount(j2) = Amount(j2) + Amount(j1)

Planning with Time and Resources

25

Extending classical planners


Most of the approaches to classical planning can be (and have been) extended to handle time and resources (with varying degrees of scalability) Partial-order planners are easiest to extend to support durative actions (concurrency) however handling resources is harder (because resource consumption depends on which actions have already been performed) Progression planners are easiest to extend to support resource consuming actionshowever handling concurrency is harder We will look at extending progression planners

Planning with Time and Resources

26

Extending progression planners


The following material is based on S. Kambhampatis planning lectures The main dierence with classical planning is that we need to produce concurrent plans For every solvable problem in classical planning, there is guaranteed to be a sequential planthis does not hold for temporal planning Intuition: consider fattening as well as lengthening the current partial plan We represent the state of a partial plan prex as [S, {A1, . . . , Ak }] where S is the current state, and {A1, . . . , Ak } are the mutually non-interfering actions that we have already committed to applying at S Notice that this is just a generalization of normal progression planning, in which the action set {A1, . . . , Ak } is a singleton

Planning with Time and Resources

27

Extending progression planners contd.


Given a state [S, {A1 , . . . , Ak }] to expand, we have (backtrackable) choices: Fatten: perform an additional action B in state S For this to be feasible, Bs preconditions should be true in S and B should not interfere with {A1, . . . , Ak } The resulting state will be [S, {A1, . . . , Ak } + B] Advance perform the actions {A1 , . . . , Ak } If S is the state resulting from application of {A1, . . . , Ak } to S, then generate the state [S , {}] Since actions have durations, we need to decide how far to advance time advance to the rst state change resulting from any of {A1, . . . , Ak }

Planning with Time and Resources

28

Extending progression planners contd.


Note that Fattening is only done in the current state (once lengthening is done, the current state changes, so any new fattening will be done in the new state) Classical progression planners do an automatic advance after each fatten (so there is only one action at each step)

Planning with Time and Resources

29

Extending progression (sketch)


Search is through time-stamped states S = (P, M, , Q, t) where P set pi, ti of uents pi and the time of their last achievement ti < t M set of functions representing resource values set of protected persistent conditions (could be binary or resource conds) Q event queue (eects of actions; contains resource as well as uent events) t time stamp of S

Planning with Time and Resources

30

Extending progression (sketch)


Goal satisfaction: S = (P, M, , Q, t) |= G if for every pi, ti G either exists tj < ti such that pi, tj P and no event in Q deletes pi, or exists e Q that adds pi at time te < ti

Planning with Time and Resources

31

Extending progression (sketch)


Action application Action A is applicable in S if: all the instantaneous preconditions of A are satised by P and M no event in Q interferes with the persistent preconditions of A As eects do not interfere with and Q A does not result in concurrent resource change When A is applied in S: P is updated with As instantaneous eects As persistent preconditions are added to As delayed eects are added to Q

Planning with Time and Resources

32

Extending progression (sketch)


Search algorithm (naive) Pick a state S If S satises the goals, stop Otherwise, non-deterministically do one of Advance the clock by executing the earliest event in Q Perform one of the actions applicable in S

Planning with Time and Resources

33

Next lecture
Hierarchical planning Russell and Norvig 3rd edition Section 11.2 Russell and Norvig 2nd edition Section 12.2

Planning with Time and Resources

34

You might also like