cmsc 722, ai planning planning and scheduling

40
1 Lecture slides for Automated Planning nder the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/ CMSC 722, AI Planning Planning and Scheduling Dana S. Nau Dept. of Computer Science, and Institute for Systems Research University of Maryland

Upload: yan

Post on 25-Jan-2016

61 views

Category:

Documents


1 download

DESCRIPTION

CMSC 722, AI Planning Planning and Scheduling. Dana S. Nau Dept. of Computer Science, and Institute for Systems Research University of Maryland. Scheduling. Given: actions to perform set of resources to use time constraints Objective: allocate times and resources to the actions - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CMSC 722, AI Planning Planning and Scheduling

1Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

CMSC 722, AI Planning

Planning and Scheduling

Dana S. Nau

Dept. of Computer Science, and

Institute for Systems Research

University of Maryland

Page 2: CMSC 722, AI Planning Planning and Scheduling

2Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Scheduling Given:

actions to perform set of resources to use time constraints

Objective: allocate times and resources to the actions

What is a resource? Usually represented as a numeric quantity Actions modify it in a relative way Several concurrent actions may use the same resource

Page 3: CMSC 722, AI Planning Planning and Scheduling

3Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Planning and Scheduling

Scheduling has usually been addressed separately from planning Thus, will give an overview of scheduling algorithms

In some cases, cannot decompose them so cleanly Thus, will discuss how to integrate them

Page 4: CMSC 722, AI Planning Planning and Scheduling

4Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Scheduling Problem Scheduling problem

set of resources and their future availability actions and their resource requirements constraints cost function

Schedule allocations of resources and start times to actions

» must meet the constraints and resource requirements

Page 5: CMSC 722, AI Planning Planning and Scheduling

5Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Action a resource requirements

» which resources, what quantities start time s(a), end time e(a), duration d(a) usually, upper and lower bounds

» s(a) in [smin(a),smax(a)]

» e(a) in [emin(a),emax(a)]

Non-preemptive action: cannot be interrupted Preemptive action: can interrupt and resume

d(a) = sum { di(a) ≤ e(a)–s(a) | i in I}

can have constraints on the intervals

Page 6: CMSC 722, AI Planning Planning and Scheduling

6Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Resources Reusable resource r

“borrowed” by an action, and released afterward

» e.g., use a tool, return it when done total capacity Qr , may be either discrete or continuous

current level zr(t) in [0,Qr]

» e.g., five cranes at a location

• Qr = 5, and 5 ≥ zr(t) ≥ 0

if action requires quantity q of r, then diminish zr by q at time s(a), increase it by q at time e(a)

Page 7: CMSC 722, AI Planning Planning and Scheduling

7Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Consumable resource r “consumed” (or in some cases produced) by an action afterwards, does not revert to previous value e.g., use fuel total capacity Qr

current level zr(t) in [0,Qr]

Page 8: CMSC 722, AI Planning Planning and Scheduling

8Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Resource requirement of an action is a conjunct of assertions consume(a,rj,qj) & …

or disjunct if there are alternatives consume(a,rj,qj) v …

zr is called the “resource profile” for z

Page 9: CMSC 722, AI Planning Planning and Scheduling

9Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Constraints Bounds on start and end points of an action

absolute times

» e.g., a deadline: e(a) ≤ u

» release date: s(a) ≥ v relative times

» latency: s(b)–e(a) in [u,v]

» total extent: e(a)–s(a) in [u,v] Constraints on availability of a resource

e.g., can only communicate with a satellite at certain times

Page 10: CMSC 722, AI Planning Planning and Scheduling

10Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Costs may be fixed may be a function of quantity and duration

e.g., set-up cost plus run-time cost e.g., suppose a follows b

cost cr(a,b) for a

duration dr(a,b), i.e., s(b) ≥ e(a) + dr(a,b)

Page 11: CMSC 722, AI Planning Planning and Scheduling

11Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Objective: minimize some function of the various costs and/or end-times

