Resource Scheduling Constraints Nicolas Beldiceanu SICS - - PowerPoint PPT Presentation

resource scheduling constraints
SMART_READER_LITE
LIVE PREVIEW

Resource Scheduling Constraints Nicolas Beldiceanu SICS - - PowerPoint PPT Presentation

Resource Scheduling Constraints Nicolas Beldiceanu SICS Lgerhyddsvgen 5 SE-75237 Uppsala, Sweden (nicolas@sics.se) Resource scheduling constraints 1. Overview 2. Cumulative 3. Cumulatives Resource scheduling Problem: tasks


slide-1
SLIDE 1

Resource Scheduling Constraints

Nicolas Beldiceanu SICS

Lägerhyddsvägen 5 SE-75237 Uppsala, Sweden (nicolas@sics.se)

slide-2
SLIDE 2

Resource scheduling constraints

  • 1. Overview
  • 2. Cumulative
  • 3. Cumulatives
slide-3
SLIDE 3

Resource scheduling

  • Problem: tasks subject to temporal and

resource constraints

  • Most successful area of CP
  • LP is usually poor on this type of problems
  • Two main categories of resources:
  • renewable
  • non-renewable
slide-4
SLIDE 4

Resource scheduling constraints

  • 1. Overview
  • 2. Cumulative
  • 3. Cumulatives
slide-5
SLIDE 5

ARGUMENTS :

ctr_arguments(cumulative, [TASKS-collection(origin-dvar, duration-dvar, end-dvar, height dvar), LIMIT-int]).

PURPOSE :

The cumulative constraint enforces that at each point in time, the cumulated height of the set of tasks that overlap that point, does not exceed a given limit.

ORIGIN : [AggounBeldiceanu93] EXAMPLE :

cumulative([[origin-1, duration-3 , end-4 , height-1], [origin-2, duration-9 , end-11, height-2], [origin-3, duration-10, end-13, height-1], [origin-6, duration-6 , end-12, height-1], [origin-7, duration-2 , end-9 , height-3]],8)

Cumulative

slide-6
SLIDE 6

Cumulative

INITIAL GRAPH

slide-7
SLIDE 7

Cumulative

1 2 3 4 5 6 7 8 91011 12 ≤ ≤ ≤ ≤ 8

( 3+1+1+2 ≤ ≤ ≤ ≤ 8 ) 7

slide-8
SLIDE 8

ARGUMENTS :

ctr_arguments(coloured_cumulative, [TASKS-collection(origin-dvar, duration-dvar, end-dvar, colour-dvar), LIMIT-int]).

PURPOSE :

The coloured_cumulative constraint enforces that at each point in time, the number of distinct colours of the set of tasks that overlap that point, do not exceed a given limit.

ORIGIN : Derived from cumulative and nvalues. EXAMPLE :

coloured_cumulative([[origin-1, duration-2 , end-3 , colour-1], [origin-2, duration-9 , end-11, colour-2], [origin-3, duration-10, end-13, colour-3], [origin-6, duration-6 , end-12, colour-2], [origin-7, duration-2 , end-9 , colour-3]],2)

Coloured_cumulative

slide-9
SLIDE 9

Coloured_cumulative

INITIAL GRAPH

slide-10
SLIDE 10

Coloured_cumulative

1 2 3 4 5 6 7 8 9101112 ≤ ≤ ≤ ≤ 2

3 2 3 2 1 nvalues([3,2,3,2],≤ ≤ ≤ ≤,2) 7

slide-11
SLIDE 11

Definition of cumulative

cumulative(Origins,Durations,Heights,Limit)

ListDvars ListDvars ListDvars Int

time quantity

  • f resource

Limit task

  • rigin

height duration

slide-12
SLIDE 12

Example of cumulative

