Cutting Stock Lengths

Here’s a program I wrote some time ago to determine how much stock (such as lumber) of a particular length you would need to get a certain number of cut stock. It sorts the cuts from longest to shortest and uses up the stock in that order. That may not be the most efficient use of stock, but I can’t think of a better way.

excel range and message box showing cut stock

I should really put the output on a sheet instead of a message box so it could be printed. I started to do something similar for square feet instead of linear feet (like plywood instead of 2×4s), but it was way too hard. You can download BoardFeet.zip.

22 thoughts on “Cutting Stock Lengths

  1. Dick, this could be very useful, but what about the amount of wood you lose with each cut? Needs to have a place to put how wide the saw blade is to account for this in each cut you make on a board. As you said it would be better to have the results put on a sheet and maybe even the “waste” that is left in each board, just a thought

  2. The width of a saw blade? What are you making, Scandinavian furniture? It might be good to have a generic waste factor in there. The user could enter either a percentage or a hard measurement and that could be added to each cut, or rather subtracted from the remaining stock after each cut.
    I thought about tracking the waste, but never got around to doing it.

  3. No am not making Scandinavian furniture but with a 1/8? saw blade and if you have 36? stock and want three 12? boards you would end up with two 12? and one 11 3/4?. If you are making anything, except maybe “rough” framing a house that is a big deal. And of course the longer the stock and the more cuts you make or a wider saw blade, this becomes more of a problem.

  4. Back in my University days our Operational Research Mathematics class (Dr Lynn was our lecturer if I remember correctly) was set the task of using linear programming and/or trim loss theory to work out how to minimise waste for a carpet manufacturer.

    Obviously they sold rolls of carpet in various lengths and widths but cut from one roll.

    I did come up with a neat solution in Algol but have never had the need to use it again (or translate it into any other language).

    Professor George B. Dantzig invented the the “simplex method” and “linear programming” whilst at Stanford, so if you need more information look it up on the web!

    Alternatively, email me and I might be able to find the Algol program!!!

  5. Hi Simon. I would be interested in your Algol solution. I happen to like OR when I was in school and am curious to see your solution. I hope you can find it and share it. Thanks for your time.

    CA

  6. Hello, first time here. Dick Kusleika – I work in the steel fabrication industry and could use your stock cutting VBA to some degree. What I would like to know is would it take much to have it tell me which pieces of which length to cut from each stock length. i.e., 2 pieces 18′ 6? long to cut from a 40′ 0? stock length piece. I would be dealing with hundreds of pieces of varying lengths from 1′ 0? to 58′ 0? being cut from 20′ 0?, 40′ 0? and 60′ 0? (various quantities of each) stock lengths as well as several random stock lengths left over from previous jobs.

    Thank you, Ed

  7. Hello, first time here. Dick Kusleika – I work in framing industry and am very happy to find your cutting stock length program. Would you consider adding a few modifications to better fit my needs? I would be grateful and more than happy to pay you for your time.

  8. Looks like we all like this example and all of us want something more.

    :)

    Thanx anyway for this….

  9. Very Useful. I’m curious if it would be easy to insert a 3rd row in addition to quantities and sizes that shows where the specific cut is to be installed. I.E. the first cut would have 4 cuts for window 1 and 3 for window 2…

  10. Hello Dick Kusleika,

    I am 16 year and as student that love VBA i follow all your steps… and see you as my master.
    I am for years very interesting in the Cutting Stock problem and find yours one of the best i ever saw!
    But i could never figure out how to make it working by more stock with different lengths.
    If one day you got little time… can you please show it?

    Thank you to read this and for your hard work!

    Christina

  11. Hi there,
    I was wondering if you have a functioning copy of this you could send through, the zip download is no longer working. I would love to see the construction of the excel file.
    Cheers.

  12. That takes me back many years to a time when I was working with a mainframe Linear Programming system (MPSX) with mixed inter options (solving problems for Roger Govier amongst others!). The optimisation of cut stock can be formulated as an Integer programming problem.
    See https://en.wikipedia.org/wiki/Cutting_stock_problem
    You could probably find the optimum solution using Solver

    There seems to be at least one Excel addin that targets the problem:
    http://www.optimalon.com/length_cutting_excel.htm

  13. Hola, segun veo este metodo no funciona para unos cortes de 1 de 4000,1 de 3000, 2 de 1500 y 2 de 1000 . largo de barra 6000.

    Si tienes la solucion a tal fin agradeceria que me la pases.

  14. Funciono para mi ¿Qué error estás viendo? (It worked for me. What error are you seeing?)

  15. Sí, ya veo. El algoritmo de optimización no es muy bueno. Siempre lleva el corte más grande que se ajuste.

  16. I made a new macro that solves this particular problem. But there are a few caveats. It’s not very well tested, so don’t use it in production. I didn’t do a lot of the error checking that it’s in the original. And it tests every possible combination so it will be really slow if you have more than a few cuts.

    Hice una nueva macro que resuelve este problema en particular. Pero hay algunas advertencias. No está muy bien probado, así que no lo uses en producción. No cometí muchos errores al comprobar que está en el original. Y prueba todas las combinaciones posibles, por lo que será muy lento si tiene más de unos pocos cortes.

    BoardFeetBestFit.zip

  17. La verdad que te pasaste Dick Kusleika , esta muy bien…. Te consulto es posible hacer algo que en verdad tome muchos cortes y optimicen en un stock con medidas dinámicas? He estado buscando mucho este tema y parece que es algo muy complejo de realizar,por lo que me gustaría se es posible que me des una mano.
    Desde ya muchísimas gracias y un abrazo enorme.


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published. Required fields are marked *