7
$\begingroup$

How many $a \times b$ rectangular pieces of cardboard can be cut from $m \times n$ rectangular piece of cardboard so that the amount of waste("left over" cardboard) is a minimum?

This question was given to me by my Mathematics Teacher as a "brain teaser".

At first I divided $m \times n$ by $a \times b,$ but then I realized that it is not possible in the given situation, as the "left over" cardboard will also be "divided" among $a \times b$.

Next I tried started thinking it terms of perimeter. I imagined all the $a \times b$ rectangles lying side by side in a "rows and columns" format(sort of a grid), without any space between them, thus forming another rectangle/square. I assumed $\lambda$ rows and $\sigma$ columns of those smaller rectangles. After a bit of calculations, my answer came out as following :

Number of smaller $a \times b $ rectangles $\geq \sigma \times \lambda$ = $\left(\dfrac {m - m \, mod \, a }{a}\right) \times \left(\dfrac {n-n\, mod \, b}{b}\right).$

Is my "second" approach correct ?

Is there any alternate way of tackling this problem?

This might seem a 'vague' question, but can this problem be generalized to any given shape ?

Any help will be gratefully acknowledged :).

  • 0
    Related: http://math.stackexchange.com/questions/988934/optimal-box-in-a-box-in-a-boxing2017-01-28
  • 0
    @SimplyBeautifulArt That does not seem to help a lot ... one answer says Without Loss Of generality assume boxes to be distinct.... By the way is my approach correct ???2017-01-28
  • 0
    I don't believe there is any known way to calculate this with a direct formula, and BeaitifulArt's link seems to agree.2017-01-28
  • 0
    @Kaynex Is my approach OK ???2017-01-28
  • 1
    You've asked twice if your approach is "OK". I'd say it's a good start, but it leaves a lot of cases untested. You might imagine a situation where you lay a row of $a\times b$ rectangles length-wise, but then another row turned 90 degrees. Maybe $3a + 5b = m$, so by laying 3 rows one way and 5 rows the other way, you end up with no waste in the $m$ direction. The point is that there are infinity minus one things to think about here.2017-01-28
  • 0
    As to the side question: It may be generalised. "How many circles of radius $r$ fit inside a larger circle of radius $R$?", "How many regular with side length $l$ fit inside a larger regular with side length $L$?", and so on. See [Packing problems, at en.wikipedia.org](https://en.wikipedia.org/wiki/Packing_problems)2017-01-28
  • 0
    @B.Goddard The problem asks for minimum waste .... So there must be some specific strategy to tackle this question. As far as I think, my approach gives the left-over area in such a way that it can not be further divided into the smaller $a \times b$ rectangles ....2017-01-29
  • 0
    @Nirbhay I explained why your approach fails. It can't even distinguish between whether $a\times b$ is better than $b\times a$. Suppose the large rectangle is $9\times 9$ and the small one is $3\times 2$. Your method would lay $4$ rows of $3\times 2$'s leaving waste of $9$ square units. I can beat that by laying $3$ rows of $3\times 2$'s and then one row of $2\times 3$'s leaving only $3$ square units of waste.2017-01-29
  • 0
    @B.Goddard Any ideas then ???2017-01-29
  • 0
    @Nirbhay Lots. Maybe Bezout's theorem will help.2017-01-29
  • 0
    @B.Goddard If instead my question was to find/know/whatever the maximum $number$ of smaller rectangles, then would my approach be correct.. Also, besides Bezout's theorem, is there any elementary or pre-college technique/rule/theorem ... that can help ????2017-01-29
  • 0
    @Nirbhay No, my example above still beats your method.2017-01-29
  • 0
    @Nirbhay There probably is a general method, but it will involve lots of cases, depending on $a \mod m$, $a \mod n$, $b \mod m$ and $b \mod n$. You might google "tiling problems".2017-01-29
  • 0
    It is called [Cutting stock problem](https://en.wikipedia.org/wiki/Cutting_stock_problem), in your case 2D with single pattern. Corresponding ILP problem is NP-hard as it seems, approximate knapsack could help.2017-02-03
  • 0
    @sas Can you suggest an answer for this problem. I you know the answer, then please post it as the answer ....2017-02-03

2 Answers 2

2

The approach proposed in the OP may be good, as it gives a waste $W $ of

$$W=(m \mod{a}) \cdot n + (n \mod { b}) \cdot m - (m \mod { a} ) ( n \mod {b}) $$

that in most cases is distributed along two adjacent sides. For example, let us take a $120\times 100$ rectangle to be filled with $11\times 7$ rectangles. Using the approach of the OP, the waste is

$$W=(120 \mod 11) \cdot 100 + (100 \mod 7) \cdot 120 - ( 120 \mod 11 )\cdot ( 100 \mod 7) \\ =10 \cdot 100 + 2 \cdot 120 - 10 \cdot 2=320$$

However, I believe that there could be a potentially better strategy. We could assess whether one between $m $ and $n $ can be expressed as $ax+by $, where $x$ and $y $ are integers. If this is the case, we can leave an incomplete region only along a single side of the large rectangle (instead of two). For instance, in the example above, we can note that $120$ can be expressed as $$120=99+21=9 \cdot 11 +3\cdot 7 \,\,\,\,$$ So, dividing the sides equal to $120$ in two parts measuring $99$ and $21$, we can divide the initial rectangle in two rectangles ( $99 \times 100$ and $21 \cdot 100$). The first one can be filled beginning from the side equal to $99$, placing a first sequence of $9$ small rectangles (oriented as $11 \cdot 7$) to cover a $99 \times 7 $ area, then another sequence to achieve a $99 \times 14 $ area, and so on, arriving to a $99 \times 98$ area. This leaves a partial waste of $2 \cdot 99=198$. The second one can be filled beginning from the side equal to $21$, placing a first sequence of $3$ small rectangles (oriented as $7 \cdot 11$) to cover a $21 \times 11$ area, then another sequence to achieve a $21 \times 22 $ area, and so on, arriving to a $21 \times 99 $ area. This leaves a partial waste of $1 \cdot 21=21$. The total waste is $198+21=219$. Generalizing, if we can set $m=ax+by $, the waste with this approach is $$W=ax \cdot (n \mod b) + by \cdot (n \mod a) $$

There are several points to be highligted in this solution. First, this approach should be attempted by considering all possibilities of expressing $m $ or $n $ as $ax+by $, and choosing the one that minimizes the waste. In the example used before, other two possibilities could be to set $$m=120=2 \cdot 11 + 14 \cdot 7\,\,$$ or $$n=100=4 \cdot 11 + 8 \cdot 7\,\, $$ Using the same procedure, it can be easily shown that these choices lead to wastes of $142$ and $604$, respectively. Among all three possibilities, that leaving $142$ gives the best solution. Second, even if this approach allows a nearly full packing along three sides, it does not always produce a minor waste than the solution suggested in the OP. The case $W=604$ described above is an example of this. Also note that the solution of the OP could be applied after rotating the initial rectangle by $90^o $ to get

$$W=(100 \mod 11) \cdot 120 + (120 \mod 7) \cdot 100 - ( 100 \mod 11 )\cdot ( 120 \mod 7) \\ =1 \cdot 120 + 1 \cdot 100 - 1 \cdot 10=210$$

which is a better result than that initially obtained. Lastly, note that a "complete" packing (with no waste) can be obtained only in two scenarios, that is to say 1) $a $ divides $m $ and $b $ divides $n $ (or alternatively $a $ divides $n$ and $b $ divides $m $), 2) both $a $ and $b $ divide one (the same) of $m $ and $n $, for example $m $, and the other (in this example $n $) is of the form $n=ax+by \,\,\,$ with $x,y$ integers.

