The problem below aims to minimize the cutting leftovers from each cut :
A company manufactures desks for kids gardens and primary schools, colleges and high schools. The leg of these desks all have the same diameter, but are of different lengths: 40cm for the smallest, 60cm for the medium and 70cm for the large. They are cut from 1.5m or 2m long steel bars.
This company receives an order from 108 small desks, 125 medium and 100 large.
How to carry out this order while minimizing the leftovers.
A. Formulate this optimization problem using an integer number linear program.
B. Use the Cplex solver to solve it.
Modeling the problem : The tables below represent every method and possibility for each leg length:
- Cutting cases and leftovers using 1.5m -150cm- steel bar :
| Case # /Leg length | --1-- | --2-- | --3-- | --4-- | --5-- | --6-- | Order |
|---------------------------|-------|-------|-------|--------|-------|--------|---------|
| Leg 1 -40cm--------- |.. 3 ..|.. 2 ..|.. 0 ...|.. 2 ....|.. 0 ..|.. 0 ....|.. 432 |
| Leg 2 -60cm--------- |.. 0 ..|.. 0 ..|.. 2 ...|.. 1 ....|.. 1 ..|.. 0 ....|.. 500 |
| Leg 3 -70cm--------- |.. 0 ..|.. 1 ..|.. 0 ...|.. 0 ....|.. 1 ..|.. 2 ....|.. 400 |
| Falls in cm----------- |.. 30 |.. 0 ..|.. 30 .|.. 10 ..|.. 20 |.. 10 ..|-------- |
For example :
The first column -case #1- means that with a 1.5m steel bar we can cut 3 legs of 40cm each with 30cm leftover.
The second column -case #2- means that with one bar steel of 1.5m we can cut 2 legs of 40cm and 1 leg of 70cm with no leftovers.
- Cutting cases and leftovers using 2m -200cm- steel bar :
| Case # /Leg length | --1-- | --2-- | --3-- | --4-- | --5-- | --6-- | --7-- | --8-- | --9------- | Order |
|---------------------------|-------|-------|-------|--------|-------|--------|---------|---------|---------|---------|
| Leg 1 -40cm--------- |.. 5 ..|.. 0 ..|.. 2 ...|.. 0 ....|.. 0 ..|.. 1 ....|.. 3 ....|.. 3 ....|.. 1 ....|.. 432 |
| Leg 2 -60cm--------- |.. 0 ..|.. 3 ..|.. 2 ...|.. 2 ....|.. 1 ..|.. 0 ....|.. 0 ....|.. 1 ....|.. 1 ....|.. 500 |
| Leg 3 -70cm--------- |.. 0 ..|.. 0 ..|.. 0 ...|.. 1 ....|.. 2 ..|.. 2 ....|.. 1 ....|.. 0 ....|.. 1 ....|.. 400 |
| Falls in cm----------- |.. 0 |.. 20 ..|.. 0 .|.. 10 ..|.. 20 |.. 10 ..|.. 10 ..|.. 20 ..|.. 30 ..|-------- |
Cplex code
//Variables definition :
// x = a case that could be from both tables above
// i = [1,2] : 1 => when we use the 1.5m steel bar, 2 => when we use 2m steel bar;
// j = [1..9] : for every case from the tables above -for i=1; j=[1..6] | for i=2; j=[1..9];
// z = My objective function;
// contrLEG* = constraints for each leg;
dvar int x11;
dvar int x12;
dvar int x13;
dvar int x14;
dvar int x15;
dvar int x16;
dvar int x21;
dvar int x22;
dvar int x23;
dvar int x24;
dvar int x25;
dvar int x26;
dvar int x27;
dvar int x28;
dvar int x29;
dexpr int z=30*x11+30*x13+10*x14+20*x15+10*x16+20*x22+10*x24+20*x26+10*x27+20*x28+30*x29;
minimize z;
subject to {
contrLEG1:
3*x11+2*x12+2*x14+5*x21+2*x23+x26+3*x27+3*x28+x29 >= 432;
contrLE2:
2*x13+x14+x15+3*x22+2*x23+2*x24+x25+x28+x29 >= 500;
contrLEG3:
x12+x15+2*x16+x24+2*x25+2*x26+x27+x29 >=400;
//Cplex is returning the following values :
// X=200;
// Y = 600;
// Z = 36000;
}
Question part
Can anyone tells me if I'm doing it the right way?
Can anyone confirm the values returned by Cplex?
Does 200 and 600 means that the manufacturer needs 200 steel bar of 1.5m and 600 steel bar of 2m?