Resource Scheduling Constraints
Nicolas Beldiceanu SICS
Lägerhyddsvägen 5 SE-75237 Uppsala, Sweden (nicolas@sics.se)
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
Lägerhyddsvägen 5 SE-75237 Uppsala, Sweden (nicolas@sics.se)
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)
INITIAL GRAPH
1 2 3 4 5 6 7 8 91011 12 ≤ ≤ ≤ ≤ 8
( 3+1+1+2 ≤ ≤ ≤ ≤ 8 ) 7
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)
INITIAL GRAPH
1 2 3 4 5 6 7 8 9101112 ≤ ≤ ≤ ≤ 2
3 2 3 2 1 nvalues([3,2,3,2],≤ ≤ ≤ ≤,2) 7
time quantity
Limit task
height duration
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]
1 2 3 1
Final Stock Consumed Quantity C Stock production task Consumer task Initial stock Produced Quantity P
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
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
1 2
1 Cumulated profiles 2 1 3 4 5 7 6
≥ ≥ ≥ ≥ 0 ≥ ≥ ≥ ≥ 0
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
1 2 3 1 ≤ 1 2 3 1 ≥
1 2 3 1 Limit Identifier
task(O,D,E,H,M) machine(M,L) bound(Ctr)
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 .
time resource consumption
1 2
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
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
({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
({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
({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
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
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, , ({
cumulatives {id-1 capacity-0}, ≥) time resource consumption
Green tasks ”cover” yellow tasks
1 2 3 4 5 6
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} ,
cumulatives {id-1 capacity-0, id-2 capacity-0} ≥ ) ({ time resource consumption 1 2 3 4 5 6
1 2
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
1-{1,3}
resource time Event points Minimum level to reach for those instants where there is at least one task Current position
Sweep-line status
1 2 3 4 Task 1 Task 2 Task 3
1 2 4 5
Sweep line status:
number of tasks sum of the height
Event points:
start of each task end of each task
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])
: 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
Preconditions for a Bad Profile Event
max(origin[t]) < min(end[t]) min(machine[t]) = max(machine[t]) = r max(height[t]) < 0
: 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
: sum_height=sum_height+max(height[t]) : sum_height=sum_height − − − −max(height[t]) Start End
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
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
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
1 2 3 ≥ ≥ ≥ ≥ 1 time resource consumption 1 2 3 4 5 6
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)
: minimum intersection with interval : maximum intersection with interval : minimum utilization in time of interval : maximum utilization in time of interval CHECKING THE NECESSARY CONDITION
PRUNING ACCORDING TO THE NECESSARY CONDITION
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
DEFINITION : The Compulsory Part CP (A. Lahrichi PhD
INTEREST : No need to wait until all the variables
MAIN QUESTION : How to efficiently compute the CP?
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
3 T T T
2 1
Startmax Startmin
3 2 1
T T T
∪ ∪
1
T
2
T
CP of the “global” task
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
Plane task (LT)
Smax Emin
Smin Smax Emin Emax
Earliest start Imin Latest end Imax
Task
CP = Imin∩ Imax ∩ LT
IDEA : Compute the intersection of all feasible instances
MAIN QUESTION : How to efficiently compute the minimum
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 ?