2

Part_Rett

A simple example, for $a=2, b=3$, and a few values for $n$ and $m$ shows that the problem is not easily approachable, specially in the last configuration.

--- added-----

It is in fact a Cutting Stock Problem as rightly indicated by @sas, however simplified by having rectangular and fixed size items.
It is quite an interesting subject, so starting from the sketch above, let's try and establish some facts about,
without pretending to be rigourous and to provide proofs.
Premised that we use the following symbols, for the integral and fractional part and for modulus $$ \begin{gathered} x = \left\lfloor x \right\rfloor + \left\{ x \right\} \hfill \\ \frac{x} {t} = \left\lfloor {\frac{x} {t}} \right\rfloor + \left\{ {\frac{x} {t}} \right\} \hfill \\ x = t\left\lfloor {\frac{x} {t}} \right\rfloor + t\left\{ {\frac{x} {t}} \right\} = t\left\lfloor {\frac{x} {t}} \right\rfloor + x\bmod t \hfill \\ \end{gathered} $$ then

  1. Upper bound for $N$
    Clearly we must have $N a b \leqslant nm$, i.e. $$ \bbox[lightyellow]{ N \leqslant \left\lfloor {\frac{{n\,m}} {{a\,b}}} \right\rfloor = \left\lfloor {\,\frac{{n\,m/\gcd (nm,ab)}} {{a\,b/\gcd (nm,ab)}}} \right\rfloor = \left\lfloor {\frac{{n'\,}} {{a'}}\,\frac{{m'}} {{b'}}} \right\rfloor \tag {1} \\ } $$ This also indicates an equivalence in the problem when the parameters are scaled so as to keep the ratio $(nm)/(ab)$ constant, and that we can always reduce the parameters and get $n$ and $m$ be coprime vs. $a$ and vs. $b$.
    But, geometrically speaking, the down-scaling looks to be applicable only if $max(a',b') \leqslant min(n',m')$.
    An example is given in this sketch
    Part_Rett_3
  2. Equivalence under rotation, reflection
    Clearly the problem does not change under rotation or reflection.
  3. "Cross histogram"
    Consider to take a horizontal scan and to record, per each unit row, the number of layers of horizontal dimension $a$ and $b$ traversed. Let's do the same on a vertical scan. Part_Rett_2r
    Clearly, every $b$ counts for a layer of width $a$ in one direction will correspond to $a$ counts for $b$ in the other direction. And viceversa.
  4. Conclusions
    Condensing all the considerations above we are led to claim the following:
    a) Among the various possible partitions of $m$ and $n$ (in case $n'$, $m'$) as a linear combination of $a$ and $b$, with non-negative integral coefficients, as $$ \bbox[lightyellow] { \left\{ \begin{gathered} n = n_{\,a} a + n_{\,b} b + n_{\,r} \hfill \\ m = m_{\,a} a + m_{\,b} b + m_{\,r} \hfill \\ \end{gathered} \right. \tag {2} }$$ we shall choose those which, while giving minimal remainder ($n_r,m_r$), also assure best symmetry around $n/2$,$m/2$, that is $$ \bbox[lightyellow] { \left\{ \begin{gathered} n_{\,a} a \approx n/2 \approx n_{\,b} b \hfill \\ m_{\,a} a \approx m/2 \approx m_{\,b} b \hfill \\ \end{gathered} \right. \tag {3} }$$
    b) Note that the above goal of symmetry is to be achieved globally on $n$ and $m$, so that it happens that we shall compromise somehow on one of the parameters, to keep the best on the other. When that happens, for the unbalanced parameter we are asked to choose two partions on the opposite sides of the symmetry, so that they make an optimal one on average, in case inserting a remainder if necessary (re. to the case $n=4,m=5$ in the first sketch). So, practically, we are determining a pair of partitions for each parameter.
    c) The above situation can be faced when $n,m$ are relatively small with respect to $a,b$. When they are much larger than $a,b$ then a partion (or two on average) close to symmetry can be found for both.

