I'm trying to come up with an algorithm for optimizing cutting a rod. Most of the examples I see online are for a stock of rod of a single length and optimizing the way to cut it up for max price.
I need something where the user enters length cuts they want (e.g. 2 of 1" length, 5 of 6" length, 10 of 8" length) and then they can choose to have this optimized for multiple stock rod lengths where they can choose which stock lengths they want to use, either 1 or multiple lengths, (e.g 8' stock, 10' stock, 12' stock).
I don't have a computer science background, so am not as familiar with algorithms and whatnot. From looking around I've seen Greedy Algorithm recommended, but was a little confused, because most examples were more simple.
I can logically come up with some really poor optimization starategy like 1.) see if any stock lengths are completely divisible by any of the desired cut lengths and do those first 2.) see if any stock lengths are completely divisible by any combination of desired cut lengths and do those next 3.) from there just kind of pick a pattern and stick to it like use up the smallest cuts first and largest last.
Possibly after doing a problem like this, I may need to move on to optimizing rectangular cut areas from a piece of plywood, but I can't even figure this out yet. Any help to point me in the right direction would be appreciated. I am a mobile app developer, so I'm trying to code this for a carpentry app.