+ All Categories
Home > Documents > Planning and Search

Planning and Search

Date post: 11-Feb-2022
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
34
Planning and Search Planning with Time and Resources Planning with Time and Resources 1
Transcript

Planning and Search

Planning with Time and Resources

Planning with Time and Resources 1

Outline

♦ Time and resources

♦ Optimal and satisficing plans

♦ Scheduling actions

♦ PDDL 2.1

♦ Integrating planning and scheduling

Planning with Time and Resources 2

Time

♦ In classical planning we assumed that actions are instantaneous

♦ Action preconditions must hold before the action is executed and theeffects of the action persist indefinitely

♦ Many planning domains are more complex:

actions take time to execute—how long an action takes to execute maydepend on the preconditions

preconditions may need to hold when the action begins, or throughout theexecution of the action

effects may not be true immediately and their effects may persist for onlya limited time—an action can have multiple effects on a fluent at differenttimes

Planning with Time and Resources 3

Examples

♦ Example: if I need a laptop in order to write a lecture, I need to continueto have the laptop while I am writing the lecture (I can’t lend it to a friend)

♦ Example: if I push the lift button, the lift may take time to arrive, andwhen 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 fuseboxwhile the match is burning

♦ When planning with time, we usually want a goal to be true at or beforea given time, or over a given interval

Planning with Time and Resources 4

Resources

♦ Time is a particular instance of a resource

♦ A resource is any quantity or (set of) object(s) whose value or availabilitydetermines 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, hiringmore staff etc)

♦ When planning with resources, a solution is defined as a plan that achievesthe goals while allocating resources to actions so that all resource constraintsare satisfied

♦ Many planners (and PDDL) treat time as a special case

Planning with Time and Resources 5

Optimal vs satisficing plans

♦ As with search problems, we can distinguish between optimal and satis-ficing solutions

♦ A satisficing plan is one that achieves the goal(s) without violating anytemporal or resource constraints

♦ An optimal plan is one that achieves the goal(s) while minimising (ormaximising) some metric—metric is often defined in terms of resource usage

Planning with Time and Resources 6

Scheduling actions

♦ One approach is to plan first and schedule later

♦ Split the overall problem into:

a planning phase in which actions are selected and partially ordered to achievethe goal(s); and

a scheduling phase in which temporal information is added to the plan toensure it meets resource and deadline constraints

♦ Assumes that plans have minimal ordering constraints required for cor-rectness (e.g., as produced by partial order planning)

Planning with Time and Resources 7

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 andthen inspect the resulting car

Each action has a duration and requires a set of resources constraints whichmust be satisfied for the action to be performed

Each resource constraint specifies the type of resource, the number of theresource required and whether the resource is consumable or reusable

Solutions are evaluated using a simple cost fuction—the total duration ofthe plan (called the ‘makespan’ in scheduling)

Planning with Time and Resources 8

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 9

Temporal constraints

♦ To minimise the plan duration, we must find the earliest start times forall actions consistent with the ordering constraints in the plan

♦ We can use the critical path method to find the possible start and endtimes for each action

♦ A path through a partially ordered plan is a linearly ordered sequence ofactions beginning with Start and ending with Finish

♦ 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 canbe executed: LS − ES is known as the slack for the action (ES earliestpossible 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) = maxA≺B ES(A) + Duration(A)

LS(Finish) = ES(Finish)

LS(A) = minB≻A LS(B) − Duration(A)

Complexity of computing ES and LS is O(Nb) where N is the number ofactions 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, 0]

Start

[0, 15]

AddEngine1

30

[0, 0]

AddEngine2

60

[30, 45]

AddWheels1

30

[60, 60]

AddWheels2

15

[60, 75]

Inspect1

10

[75, 75]

Inspect2

10

[85, 85]

Finish

Planning with Time and Resources 12

Example: assembling cars (critical path)

10 20 30 40 50 60 70 80 90

AddEngine2

AddEngine1

AddWheels2

Inspect2