O1 in 1..2, O2 in 3..3, D1 in 2..3, D2 in 2..2, H1 in 1..4, H2 in 2..3 cumulative([O1,O2],[D1,D2],[H1,H2],4), labeling([leftmost,up],[O1,D1,H1,O2,D2,H2]). [1,2,1,3,2,2] [1,3,1,3,2,3] [1,2,1,3,2,3] [1,3,2,3,2,2] [1,2,2,3,2,2] [2,2,1,3,2,2] [1,2,2,3,2,3] [2,2,1,3,2,3] [1,2,3,3,2,2] [2,2,2,3,2,2] [1,2,3,3,2,3] [2,3,1,3,2,2] [1,2,4,3,2,2] [2,3,1,3,2,3] [1,2,4,3,2,3] [2,3,2,3,2,2] [1,3,1,3,2,2]

slide-13
SLIDE 13

Main applications of cumulative

1 2 3 1

Renewable resource

  • disjunctive scheduling
  • cumulative scheduling

Non renewable resource

  • producer consumer

Bin-packing Necessary condition for placement

slide-14
SLIDE 14

Producer-Consumer

Final Stock Consumed Quantity C Stock production task Consumer task Initial stock Produced Quantity P

slide-15
SLIDE 15

Cumulative for placement

We want to place the 8 followings rectangles in a 12 x 4 rectangle : R1(5×2), R2(8×3), R3(6×1), R4(5×1), R5(2×1), R6(3×1), R7(2×2), R8(1×2) . There exists a cumulative solution (by cutting R8 into two pieces) but there is no solution with a non-overlapping constraint on rectangles.

(proof : M. Hujter, On the dynamic storage allocation problem, Manuscript, Computer and Automation Institute Hung. Acad. Sci. (1990))

4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12

R8

R1 : 5 × 2 R2 : 8 × 2 R1 : 6 × 1 R8 R4 : 5 × 1 R5 R6:3 × 1 R2 : 2 × × × × 2

slide-16
SLIDE 16

Resource scheduling constraints

  • 1. Overview
  • 2. Cumulative
  • 3. Cumulatives
slide-17
SLIDE 17

The cumulatives constraint

The original cumulative constraint:

Restrict the resource consumption at each point in time.

The generalized cumulatives constraint:

A pool of cumulative resources , Height of a task can be negative , Maximum or minimum resource consumption , Holds for time-points crossed by at least one task.

1 2 3 4 5 6 1 2 3 4 1 2 3 4 time resource consumption

≤ ≤ ≤ ≤ 4

time resource consumption 1 2 3 4 5 6

  • 2
  • 1

1 2

  • 1

1 Cumulated profiles 2 1 3 4 5 7 6

≥ ≥ ≥ ≥ 0 ≥ ≥ ≥ ≥ 0

slide-18
SLIDE 18

Parameters

  • Tasks:
  • Origin
  • Duration
  • End
  • Height
  • Machine

1 2 3 4 5 6 1 2 3 1 time Origin End Duration Height Machine

Consumption Resource 2 Resource 1

Origin+Duration=En d

  • Constraint:
  • upper
  • lower

1 2 3 1 ≤ 1 2 3 1 ≥

  • MachineId
  • Limit

1 2 3 1 Limit Identifier

  • Resources:

task(O,D,E,H,M) machine(M,L) bound(Ctr)

slide-19
SLIDE 19

D E F I N I T I O N

For all tasks : For all time-points crossed by task : Let be the machine where task is assigned , For all tasks which both cross point , and are assigned to : The sum of the height of tasks is not greater (less) than the capacity of machine .

t t t i m s i m m s

time resource consumption

  • 2
  • 1

1 2

  • 1

1 3 5 7 6

≥ ≥ ≥ ≥ 0

≥ ≥ ≥ ≥ 0

Machine 1 Machine 2

1 2 4 1

2

3 4 5 6

E X A M P L E

slide-20
SLIDE 20

Original cumulative constraint

1 2 3 4 5 6 1 2 3 4 1 2 3 4 time resource consumption

Maximum capacity

({machine-1 origin-2 duration-2 height-2 machine-1 origin-4 duration-2 height-1 machine-1 origin-3 duration-1 height-1 machine-1 origin-5 duration-1 height-3}, {id-1 capacity-4},

≤ ≤ ≤ ≤)

cumulatives

slide-21
SLIDE 21

cumulative constraint with machine choice

