Cut length optimization is well discussed in Wikipedia and in many websites. Even I found some examples with source code. Many companies also providing free/trial 1d-cutting software. But when I tried to run them, I observed...
1) Most of the applications available online are considering standard stock sizes.( or supporting only one stock size)
2) If stock sizes are varying, software trying to find solution by sorting ordered items (descending/ascending) and then finding minimum waste combination as per sorted priority.
Suppose, I have 10 stocks (steel bars) of varying lengths (No sorting allowed, start cutting from 1st stock), and I want to cut 3 different customer lengths in ordered quantities.
I made an application using c#. It starts with 1st stock. it finds the minimum wastage combination for the 1st stock. Then picks the 2nd stock, finds min wastage combination for it and then 3rd, 4th ... etc. But this logic is not giving optimal results. I understood, Best combo for set of stocks is different to set of individual best combos.
I want to find best cutting combinations for all available stocks, not one by one. Please help me how to do it. I understood, it is like, multi objective linear programming. But didn't find methods/examples to solve it.
//Finding best combo is just nested for loop.
//Just like solving a linear equation.
//vDistinctItemsList is a list of distinct ordered Items
//vMaxBoundForEachOrder is a list of max number of pieces than can be cut from stock for each ordered length
for (int c1 = vMaxBoundForEachOrder[0]; c1 >= 0; c1--)
{
if (vMaxBoundForEachOrder.Count > 1)
{
for (int c2 = vMaxBoundForEachOrder[1]; c2 >= 0; c2--)
{
if (vMaxBoundForEachOrder.Count > 2)
{
for (int c3 = vMaxBoundForEachOrder[2]; c3 >= 0; c3--)
{
nTotalLen = c1 * vDistinctItemsList[0] + c2 * vDistinctItemsList[1] + c3 * vDistinctItemsList[2];
//check here whether this combo is better than previous best
}
}
else
{
nTotalLen = c1 * vDistinctItemsList[0] + c2 * vDistinctItemsList[1];
//check here whether this combo is better than previous best
}
}
}
else
{
nTotalLen = c1 * vDistinctItemsList[0];
//check here whether this combo is better than previous best
}
}