Professional Documents
Culture Documents
ILOG IBM CP Optimizer Webinar Slides PDF
ILOG IBM CP Optimizer Webinar Slides PDF
Presenter
Didier Vidal
Senior Product Manager dvidal@ilog.fr
P1 35 P2 10 I1 0 I2 20
2 P1-40 P2-35
3 P1-10 P2-45
4 P1-20 P2-35
5 P1-50 P2-65
6 P1-10 P2-45
7 P1-50 P2-65
8 P1-10 P2-45
9 P1-50 P2-65
10 P1-50 P2-65
P1-50 P2-65 P1 - 20
C1
C2
C3 C1 C2
C4
Setup product 2
C3
C4
Deliver C1 and C2
ILOG, All rights reserved
Deliver C3 and C4
P1 35 P2 10 I1 0 I2 20
2 P1-40 P2-35
3 P1-10 P2-45
4 P1-20 P2-35
5 P1-50 P2-65
6 P1-10 P2-45
P1-50 P2-65 P1 - 20
P1-50 P2-65
C1
C2
C3 C1 C2
C4
Setup product 2
Deliver C3 and C4
State function
Cumul function
A production problem
Step 1 Prepare Step 1
Duration 30
Manufacturing process
Heat treating
Duration D1 Temperature T1
Heat treating
Duration D2 Temperature T2
Product Steps
1 2 3 4 5 T1 30 T2 30 - T3 30 T2 45 T3 45 T4 45 T1 45 T1 30 T4 30 T3 30 T4 45 T1 45 T2 45 T4 30 T3 30 T2 30
Orders
12 16 14 18 13
Oven 1 Capacity 4
Oven 2 Capacity 4
Oven 3 Capacity 4
A production plan
T2 Oven 1 Capacity 4
P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1
T1
P3-S1 P3-S1 P3-S1 P3-S1 P3-S1 P3-S1 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2
T2 Oven 2 Capacity 4
P2-S1 P2-S1 P2-S1 P2-S1
T4
P4-S1 P4-S1 P4-S1 P4-S1
T3
P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S3 P2-S3 P2-S3 P2-S3
T4
P2-S3 P2-S3 P3-S2 P3-S2 P3-S2 P3-S2 P3-S2 P3-S2
T2 Oven 3 Capacity 4
P2-S1 P2-S1 P2-S1 P2-S1
T1
P3-S1 P3-S1 P3-S1 P3-S1
T3
P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S3 P2-S3 P2-S3 P2-S3
T4
P2-S3 P2-S3 P3-S2 P3-S2 P3-S2 P3-S2 P3-S2 P3-S2
State function
Cumul function
10
Modeling step 1
P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P4-S1 P4-S1 P4-S1 P4-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P3-S1 P3-S1 P1-S1 P3-S1 P3-S1 P1-S1 P3-S1 P4-S2 P1-S1 P3-S1 P4-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2 P2-S3 P2-S3 P2-S3 P2-S3
Atomic decisions:
Start date and end date of each heating task (product, step, order number) Modeled as intervals
Temporal relation
Step n+1 starts at least 30 minutes after step n
ILOG, All rights reserved
11
Model step 1
dvar interval stepHeatingInt[a in allTasks] size a.ovenDuration; minimize max(a in allTasks) endOf(stepHeatingInt[a]); constraints { forall(t in allTasks : t.stepCount == 1) { startOf(stepHeatingInt[t]) >= preparationTime; }
forall(t1,t2 in allTasks : t1.processId == t2.processId && t1.stepCount + 1 == t2.stepCount && t1.commandId == t2.commandId) { endBeforeStart(stepHeatingInt[t1], stepHeatingInt[t2], preparationTime); } }
12
Solution step 1
13
Solution Step 1
Oven 1 Capacity 4
P1-S1
Oven 2 Capacity 4
P2-S1 P3-S1 P3-S1 P3-S1 P3-S2 P3-S2 P3-S2 P3-S2 P3-S3 P3-S3 P3-S3 P3-S3
P3-S1
Oven 3 Capacity 4
P4-S1
14
15
1
Pulse(p1-s1-c1, 1)
0 1
Pulse(p1-s1-c2, 1)
Pulse(p1-s1-c1, 1) 2 + Pulse(p1-s1-c2, 1) 1
16
Model step 2
dvar interval stepHeatingInt[a in allTasks] size a.ovenDuration;
minimize max(a in allTasks) endOf(stepHeatingInt[a]); constraints { forall(t in allTasks : t.stepCount == 1) { startOf(stepHeatingInt[t]) >= preparationTime; }
forall(t1,t2 in allTasks : t1.processId == t2.processId && t1.stepCount + 1 == t2.stepCount && t1.commandId == t2.commandId) { endBeforeStart(stepHeatingInt[t1], stepHeatingInt[t2], preparationTime); }
17
Solution Step 2
18
Solution Step 2
Oven 1 Capacity 4
Oven 2 Capacity 4
P1-S1 P2-S1 P1-S2 P2-S1 P1-S1 P2-S1 P2-S1 P1-S1 P2-S1 P2-S1 P2-S1 P1-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P3-S1 P1-S1 P5-S2 P2-S2 P4-S1 P4-S1 P4-S1 P4-S1 P4-S1 P5-S1 P4-S1 P5-S1 P2-S1 P4-S1 P5-S1 P2-S2 P5-S1 P2-S1 P5-S1
Oven 3 Capacity 4
19
Each heating task can be performed on one of the 3 ovens The CP Optimizer concept to model this is an alternative statement
20
Min 30 minutes
P1-S3
Alternative
Alternative
P1-S1 on O2
P1-S2 on O2
Alternative
P1-S1 on O1
P1-S2 on O1
P1-S3 on O1
P1-S3 on O2
P1-S1 on O3
P1-S2 on O3
P1-S3 on O3
Oven 1 Capacity 4
21
Model step 3
dvar interval stepHeatingInt[a in allTasks] size a.ovenDuration; dvar interval stepOvenInt[a in allTasks][f in ovens] optional; cumulFunction ovenUsage[f in ovens] = sum(a in allTasks) pulse(stepOvenInt[a][f], 1); minimize max(a in allTasks) endOf(stepHeatingInt[a]); constraints { forall(t in allTasks : t.stepCount == 1) { startOf(stepHeatingInt[t]) >= preparationTime; } [...] forall(t in allTasks) alternative(stepHeatingInt[t], all (f in ovens) stepOvenInt[t][f]);
22
Solution Step 3
23
Solution Step 3
Oven 1 Capacity 4
P1-S1 P2-S1 P1-S2 P2-S1 P1-S1 P2-S1 P2-S1 P1-S1 P2-S1 P2-S1 P2-S1 P1-S1
Oven 2 Capacity 4
Oven 3 Capacity 4
P4-S1 P4-S1 P5-S1 P4-S1 P5-S1 P2-S1 P4-S1 P5-S1 P2-S2 P5-S1 P2-S1 P5-S1
24
T4 10 5 0 5 15 10 5 0
25
4
State function for oven 1
3 2 1 0
Only intervals requiring T1 allowed
5 minutes min
Only intervals requiring T2 allowed
-1 (undefined)
State function
ILOG, All rights reserved
26
Model step 4
dvar interval stepHeatingInt[a in allTasks] size a.ovenDuration; dvar interval stepOvenInt[a in allTasks][f in ovens] optional; cumulFunction ovenUsage[f in ovens] = sum(a in allTasks) pulse(stepOvenInt[a][f], 1); stateFunction ovenTemperatureCode[f in ovens] with transitionTimes;
minimize max(a in allTasks) endOf(stepHeatingInt[a]); constraints { forall(t in allTasks : t.stepCount == 1) { startOf(stepHeatingInt[t]) >= preparationTime; } [...] forall(t in allTasks) alternative(stepHeatingInt[t], all (f in ovens) stepOvenInt[t][f]); forall(t in allTasks, f in ovens) alwaysEqual(ovenTemperatureCode[f], stepOvenInt[t][f], t.ovenTemperatureCode); forall(f in ovens) ovenUsage[f] <= ovenCapacity[f]; }
ILOG, All rights reserved
27
Solution Step 4
T2 Oven 1 Capacity 4
P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P2-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1 P1-S1
T1
P3-S1 P3-S1 P3-S1 P3-S1 P3-S1 P3-S1 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2 P4-S2
T2 Oven 2 Capacity 4
P2-S1 P2-S1 P2-S1 P2-S1
T4
P4-S1 P4-S1 P4-S1 P4-S1
T3
P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S3 P2-S3 P2-S3 P2-S3
T4
P2-S3 P2-S3 P3-S2 P3-S2 P3-S2 P3-S2 P3-S2 P3-S2
T2 Oven 3 Capacity 4
P2-S1 P2-S1 P2-S1 P2-S1
T1
P3-S1 P3-S1 P3-S1 P3-S1
T3
P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S2 P2-S3 P2-S3 P2-S3 P2-S3
T4
P2-S3 P2-S3 P3-S2 P3-S2 P3-S2 P3-S2 P3-S2 P3-S2
28
29
oven 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3
startTime endTime duration temperatureCode label 30 120 90 2 P2S1: 8 125 680 555 1 P1S1: 12 - P2S4: 16 - P3S1: 10 - P4S2: 18 685 775 90 2 P1S2: 1 - P4S3: 4 - P5S3: 5 780 810 30 3 P1S3: 3 30 75 45 2 P2S1: 4 85 130 45 4 P4S1: 4 135 225 90 3 P2S2: 8 230 485 255 4 P2S3: 5 - P3S2: 7 - P4S1: 9 - P5S1: 6 490 580 90 3 P3S3: 6 - P5S2: 6 585 735 150 2 P1S2: 7 - P4S3: 4 - P5S3: 6 740 800 60 3 P1S3: 5 - P3S3: 3 30 75 45 2 P2S1: 4 80 110 30 1 P3S1: 4 120 210 90 3 P2S2: 8 215 500 285 4 P2S3: 11 - P3S2: 7 - P4S1: 5 - P5S1: 7 505 595 90 3 P3S3: 5 - P5S2: 7 600 770 170 2 P1S2: 4 - P4S3: 10 - P5S3: 2 775 805 30 3 P1S3: 4
usage 100.00% 98.65% 100.00% 75.00% 100.00% 100.00% 100.00% 100.00% 100.00% 95.00% 100.00% 100.00% 100.00% 100.00% 100.00% 100.00% 92.65% 100.00%
30
State function
Cumul function
31
32
forall(t in tasks : t.isSubdivided == 1) { span(taskInt[t], all(s in tasks : s.parentId == t.taskId && s.projectId == t.projectId) taskInt[s]); } forall(t in dependencies) endBeforeStart(taskInt[<t.projectId, t.beforeTid>], taskInt[<t.projectId, t.afterTid>]);
33
Various costs
int n = 100; int horizon = 500; int capMax = 500; dvar interval cover in 0..horizon size horizon; dvar interval a[i in 1..n] optional in 0..horizon size i; cumulFunction free = pulse(cover, 0, capMax); cumulFunction level = sum(i in 1..n) pulse(a[i],n-i) + free; Requires n-i resources
dexpr int peak = capMax - heightAtStart(cover, free); dexpr int makespan = max(i in 1..n) endOf(a[i]); dexpr int nbTasks = sum(i in 1..n) presenceOf(a[i]); int mpeak = 1; int mmakespan = 0; int mnbTasks = 0; Size i
minimize mpeak*peak + mmakespan*makespan - mnbTasks*nbTasks; subject to { forall(i in 1..n) presenceOf(a[i]) + mnbTasks >= 1; level <= capMax - 200*mnbTasks; heightAtStart(cover, free) <= mpeak*capMax; }
Cap max
10 40 90
Horizon (500)
Free
34
Various costs
600 500
400 minimize makespan Minimize peak Maximize task count with cap 300 200
300
100
Size i
0 1 38 75 112 149 186 223 260 297 334 371 408 445 482
Cap max
10 40 90
Horizon (500)
Free
35
State function
Cumul function
36
CP Optimizer tutorial
54 pages
Resources at cpoptimizer.ilog.com
37
Thank You!