Page 12: CMSC 722, AI Planning Planning and Scheduling

12Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Types of Scheduling Problems Machine scheduling

machine i: unit capacity (in use or not in use) job j: partially ordered set of actions aj1, …, ajk

schedule:

» a machine i for each action ajk

» a time interval during which i processes ajk

» no two actions can use the same machine at once actions in different jobs are completely independent actions in the same job cannot overlap

» e.g., actions to be performed on the same physical object

Page 13: CMSC 722, AI Planning Planning and Scheduling

13Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Single-stage machine scheduling each job is a single action, and can be processed on any machine identical parallel machines

» processing time pj is the same regardless of which machine

• can model all m machines as a single resource of capacity m

uniform parallel machines

» machine i has speed(i); time for j is pj/speed(i)

unrelated parallel machines

» different time for each combination of job and machine

Page 14: CMSC 722, AI Planning Planning and Scheduling

14Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Multiple-stage scheduling problems job contains several actions each requires a particular machine flow-shop problems:

» each job j has exactly m actions {aji | j = 1, …, m}

» each aji needs to be done on machine i

» actions must be done in order aj1, aj2, …, ajm

open-shop problems

» like flow-shop, but can do actions in any order job-shop problems (general case)

» constraints on order of actions, which machine for each action

Page 15: CMSC 722, AI Planning Planning and Scheduling

15Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Example Job shop, machines m1, m2, m3, jobs j1, …, j5.

j1: <m2(3), m1(3), m3(6)>

m2 for 3 time units, m1 for 3 time units, m3 for 6 time units

j2: <m2(2), m1(5), m2(2) , m3(7)>

j3: <m3(5), m1(7), m2(3)>

j4: <m2(4), m3(6), m1(7), m2(4)>

j5: <m2(6), m3(2)>

Page 16: CMSC 722, AI Planning Planning and Scheduling

16Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Notation Standard notation for designating machine scheduling problems:

| |

= type of problem:

• P (identical), U (uniform), R (unrelated) parallel machines

• F (flow shop), O (open shop), J (job shop)

= job characteristics (deadlines, setup times, precedence constraints), empty if there are no constraints

= the objective function Examples:

Pm | j | jwjej

» m identical parallel machines, deadlines on jobs, minimize weighted completion time

J | prec | makespan

» job shop with arbitrary number of machines, precedence constrants between jobs, minimize the makespan

Page 17: CMSC 722, AI Planning Planning and Scheduling

17Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Complexity Most machine scheduling problems are

NP-hard There are many polynomial-time

reductions

P - identical parallel machines

U - uniform parallel machines

R - unrelated parallel machines

F - flow shop

O - open shop

J - job shop

Page 18: CMSC 722, AI Planning Planning and Scheduling

18Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Solving Machine Scheduling Problems Integer Programming (IP) formulations

n-dimensional space Set of constraints C, all are linear inequalities Linear objective function f Find a point p=(x1,…, xn) such that

» p satisfies C

» p is integer-valued, i.e., every xi is an integer

