In this post an interesting problem was described:
- Raw material is a number of lengths of wood types A,B,C and D.
- We want to cut it so we can create final product. This final product consists of combos of wood types A,B,C and D of the same length.
- The final product can not be shorter than 30.
- In the post it was requested to produce a cutting scheme such that left over raw material of length less than 30 (waste) is minimized.
If we would just use this objective (minimize waste) the optimal strategy would be “don’t cut anything”. Therefore our first approach is to use a slightly different objective: create as much final product as we can. Later on we will discuss some refinements.
As usual there is more than one way to skin a cat, here is just one way of doing that. First introduce our basic “assignment” variables and the index sets they operate upon:
The assignment structure follows from these fundamentals.
- The first equation is used to make sure that exactly one raw piece is used for each wood type in a final product. We introduce a binary variable yj to keep track which j’s are actually created (typically we have more j’s in the model than needed: we don’t know this number in advance).
- Equation (2) deals with the length of the final product combo. Note that Lj does not depend on the wood type w. So all pieces in the combo have the same length. Note that this final product combo length is actually a decision variable.
- Inequality (3) simply makes sure δw,i,j=0 ⇒ xw,i,j=0.
- Finally inequality (4) deals with raw material lengths. This Li is a constant.
The data set we will use is:
This means in the model we do not want to use all combinations (w,i) but rather a subset wi(w,i). A complete model setup can look like:
The model equations are:
Notes:
- The variables Lj are declared integer, just to get nicer solutions.
- The order equation helps producing nicer reports but also helps in speeding up things.
- We solved with Cplex with some extra options:
- Threads to allow parallel B&B
- Mipemphasis to indicate we want to go to optimality
- Priorities on the discrete variables to help Cplex a bit
The final results look like:
The rows represent the raw material and the columns are the final product combos. Each column should have exactly four entries (one from each color or wood type). The columns are ordered by length and the smallest length is 30. On the right we verify that we have never exceeded the raw material length. In this solution we have used up all the yellow (wood type C) raw material.