Cutting Optimizer (1 Viewer)

kip

Registered User.
Local time
Yesterday, 18:24
Joined
Mar 19, 2012
Messages
21
I have database that will spit out frame sizes for cutting. We then manually enter this information into another software tool that will optimize the cut order to minimize the number of 14 foot boards used.

It would be beneficial to do the optimizing in the database and eliminate the extra data entry thus reducing the possibility for error.

I'm sure that this code has been written but I'm having no luck finding it.

Does anyone know of a place where I might find some code examples like this?

Am I using the right search criteria? - Cutting Optimizer
 

nhorton79

Registered User.
Local time
Today, 13:24
Joined
Aug 17, 2015
Messages
147
The keyword you might be looking for is “nesting”. Don’t know how to do this using vba but that keyword might help


Sent from my iPhone using Tapatalk
 

Minty

AWF VIP
Local time
Today, 02:24
Joined
Jul 26, 2013
Messages
10,371
If you know the formulas used then they can almost certainly be incorporated into a function within Access, however I suspect they are quote complex. So probably not a trivial task.

Can you show some examples of the data you put in and the returned results, with an explanation of how the result was obtained ?
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 21:24
Joined
Jan 23, 2006
Messages
15,379
search google using algorithm to optimize cutting wood
 

kip

Registered User.
Local time
Yesterday, 18:24
Joined
Mar 19, 2012
Messages
21
Minty,

The input is:

Piece
Size Q'ty
18 5
19 4
24 17
25 2
27 6
29 2
33 2
34 3
41 2
43 1
54 7

Output is:

Mult Stock Offcut Pieces to cut out

2 188 4 27 24 24 24 24 24 18 18
2 188 4.25 41 34 33 29 27 19
1 188 4.25 54 43 24 24 19 19
2 188 4.375 54 54 27 24 24
1 188 5.375 54 54 25 25 24
1 188 135.75 34 18

To the best of my knowledge there is no formula. Programs run through all possibilities and pick the result that is most desirable.

Thanks
 

mcescher

Busy as usual
Local time
Yesterday, 20:24
Joined
Mar 19, 2018
Messages
28
I was mistaken on my note about that library.

Should be 1D and 2D, setting up beam material and how to cut that, and also flat sheet material.

Note, it even allows you to set the saw kerf and uses that in the calculation.
 

Minty

AWF VIP
Local time
Today, 02:24
Joined
Jul 26, 2013
Messages
10,371
Okay - then that is a pretty complex process.

I think the link provided by mcescher might be of use if you wanted to port this over, but as he said there is a price.

It's not necessarily the maths involved in working out what's required, but the algorithm to make it pick the best fit that is going to be complicated.

If you employed someone to do this (Unless they have done it already) it would be a least a days work (probably more with incorporating it into your existing system) , costing way more than a single licence for the code already available.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 20:24
Joined
Feb 28, 2001
Messages
27,179
To the best of my knowledge there is no formula. Programs run through all possibilities and pick the result that is most desirable.

Actually, that IS more or less the formula - basically, an iterative operation. A variant of some queueing theory math is part of it, though it has been over 30 years since I saw anything like that. Like, 30 years and at least two distinct jobs ago, even before my D.o.D. contractor career.

In general, your algorithm will put in the longest pieces first and then will continue to place smaller and smaller pieces to fill in the gaps. However, the product we used at the time was proprietary and the only reason I know that much about it is from reading the product documentation overview. I can't even tell you the name of the company it has been so long. But in any case, I'm sure you can find some online guidance. If something was around 30 years ago, there will be more available now.
 

nhorton79

Registered User.
Local time
Today, 13:24
Joined
Aug 17, 2015
Messages
147
We use a piece of software /plugin called eCut for CorelDRAW which does nesting based on the shapes selected in the file.

It is written in VBA, as CorelDRAW has this available in the background just like Word,Excel,Access etc

This is however a paid license but only 60 euros


Sent from my iPhone using Tapatalk
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:24
Joined
May 21, 2018
Messages
8,527
I cannot post links because I am a new member. So have to provide the google


Not sure if still interested in this problem. I discuss it in detail in another forum, but will have to figure out how to send you the link.

I provide a lot of potential solutions and links to tools to do this. Some of those links are dead. There are solutions to this problem and they do not require, as people have said, an exhaustive search. This is a traditional problem in linear optimization known as a "Cutting Stock" problem. I believe it is 1D (cutting sheets) versus 2d (cutting patterns) It is in the family of integer linear programming.

This is an LP (Linear programming) problem with the complication that the number of different ways to cut each stock piece grows exponentially with the number of lengths required and may get too large for traditional LP techniques. The different lengths required are rows of the solution matrix and the unique cutting patterns are the columns. The intersections of the input matrix contain the number of that length (row) which can be cut from that pattern (column). Since there may be hundreds (or thousands or millions) of columns, they cannot all be generated. The solution uses a technique called "Delayed Column Generation". Here we generate enough columns to define a solution, usually not the optimal one. Specifically, for each part length, cut as many as possible of that length from the longest available stock piece) until enough parts have been cut.. That solution is used as input to the second part of the algorithm, a "Knapsack" algorithm, which searches for an unused pattern that improves the solution, i.e. reduces the total cost. Since the Knapsack algorithm maximizes the value of goods that can be collected in a knapsack of a given size, the trick here is use the "dual variables" of the LP problem to maximize the amount of material cut per unit cost. This process continues, swapping in each pattern which lowers the cost until no such pattern is found.