» no other integer-valued point p’ satisfies C and has f(p') < f(p) A huge number of problems can be translated into this format

An entire subfield of Operations Research is devoted to Integer Programming Several commercial IP solvers

Page 19: CMSC 722, AI Planning Planning and Scheduling

19Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

IP Solvers Most IP solvers use depth-first branch-and-bound Depth-first backtracking

Node selection is guided by a lower bound function L(u)» For every node u, L(u) ≤ {f(v) : v is a descendant of u}

procedure DFBBglobal u* nil; f* ∞ call search(r), where r is the initial nodereturn (u*,f*)

procedure search(u)if u is a solution and f(u) < f*

then u* u; f* f(u)else if u has no unvisited children or L(u) ≥ f(u*)

then do nothingelse call search(v), where v = argmin{L(v) : v is a not-yet-visited child of u}

L(u) is similar to A*’s heuristic functionf(u) = g(u)+h(u)

A* can be expressed as a best-first branch-and-bound procedure

Page 20: CMSC 722, AI Planning Planning and Scheduling

20Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Planning as Scheduling Some planning problems can be modeled as machine-scheduling problems Example: modified version of DWR

m identical robots, several distinct locations job: container-transportation(c,l,l')

» processed by a single robot• go to l, load c, go to l', unload c

release dates, deadlines, durations setup time tijk if robot i does job j after performing job k minimize weighted completion time

Can generalize the example to account for the following: cranes for loading/unloading arrangement of containers into piles

But can’t handle the part I said to ignore

Let’s ignore thisfor a moment

Page 21: CMSC 722, AI Planning Planning and Scheduling

21Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Limitations Some other things cause problems too:

Page 22: CMSC 722, AI Planning Planning and Scheduling

22Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Integrating Planning and Scheduling Extend the chronicle representation to include resources

finite set Z={z1,…,zm} of resource variables

» zi is the resource profile for resource i

Like we did with other state variables, will use function-and-arguments notation to represent resource profiles cranes(l) = number of cranes available at location l

Will focus on reusable resources resources are borrowed but not consumed

Page 23: CMSC 722, AI Planning Planning and Scheduling

23Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Temporal Assertions Resource variable z whose total capacity is Q A temporal assertion on z is one of the following:

Page 24: CMSC 722, AI Planning Planning and Scheduling

24Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Temporal Assertions (Continued)

Page 25: CMSC 722, AI Planning Planning and Scheduling

25Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Example: same figure as before.

Page 26: CMSC 722, AI Planning Planning and Scheduling

26Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Assume distinct resources are completely independent Using a resource z does not affect another resource z' Every assertion about a resource concerns just one resource

Don’t need consistency requirements for assertions about different resource variables Just for assertions about the same variable

Page 27: CMSC 722, AI Planning Planning and Scheduling

27Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Page 28: CMSC 722, AI Planning Planning and Scheduling

28Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Consistency A chronicle is consistent if

Temporal assertions on state variables are consistent

» in the sense specified in Chapter 14 No conflicts among temporal assertions

Page 29: CMSC 722, AI Planning Planning and Scheduling

29Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Example DWR domain, but locations may hold more than one robot

Resource variable space(l) = number of available spots at location l Each robot requires one spot

Page 30: CMSC 722, AI Planning Planning and Scheduling

30Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Also need to specify total capacity of each resource One way: fixed total capacity Q for {space(l) : l is a location}

Example: Q = 12 » At most 12 spots in each location» If location loc1 has only 4 spots then the initial chronicle will

contain space(loc1)@[0,oo):8 Another way: make Q depend on the location Q(loc1) = 4, Q(loc2) = 12, …

Suppose we’re only trying to find a feasible plan, not an optimal one Then except for the resources, our definitions of planning

domain, planning problem, etc. are basically the same as in Chapter 14

Page 31: CMSC 722, AI Planning Planning and Scheduling

31Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Page 32: CMSC 722, AI Planning Planning and Scheduling

32Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Page 33: CMSC 722, AI Planning Planning and Scheduling

33Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Page 34: CMSC 722, AI Planning Planning and Scheduling

34Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Page 35: CMSC 722, AI Planning Planning and Scheduling

35Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Page 36: CMSC 722, AI Planning Planning and Scheduling

36Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Page 37: CMSC 722, AI Planning Planning and Scheduling

37Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Can use such constraints to resolve resource-conflict flaws

Page 38: CMSC 722, AI Planning Planning and Scheduling

38Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Page 39: CMSC 722, AI Planning Planning and Scheduling

39Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Page 40: CMSC 722, AI Planning Planning and Scheduling

40Dana Nau: Lecture slides for Automated PlanningLicensed under the Creative Commons Attribution-NonCommercial-ShareAlike License: http://creativecommons.org/licenses/by-nc-sa/2.0/

Three main steps: solve open-goal flaws solve threat flaws solve resource-conflict flaws