AddWheels1

Inspect1

Planning with Time and Resources 13

Resource constraints

♦ Critical path problems are easy to solve because they are defined by aconjunction of linear inequalities on start and end times

♦ Any action can be executed in parallel with any other unless this isprohibited by the partial order specified in the plan

♦ Resource constraints impose additional restrictions on the ordering ofactions not explicitly present in the original plan—actions which require thesame resources can’t be executed at the same time

♦ Problem is now defined by a disjunction of linear inequalities

♦ Scheduling with resource constraints is NP-hard

Planning with Time and Resources 14

Example: assembling cars (resources)

10 20 30 40 50 60 70 80 90

AddEngine2AddEngine1

AddWheels2

Inspect2

AddWheels1

Inspect1

100 110 120

EngineHoists(1)

WheelStations(1)

Inspectors(2)

Planning with Time and Resources 15

Integrating planning and scheduling

♦ So far, we produced a plan first, 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 accountwhen choosing which actions to perform

♦ For completeness, we need to integrate planning and scheduling—considerthe time and resource implications of choosing a particular action whengenerating 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 objects—can be true or false

• Initial state: the state of the world when planning begins

• Goal specification: the state of the world we want to achieve

• Actions: operations we can perform to change the state of the world

Domain file specifies predicates and actions

Problem file specifies objects, initial state, and goal

Planning with Time and Resources 17

PDDL domain file

Domain files 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 file

(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 fixed or variable duration

Preconditions can be “at start” or “over all” (throughout the duration)

Effects can be “at start” or “at end” and can update resources either at thestart or end of the action, or continuously during the execution of the action

Goals

Achievement goals are specified by a list 〈pi, ti〉 where ti is the time by whichpi should hold

Persist goals are specified by a condition and an interval over which it shouldhold

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 simpletemporal 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 de-fined within a domain and manipulated by the actions of the domain

Example: sum of action (resource) costs—can be split into multiple dimen-sions, one corresponding to each resource

♦ To define a metric in terms of a particular quantity, that quantity mustbe instrumented in the domain description—e.g., for a metric fuel-used, afuel-used quantity is updated every time an action consumes fuel

♦ The same initial and goal states may result in different optimal plansgiven different 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 fluents (resources)

Level 3: adds discrete durative actions

Level 4: adds continuous durative actions

♦ Introducing numeric valued fluents makes the planning problem undecid-able

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:

Pour(j1, j2):Precond: Capacity(j2) − Amount(j2) ≥ Amount(j1)Effect: 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 dependson which actions have already been performed)

Progression planners are easiest to extend to support resource consumingactions—however 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. Kambhampati’s planning lectures

♦ The main difference with classical planning is that we need to produceconcurrent plans

♦ For every solvable problem in classical planning, there is guaranteed tobe a sequential plan—this does not hold for temporal planning

♦ Intuition: consider ‘fattening’ as well as ‘lengthening’ the current partialplan

We represent the state of a partial plan prefix as [S, {A1, . . . , Ak}] whereS is the current state, and {A1, . . . , Ak} are the mutually non-interferingactions that we have already committed to applying at S

Notice that this is just a generalization of normal progression planning, inwhich 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, B’s preconditions should be true in S and B shouldnot 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, thengenerate the state [S ′, {}]

Since actions have durations, we need to decide how far to advance time—advance to the first 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, thecurrent state changes, so any new fattening will be done in the new state)

Classical progression planners do an automatic advance after each fatten (sothere 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 fluents 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 (effects of actions; contains resource as well as fluent 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 satisfied by P and M

no event in Q interferes with the persistent preconditions of A

A’s effects do not interfere with Π and Q

A does not result in concurrent resource change

When A is applied in S:

P is updated with A’s instantaneous effects

A’s persistent preconditions are added to Π

A’s delayed effects are added to Q

Planning with Time and Resources 32

Extending progression (sketch)

♦ Search algorithm (naive)

Pick a state S

If S satisfies 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


Recommended