We're talking about metal products factory. There is machine which cuts long iron bars to smaller parts which are later used for creating various products.
For example, I have requirement to produce bars of following length and quantity: 2 pieces of 248mm, 5 of 1150mm, 6 of 2843mm, 3 of 3621mm.
That is the partitioning output.
On input side I have (again for example) 3 bars of 2500mm, 2 bars of 5000mm, 6 bars of 8000mm and 3 bars of 10000mm.
I should find a way how to cut input bars optimally - the rest (remaining parts that are too small to be used) after cutting should be smallest as possible.
I've created algorithm which simply creates all possible combinations and then pick best one among them. Code works, but as soon as input and output are little bit bigger, calculation can last very long, so I must find new approach to the problem.
Do you have any hints?