Logic question

Recommended Posts

Hey guys,

I need some help with developing an approach to a problem. I've got a buddy that works in a welding shop. He often needs to determine the right amount of stock to order for given project. The issue usually goes something like this:

This particular project requires:

15 ea 6 foot length

30 ea 3 foot lengths

10 ea 11 foot lengths

All those lengths are of the same materiel

For this example, the materiel comes from the supplier in 20 foot segments, and lets say that we are not allowed to weld smaller pieces together to make any of those parts.

So, I would like to devise a script that will accept assorted piece requirements and have it return a breakdown of how many full length pieces need to be ordered, and how to break down the cuts.

I'm thinking I would need to sort the required lengths then from largest to smallest, then starting at the top, see if I can fit another of the pieces in and if not, try to fit one of the next smaller... etc.

So using my example:

a ) 15x6

b ) 30x3

c ) 10x11

would sort to

c ) 10x11

a ) 15x6

b ) 30x3

Then the output would be

cab

cab

cab

cab

cab

cab

cab

cab

cab

cab

aaa

aabb

bbbbbbbb

bbbbbbbb

bb

Total of 15 pieces ordered

Is there a more efficient method or formula to use?

Edited by SpookMeister

Share on other sites

I think your approach is a great start. there would be 5 - 2' pieces left over. However, there may be times that the smaller piece may cut equally into the 20' stock and the longest and second longest may need to cut from the same 20' stock to get the least waste.

good luck

8)

Edited by Valuater

Share on other sites

Hey guys,

I need some help with developing an approach to a problem. I've got a buddy that works in a welding shop. He often needs to determine the right amount of stock to order for given project. The issue usually goes something like this:

This particular project requires:

15 ea 6 foot length

30 ea 3 foot lengths

10 ea 11 foot lengths

All those lengths are of the same materiel

For this example, the materiel comes from the supplier in 20 foot segments, and lets say that we are not allowed to weld smaller pieces together to make any of those parts.

So, I would like to devise a script that will accept assorted piece requirements and have it return a breakdown of how many full length pieces need to be ordered, and how to break down the cuts.

I'm thinking I would need to sort the required lengths then from largest to smallest, then starting at the top, see if I can fit another of the pieces in and if not, try to fit one of the next smaller... etc.

So using my example:

a ) 15x6

b ) 30x3

c ) 10x11

would sort to

c ) 10x11

a ) 15x6

b ) 30x3

Then the output would be

cab

cab

cab

cab

cab

cab

cab

cab

cab

cab

aaa

aabb

bbbbbbbb

bbbbbbbb

bb

Total of 15 pieces ordered

Is there a more efficient method or formula to use?

Optimsing can be very difficult. A 1D optimiser is the simplest but it is still quite tricky and can take a long time to develop.

Your results have not allowed for the saw with by the way which will be important. Also an new bar will usually need to have the ends trimed off so there will be some waste.

If you assume a saw width of 0 and no trim from each end then I don't think you will do simpler than

cbbb x 10

aaa X 5

There are various versions available and searching the internet will find some. Most have a free trial period.

One of the best, which you won't find by searching the internet, was written by me (which was used to get my results above)

It has a lot of features, display of how all the bars should be cut, allows any number of stock bar types, up to 20 lengths for each bar type, saw width adjustment, offcut trim required if any for new bars. Has options to print results, option to return unused offcuts to stock and more.

It has an excellent label printing feature and can produce instructions to drive an automatic saw.

If you are interested I can PM you a trial copy which will last for 28 days.

It might give you some ideas. You could also try to get better results than I can. Main problem with it would be that it is written fo metric use so you would need to enter everything in tenths of an inch to get sensible results, or 100th of an inch.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Create an account

Register a new account