({machine-1 origin-2 duration-3 height-1, machine-1 origin-3 duration-2 height-2, machine-2 origin-2 duration-4 height-1, machine-1 origin-6 duration-1 height-2}, {id-1 capacity-3,

id-2 capacity-1},

≤) cumulatives resource consumption

Machine 2 with capacity 1 Machine 1 with capacity 3

1 2 3 4 5 6 1 2 3 1 time 1 2 3 4

slide-22
SLIDE 22

Uninterupted minimum level

  • f resource consumption

({machine-1 origin-2 duration-4 height-0, machine-1 origin-2 duration-4 height-1, machine-1 origin-2 duration-2 height-1, machine-1 origin-4 duration-2 height-2, machine-1 origin-4 duration-1 height-1}, {id-1 capacity-2},

≥ ≥ ≥ ≥)

cumulatives 1 2 3 4 5 6 1 2 3 4 time resource consumption 2 3 4 5 1

Minimum consumption is 2

First use Last use

slide-23
SLIDE 23

Minimum level of resource consumption

({machine-1 origin-2 duration-2 height-1, machine-1 origin-2 duration-1 height-2, machine-1 origin-3 duration-1 height-1, machine-1 origin-5 duration-2 height-2}, {id-1 capacity-2},

≥ ≥ ≥ ≥)

cumulatives 1 2 3 4 5 6 1 2 3 4 time resource consumption No constraint at this point 3 1 2 4

Minimum consumption is 2

slide-24
SLIDE 24

Producer-consumer

cumulatives machine-1 origin-1 duration-3 height-2, machine-1 origin-1 duration-4 height-3, machine-1 origin-1 duration-6 height-1, machine-1 origin-5 duration-2 height-4}, ({ {id-1 capacity-7}, ≤) time resource consumption

No negative stock

1 2 3 4 5 6 1 2 3 4 5 6 7 1 4 2 3 Stock at this point in time

slide-25
SLIDE 25

Producer-Consumer with multiple resources

cumulatives {id-1 capacity-4, id-2 capacity-3}, ≤ ) time resource consumption

No negative stock on resource 2

1 2 3 4 5 6 1 2 3 4 1 2 3 Stocks at this points in time 3 1 2 4 5

No negative stock on resource 1

