I'm working in a metal workshop where we have the following challenge:
We produce driveshafts according to spec from a certain customer. They have many different specs for the driveshafts, requiring a lot of different lengths. According to the length requested, we cut 20 feet long 10inch thick steel bars into the appropriate lengths, but sometimes we end up with too much of the steel bars that go to waste. Which is costly in the long run.
I'm looking for an algorithm to solve this problem so that I can optimize cutting length for a certain number of driveshafts.
Say that I have x number of different length driveshafts to make. I want to calculate all permutations (ordered sets) of lengths, but in the process of calculating the permutations I also want to keep the total length of the y first driveshafts in the permutation so that it will be below, but as close to 20 feet as possible.
The program is supposed to receive as input the number of and length of driveshafts to produce, and generate as output optimized cutting lengths for the steel bars I need to spend in order to produce all driveshafts with as little waste of metal as possible.
Any suggestions with regards to how to code this thing? Or the permutation algorithm that is required?