How many rods to purchase?

74 Views Asked by At

Available rods lengths in the shop = 144 inches and 180 inches.

Question: How many rods do I need to purchase if my requirement is as below?

70 inches each -> 3 rods

45 inches each -> 2 rods

The choice of length of the rod to purchase could be either 144 or 180 inches and they both are of the same price per inch/foot. The goal is the make less wastage possible.

With Brute force, I came up with this. (Note: I have simplified the question for lesser requirements) enter image description here

2

There are 2 best solutions below

3
On BEST ANSWER

This is the multiple length cutting stock problem. Via integer linear programming, I confirmed optimality of all but the last of your solutions. The last one can actually be satisfied with 0 waste by taking 6 of the 144" rods, each covering 3 of the 34" and 2 of the 21" demands.

0
On

Brute force. Below is every sensible possibility

A) How much pipe do we need? $3\times 70 + 2\times 45 = 300$.

B) How many ways are there to get $300$ inches of pipes (regardless if we can saw them to the length we want) from all long to all short.

  1. $2\times 180 = 360; 60$ wastage
  2. $180 + 144 = 324; 24$ wastage
  3. $2\times 144 =288$ failure
  4. $3\times 144 = 432; 132$ wastage

If possible we want to do $2$ as that is the least wastage if the cuts are possible.

C) Is it possible cut these ways. Big to small.

2--- we have $180$ and $144$. Try to get as many of the $70$ from the $180$ if possible.

$70+70=140;40$ left over. That's $40$ that can't be used by either $70$ or $45$ so that's $40$ inches of wastage when we only had $24$ to spare. Can't do it this way.

So we can do it at all we must take at least $2$ of the $70$ from the $144$. That gives us $70+70=140; 4$ left over. That's $4$ inches of wastage from rod and all the rest (one $70$ and the two $45$) must come from the $180$ pipe. As $70 + 2\times 45 = 160$ we have the expected $20$ inches of wastage.

Now we must take at least two of the $70$ from the $144$ and we can't take anything else from the $144$ so the is the only way to do option $2$.

So we know this is the best option and we don't have to look any further.

....

but lets do it for practice.

1--- we have two $180$. Try to be as many of the $70$s from one of the $180$. $2\times 70 = 140$ and that leaves $40$ for that pipe that is good for nothing. So we can't have all three $70$ from one the $180$ so we must at least one of the $70$ from one pipe. That means each rod must have at least one $70$. That means one rod with have one $70$ and the other will have two $70$s. That we leave $40$ wastage from one rod, and we will have $110$ from the other. That's enough for $2\times 45$ with $20$ wastage.

So we can do $70+70$ with $40$ wastage from one pipe and $70+2\times 45$ with $20$ wastage on the other. That is the only way to do option 1.

3--- we have $3$ $144$ pipes.

They are all the same rod so we must take a $70$ from one of them. We can only take a maximum of two $70$s from one of them so we must take $70$ from two of them. That will leave us with two $74$ inch remaining rods and one untouched $144$ rod, for the remaining $70$ inches and the two $45$.

We can a) take the remaining $70$ from one of the two $74$ rods, or b) take the remaining $70$ from the $144$ rod.

If we do a) we will have $4$ inches of wastage of one rod, one $74$ inch rod, and an untouched $144$ to get two $45s$. we can't get both $45$ from the $74$ inch rod so we must get one $45$ from the $144$ and have a $99$ inch rod remaining.

So we a $74$ inch rod, and a $99$ inch rod to get one remaining $45$ inch cut. We can take it from either pipe.

If we do b) we have three $74$ inch rods for two $45$ inch cuts. We have to take them from two different rods.

So there are three different ways to do 4----

4a) From 1 $144$ pipe take $2\times 70$. From a second $144$ pipe take $70$ and $45$. and take $45$ from the third.

4b) From 1 $144$ pipe take $2\times 70$. From the second take $70$ and from the third take $2\times 45$.

4c) From two of them take $70 + 45$ and from the third take $45$.

But all of those are the least efficient and have $132$ nearly an entire rod of wastage.