# Setting up a linear programming word problem

Problem: A metalworking shop needs to cut at least 32 large disks and 219 small ones. There are three cutting patterns for the standard size metal rectangle. One cutting pattern produces two large disks with 14% waste. A second cutting pattern produces five small disks with 29% waste. The third cutting pattern produces one large and three small disks with 24% waste. What is the minimum waste way to make the required disks?

Having trouble setting up the objective function and constraints. The percentage makes me think that I cannot use large disks and small disks as my x1,x2.


$$.14 p_1 + .29 p_2 + .24 p_3 = W$$

Minimize $W$. Upper bounds can be inferred: $p_1 < 17$, $p_2 \le \floor{\frac {219}{5} }$ so $p_2 < 44$, and $p_3 \le {\rm Min}\paren{\floor{ \frac {32}{1} }, \floor{ \frac {219}{3} }}$ so $p_3 \le 32$.

An approach that doesn't use programming is to write $W$ in terms of $p_3$.

$$\ceil{ \frac{32 - p_3}{2} } = p_1$$ $$\ceil{ \frac{219 - 3p_3}{5} } = p_2$$ $$W = .14 \ceil {\frac{32 - p_3}{2} } + .29 \ceil{ \frac{219 - 3p_3}{5}\ } + .24 p_3$$

Now using $\ceil {a/b } = \floor{ (a - 1)/b } + 1$ and $\floor{ a/b } b + a ~{\rm mod}~ b = a$:

$$W = .14 \floor{ \frac{31 - p_3}{2} } + .29 \floor{ \frac{218 - 3p_3}{5} } + .24 p_3 + 0.43$$

$$W = 15.244 - 0.07\bparen{(31 - p_3)~{\rm mod}~ 2} - 0.058\bparen{(218 - 3p_3) ~{\rm mod}~ 5} - 0.004 p_3$$

$$W = \label{14.942 - 0.004 p_3}{x} + \label{0.07\bparen{p_3~{\rm mod}~ 2} + 0.058\bparen{(3p_3 + 1) ~{\rm mod}~ 5}}{y}$$ (In the last line using $a ~{\rm mod}~ b = b - 1 - \bparen{(b - 1 - a) ~{\rm mod}~ b}$)

From expression $x$ minimizing $W$ means maximizing $p_3$ under $p_3 \le 32$, and expression $y$ suggests that want $p_3 \equiv 0 \pmod 2$ and $3p_3 + 1 \equiv 0 \pmod 5$, which is $p_3 = 3 + 5k$. The largest value which meets these requirements is $p_3 = 28$, giving the optimal value:

$$\begin{cases} p_1 = 2 \\ p_2 = 27 \\ p_3 = 28 \\ W = 14.83 \end{cases}$$

The thing you have direct control over is:
number of pattern 1s, number of pattern 2s, number of pattern 3s.
I think they should be your $x1,$ $x2$, $x3$

• I attempted that to begin with...went back to it after some thought and was able to fully set up the problem. Thank you! – BlueJello27 Mar 2 '15 at 23:51