machine-1 origin-1 duration-1 height-1, machine-1 origin-1 duration-3 height-2, machine-2 origin-1 duration-3 height-1, machine-2 origin-3 duration-4 height-2} machine-1 origin-3 duration-4 height-1, , ({

slide-26
SLIDE 26

Workload covering

cumulatives {id-1 capacity-0}, ≥) time resource consumption

Green tasks ”cover” yellow tasks

1 2 3 4 5 6

  • 4
  • 3
  • 2
  • 1

1 2 3 Cumulated profile machine-1 origin-2 duration-2 height-(-2), machine-1 origin-4 duration-2 height-(-3), ({ 1 3 2 4 5 6 machine-1 origin-1 duration-4 height-1, machine-1 origin-5 duration-2 height-1, machine-1 origin-2 duration-4 height-1, machine-1 origin-3 duration-3 height-1} ,

slide-27
SLIDE 27

Workloads covering

cumulatives {id-1 capacity-0, id-2 capacity-0} ≥ ) ({ time resource consumption 1 2 3 4 5 6

  • 2
  • 1

1 2

  • 1

1 Cumulated profiles 2 1 3 4 5 7 6 machine-1 origin-2 duration-2 height-(-2), machine-1 origin-1 duration-4 height-1, machine-1 origin-4 duration-2 height-(-1), machine-1 origin-2 duration-3 height-2, machine-1 origin-5 duration-2 height-2, machine-2 origin-3 duration-2 height-(-1), machine-2 origin-1 duration-4 height-1} ,

Green tasks ”cover” yellow tasks on both resources

slide-28
SLIDE 28

Exercise: project scheduling

Each task requires a given number of persons. Knowning that you have at most 7 persons, find the earliest end.

T1 2-1 T2 1-3 T3 4-3 T4 2-2 T5 3-4 T6 1-6 T7 0-0

slide-29
SLIDE 29

Exercise: project scheduling (load)

Each task requires a given load (duration x needed resource).Knowning that you have at most 7 persons, modify your previous program in order to find the earliest end.

T1 1 T2 3 T3 12 T4 4 T5 12 T6 6 T7

slide-30
SLIDE 30

Exercise: perfect square

Write a program for finding a solution for placing 21 squares of respective size [50,42,37,35,33,29, 27,25,24,19,18,17,16,15,11,9,8,7,6,4,2]) into a square of size 112 without overlap.

slide-31
SLIDE 31

Exercise: machine scheduling

Each task has to run on a given machine chosen from a set of machines. Each machine can only run one task at a time and each task should not be interrupted. Find the earliest end. T1 2-{1,2} T2

1-{1,3}

T3 4-{1,3} T4 2-{2,3} T5 3-{1} T6 1-{1,3} T7 0-{}

slide-32
SLIDE 32

Exercise: machine scheduling (quotient labeling)

Create a specialized labeling which, for each task, creates a compulsory part (intersection

  • f the task positioned at its earliest start and
  • f the task positioned at its latest start) of

size 1. Justify the use of this heuristics.

slide-33
SLIDE 33

Exercise: machine scheduling (variable speed)

The effective duration of a task is now computed by multiplying the ”duration” by a fixed coefficient (2 of M1, 1 of M2, 3 for M3). Modify your program to handle this factor.

slide-34
SLIDE 34

The Sweep Algorithm: Fixed Tasks

resource time Event points Minimum level to reach for those instants where there is at least one task Current position

  • f the sweep line: 3

Sweep-line status

1 2 3 4 Task 1 Task 2 Task 3

  • nb_task=1
  • sum_height=2

1 2 4 5

Sweep line status:

number of tasks sum of the height

  • which overlap the sweep line

Event points:

start of each task end of each task

  • nb_task=2
  • sum_height=3
  • nb_task=0
  • sum_height=0
  • nb_task=1
  • sum_height=4
  • nb_task=0
  • sum_height=0
slide-35
SLIDE 35

Not Yet Fixed Tasks

Preconditions for a Check Event

max(origin[t])<min(end[t]) min(machine[t])=max(machine[t])=r max(height[t])<max(0,Limit[m])

  • machine[t]

: nb_task=nb_task+1 : nb_task=nb_task− − − −1 Start End

QUESTION ANSWER ACTION : which instants to check ? : those instants for which there is a task which can cause a problem : count the number of such tasks which overlap the sweep line

slide-36
SLIDE 36

Not Yet Fixed Tasks (continued)

Preconditions for a Bad Profile Event

max(origin[t]) < min(end[t]) min(machine[t]) = max(machine[t]) = r max(height[t]) < 0

  • r

: sum_height=sum_height+max(height[t]) : sum_height=sum_height − − − −max(height[t]) Start End

QUESTION ANSWER ACTION : how to build an ”optimistic” resource consumption profile ? : consider the ”bad” and ”good” tasks : sum up the height of such tasks which overlap the sweep line Preconditions for a Good Profile Event

r ∈ ∈ ∈ ∈ dom(machine[t]) max(height[t]) > 0

  • r

: sum_height=sum_height+max(height[t]) : sum_height=sum_height − − − −max(height[t]) Start End

slide-37
SLIDE 37
  • 10. if nb_task≠0 and sum_height<limit to reach then return fail
  • 1. Scan the tasks and generate the check and profile events
  • 2. Sort the events in increasing order
  • 3. Set nb_task and sum_height to 0 and d to the smallest date

The Sweep Algorithm: Main Loop

(simplified version: one resource, no pruning)

  • 4. while there still exist an event E do

9. Extract the next event E (if it exists)

INITIALIZATION CHECK MODIFY SWEEP STATUS CHECK

5. if d≠date of E then 6. if nb_task≠0 and sum_height<limit to reach then return fail 7. Set d to date of E 8. if type of E=check then add E.inc to nb_task else add E.inc to sum_height

slide-38
SLIDE 38

Principle of the Generalization Algorithm

1 2 3 4 5 6 1 2 3 1 time 1 2 3 4 Machine 1 Machine 2 1 2 3 4 5 6

? ?

Removes 3,4 from origin of task 4

slide-39
SLIDE 39

Task Interval

DEFINITION: At each instant: Σ Σ Σ Σ heigths ≥ ≥ ≥ ≥ Capacity

NECESSARY CONDITION: Σ Σ Σ Σ surfaces ≥ ≥ ≥ ≥ utilisation of interval x Capacity

IDEA: sum up over each instant where we have at least one task

time 1 2 3 4 5 6

  • 4
  • 3
  • 2
  • 1

1 2 3 ≥ ≥ ≥ ≥ 1 time resource consumption 1 2 3 4 5 6

  • 4
  • 3
  • 2
  • 1

1 2 3 1 3 2 4 5 6 ≥ ≥ ≥ ≥ 1

interval ≥ ≥ ≥ ≥ (1+1+1)X1 (3-1)+(1+1+1-2)+(1+1+1-2)

slide-40
SLIDE 40

Task Interval (atleast case)

  • For tasks with negative height
  • For tasks with positive height
  • If non-negative capacity
  • If negative capacity

: minimum intersection with interval : maximum intersection with interval : minimum utilization in time of interval : maximum utilization in time of interval CHECKING THE NECESSARY CONDITION

  • Forbid to cover more than a given surface in an interval
  • Force to cover at least a given surface in an interval

PRUNING ACCORDING TO THE NECESSARY CONDITION

slide-41
SLIDE 41

Minimum Intersection of a Task with an Interval

interval

T at its earliest start and minimum duration T at its latest end and minimum duration

2 1

Compute the size of the intersection with the interval of these two instances, and take the minimum

Result is 1

slide-42
SLIDE 42

Key ideas of most algorithms for resource scheduling: compulsory part

DEFINITION : The Compulsory Part CP (A. Lahrichi PhD

thesis 1979) is the intersection of all feasible instances of the task T

INTEREST : No need to wait until all the variables

(start, duration, resource consumption) of task T are fixed to deduce some information about resource consumption of T over time. The other tasks will not have access to that resource amount pruning

MAIN QUESTION : How to efficiently compute the CP?

slide-43
SLIDE 43

To compute CP, we need to compute only the intersection of the two followings instances of the rectangle task : Imin= task at its earliest date with minimum duration Imax= task at its latest date

Compulsory part Startmin Startmax Startmin + Durationmin Durationmin Durationmax

CP of a rectangle task

slide-44
SLIDE 44

3 T T T

CP CP CP

2 1

∪ ∪

Startmax Startmin

T1 T2 T3 T1 T2 T3

3 2 1

T T T

CP

∪ ∪

∅ =

1

T

CP ∅ =

2

T

CP

CP of the “global” task

CP of a sequence of rectangles

slide-45
SLIDE 45

Scheduling Problem under Labour Constraints

resource time

0 1 2 3 4 5 6 7 8 9 10 11 12 6 5 4 3 2 1

Compulsory part of T2

T1 can not start at positions 0,1,2 and 6

T2 T1

  • Starting time of of T2 within [1, 3]
  • No restriction on the starting time of T1
  • Resource capacity equal to 6

Use of CP for pruning

slide-46
SLIDE 46

Plane task (LT)

Smax Emin

Smin Smax Emin Emax

Earliest start Imin Latest end Imax

Task

CP of a task with valleys

CP = Imin∩ Imax ∩ LT

slide-47
SLIDE 47

Key ideas of most algorithms for resource scheduling: task interval

IDEA : Compute the intersection of all feasible instances

  • f a task T with a given interval and take the minimum.

Repeat the previous step for all tasks Cumulate all the minimum intersections and check that it does not exceed the available surface

MAIN QUESTION : How to efficiently compute the minimum

intersection with an interval?

slide-48
SLIDE 48

Exercise: maximum intersection

Consider a cumulative scheduling problem where one needs to use almost all the resource availability (i.e. the sum of the surface of the tasks is almost equal to the resource availability). Question 1: consider a fixed interval low..up and a task t characterized by its origin, duration and end (3 domain variables). Come up with a method for computing the maximum intersection in surface (or a lower approximation) of task t with interval low..up. Question 2: how could you use the result of question 1 to perform some pruning in the context of the cumulative constraint ?