2

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?

m1k4
  • 829
  • 2
  • 12
  • 26
  • oh, i get it, it's not school problem :) real world one – m1k4 Sep 10 '09 at 15:08
  • the homework tag seems excessive. Could be the guy is actually writing software for stock cutting, and the benefit of the doubt could be nice. – user44242 Sep 10 '09 at 15:35
  • yeah, the programm is not really for homework. a friend of mine is running small-business and really needs application (it's named Cutter and I'm giving him it for free). At first, i thought it's trivial but now i see that this is known academic problem (i'm uneducated developer) – m1k4 Sep 10 '09 at 15:45
  • It seems linear programming is the common way to solve these types of problems. Its interesting to note that if you could cut "real" number quantities instead of integer quantities (this of course is not the case) then this problem could be tackled with the basic simplex method, instead of a modified one with branch and bound search. This is because integer linear programming is NP hard, real linear programming isn't. – ldog Sep 10 '09 at 16:21
  • Also, note that most integer linear programming methods use a search (since this is NP hard.) It may be overall less complex and more efficient for you to omit the simplex part of the algorithm and just write a search algorithm. A* search is really efficient, and you may want to look into neural networks. – ldog Sep 10 '09 at 16:23
  • @gmatt : Neural networks are primarily used for classification problems, e.g. "is this a picture of a duck"? I don't mean to be rude or anything, but I would like you to explain *why* neural networks may be useful in this situation. Similarly, as you correctly stated, A* is an efficient search algorithm. However, this problem is an optimization, not a search problem. Could you explain what sort of heuristic you have in mind when using A* for this particular problem? – agorenst Sep 11 '09 at 03:57
  • You could use the NN in the following way. Break the sheet metal down into squared units of measurements (pixilize it) small enough to be negligible. For the inputs, input a linear array where each input represents one of the pixels. In the inputs include the dimensions of the desired pieces to be cut. The output would just be a linear array of pixels indicating which area will be included in the cut. If the training data provided does this efficiently then there is a good chance that the NN may do it also efficiently. I think to verify this claim experimentation would have to be done. – ldog Sep 11 '09 at 17:20
  • For the A* search, start with placing the desired pieces to be cut within a bounded rectangle, **not** worrying about overlap of the pieces. Make the heuristic be the total overlap of all the pieces (this should be admissible.) Let the A* search proceed by shifting around the pieces. A goal state would be a state where there is no overlap. Each goal state can have an evaluation function (how much wasted material there is) and if its too high the search could continue. – ldog Sep 11 '09 at 17:23
  • I'm not saying either of these options would produce perfect results everytime, but neither will any integer linear problem solver. These are just ideas off the top of my head, if you sat down and thought harder you may come up with some of your own. – ldog Sep 11 '09 at 17:26
  • @gmatt I suppose my question was because you give the obvious answer (linear programming), and then proceed to give very strange suggestions. And while creative solutions are often quite nice, often it is best to do what is established, as they think hardest of all. :) e.g., your NN will almost certainly require cyclic neurons, which are basically impossible to work with except via prayer, and your A* will easily run forever if you're too "greedy". I really hope I didn't come off as rude last time, its hard to write tersely *and* politely. No worries. – agorenst Sep 14 '09 at 03:26

4 Answers4

5

Your problem is quite common problem in Operations Research. Look at Cutting stock problem. This problem is essentially NP-hard as you have figured out on your own. It doesn't scale very well.

How to solve it ? After you are able to figure out the model it would be best to call some mixed integer programming solver. I have previously used LPSolve 5.5

There may be simplier algorithms that you could code that deal with this problem in particular. The problem with these algorithms usually arises when you need to add some side constraints that the authors haven't thought of. The MIP Solver is way more generic tool.

Tomas Pajonk
  • 5,132
  • 8
  • 41
  • 51
4

This is called the variable size bin packing problem. It's NP hard, which means that your solution will invariably fail for large input. This article, here, which unfortunately I don't have access too, addresses this problem and uses the metal cutting industry as an example.

user44242
  • 1,168
  • 7
  • 20
  • 1
    The solution will fail to be optimal with large enough input (and, since we're talking NP-hard, "large enough" can be surprisingly small), but it still may be considerably better than guessing. Bar stock can be a major expense for a shop, and any significant reduction in waste can be useful. – David Thornley Sep 10 '09 at 15:50
1

Linear programming is your friend. See http://en.wikipedia.org/wiki/Linear_programming in general, and, particulary, http://en.wikipedia.org/wiki/Linear_programming#Uses, http://en.wikipedia.org/wiki/Linear_programming#Algorithms.

Victor Sorokin
  • 11,878
  • 2
  • 35
  • 51
1

Looks like it's similar to the knapsack problem (know to be really nasty) I found this on the NIST DADS (handy reference) easier to get to than ACM for non members Bin Packing

CodePartizan
  • 318
  • 3
  • 7