Therefrom a possible strategy seems to be as follows (you can follow the process on one of the sketches given)

  • repart one side of the rectangle (e.g. $m$) according to one of its pair of partitions, putting first all the $a$'s, then the remainder, then the $b$'s;
  • following the perimeter, repart the contiguous side ($n$), this time starting with the $b$'s;
  • pass to next side ($m$), and apply the remaining partition of the pair associated with $m$;
  • same for the last side;
  • expand the partition of the perimeter towards the inner part, as allowed

From the examples, it looks that it is possible to reach $N= \left\lfloor {\frac{{n\,m}}{{a\,b}}} \right\rfloor$ in "many" cases.

  • 0
    @G Cab Which software did you use ???? Do you have any idea how to solve the problem ???2017-02-02
  • 0
    @Nirbhay I did the sketch by hand, trying to validate a possible approach, which unfortunately does not work for particular values of $m$ and $n$ as shown. However it provides upper and lower bounds: I will add it to my answer, as it might interest you anyway.2017-02-02
  • 0
    How can you possibly "sketch" that "by hand" ????2017-02-02
  • 0
    @Nirbhay: by hand on a spreadsheet2017-02-02
  • 1
    How many $2\times 2$ squares can you fit into a $3\times 3$ square? Certainly no more than $1$, despite the fact that $\lfloor(9/4)\rfloor=2$.2017-02-08
  • 0
    @mjqxxxx: you are right, thanks for signalling. In this case we cannot reach $\lfloor(9/4)\rfloor=2$. However the process of construction by partition of the perimeter remains valid. I will amend my answer.2017-02-08
  • 0
    You may have assumed that all rectangles are arranged at right angles to each other; which is not a stipulation of the question. There will be cases when a diagonally placed rectangle must be part of the solution.2017-02-09
  • 0
    @RobertFrost: yours is an interesting objection, in fact I did not consider placements other than vert./horiz. . Please indicate an example of a diagonal placement obtaining better results.2017-02-09
  • 0
    @Nirbhay: thanks for assigning the bounty, although I realize that my answer does not satisfy fully your requirements.2017-02-09
  • 0
    @GCab No probs.... ^_^2017-02-09
  • 0
    @GCab I don't have long but... I can imagine a long thin rectangle too long to fit in vertically, but can do so if turned at 45 degrees2017-02-09
  • 1
    @RobertFrost: yes, that's the case if we admit that $a$ or $b$ can be larger than $n,m$: that opens a quite different scenario.2017-02-09