Definitely take a look at this program for doing cutting stock. Not sure what you are using.
(google Delphi Cutting Stock)

The source code is provided, but that would be a some serious work. I do not know of an easy add-in for vba/vb. In the thread I posted I was able to export to Excel and run the solver optimization. I aslo built a heuristic due to the simplicity of the problem. So in your problem what changes? Is the stock always 14 ft? Is the input changing? Also can you explain your output? I think there is some formatting and do not understand the 2, 188, 4

2 188 4 27 24 24 24 24 24 18 18

If still interested would be willing to take a look. You may be able to get by with a Excel solution. Really would need to understand the inputs and outputs and what is variable.
 

kip

Registered User.
Local time
Yesterday, 18:24
Joined
Mar 19, 2012
Messages
21
Yes, MajP, I am still interested. It looks like my column headers were missing from my post showing the output. The first column is quantity, the next is length of starting peice, then leftover, and finally the individual cuts.
 

kip

Registered User.
Local time
Yesterday, 18:24
Joined
Mar 19, 2012
Messages
21
Variables would be start length, blade thickness, starting offcut, minimal ending offcut. And of course all the desired cuts.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:24
Joined
May 21, 2018
Messages
8,527
There is definitely purchasable software which may expose dlls and some free software. Just Google “1D Cutting Stock Software.” If you can go this way, I would strongly recommend it. I will try to look at some of the free stuff and see if I can get something that Access can talk to. If what mcescher suggests works with Access that would be a good option. Adapting existing code into Access will not be trivial and writing something from scratch is not really doable in a cost effective way. Most of these programs solve this problem as a Linear Optimization Program (LP) using a technique called Delayed Column Generating which is solving two different but related LPs iteratively. There are also a lot of open source generic LP solvers, but even formulating the problem is somewhat difficult if you have not done this before.

I will try to explain in general how this is solved and what is involved in rolling your own solution.

The standard formulation for the cutting-stock problem starts with a list of “m” orders (where an order is a different cut size) each order requires q(j) pieces where j = 1 to m. In your example you have m = 11 orders with their corresponding quantities.
Piece
(m) Order Quantity (q)
1 18 5 q(1)
2 19 4
3 24 17
4 25 2
5 27 6
6 29 2
7 33 2
8 34 3
9 41 2
10 43 1
11 54 7 q(11)
In the first step in formalizing the problem you need to first identify all the feasible combinations of cuts (often called "patterns"). That usually requires some kind of spanning tree algorithm. For something small this may be doable, but the number of possible patterns grows exponentially as a function of m, the number of orders. ( As the number of orders increases, it may therefore become impractical to enumerate the possible cutting patterns which lead to another solution called the delayed column generating algorithm). A simple example would be
stock of 10 ft
Order Quantity
2 q(1) 20
3 q(2) 30
4 q(3) 40

This would lead to the feasible patterns of
X1 2 2 2 2 2
X2 2 2 2 3
X3 2 2 3 3
X4 2 2 2 4
X5 2 4 4
X6 3 3 4
X7 3 3 3
So there are “n” = 7 patterns, and in the LP we associate with each pattern a positive integer variable X(i), representing how many times pattern i is used, where i=1…n.
Now you need to know “A(i,j)” where A(i,j) is the number of cut size (orders) “j” in pattern “i”
From there you can build a linear integer program. This consists of an objective function (minimize or maximize) and a series of constraints. (This could be shown with summations, but too hard to type)
Objective: Minimize the number of cuts
Min X(1) + X(2) + X(3) + … + X(7) ( where X1 is the number of pattern 1, X2 number of pattern 2, etc)
Subject To
A(1,1)X1 + A(1,2)X2 + A(1,3)X3 … >= q(1)
….
A(3,1)X1 + A(3,2)X2 + A(3,3)X3 … >= q(3)
In other words the constraints say that the sum of the number of a given piece within each pattern is greater than or equal to the number of that piece required. So just writing the code to formulate the problem would not be that trivial. I would imagine you would have several hundred to thousands of feasible patterns for your example.
In general to solve an LP you convert those constraints and the objective function (plus some other columns) and put them into a matrix (called a tableau). The Simplex method uses interations of matrix pivots and then comparing that to the objective function to determine the next matrix pivot. So if your coding you need to code a lot of matrix math and matrix operations. Again not trivial.
Now in truth most Cutting Stock solvers do not do that. The reason as said, the number of feasible patterns may be too expensive to iterate. A solution known as a Delayed Column Generating algorithm is used. Instead of iterating all the patterns it starts with a few set of patterns. But after you do your iterations you solve another LP (it is called the dual and it is like a transpose of your original problem). This alternate problem is known as the knapsack problem, using dual variable information from your original linear program. That problem then gives the new pattern (column) to add to the original. Coding that would require formulating the second LP based on the original LP. And then you are not quite done, because this gives a non-integer solution requiring you to code a branch and bound algorithm as well.

Unlikely you could do this in excel because the number of variables (patterns) will likely exceed the built in solver capability. However, there is an open source called OpenSolver that can handle much bigger problems. I plan to take a look at that.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:24
Joined
May 21, 2018
Messages
8,527
For some reason I cannot format the above post from this machine. I will fix from another so it is more readable.
 

Users who are viewing this thread

Top Bottom