# More spoilage

The question of minimizing spoilage still interests me. Today I want to consider the consequences of relaxing one of the constraints on the problem. In particular I do not assume that the two different types of fruit cost the same per unit. And I want to minimize the total amount of wasted money (i.e. the amount of spoiled fruit times the unit cost.)

Definitions:

1. There are two types of fruit $A$ and $B$. The unit costs are $c_A$ and $c_B$ respectively.
2. We can consume $z$ units of fruit per day.
3. The goal is to minimize the cost of the total spoiled fruit.
4. The percent of fruit that spoils at the end of each day is $m_A d$ and $m_B d$ respectively for A and B, where $m_A$, $m_B$ are constants and $d$ is the number of days since buying the fruit (i.e. $d = 0$ for the first day.)

Calculations:
First, note that by minimizing the cost of spoiled fruit at the end of each day the total cost of spoiled fruit is minimized (I should prove this and I might in a future post. I think this comes from the fact that we’re solving a convex optimization problem?).

Given $x$ and $y$ units of fruit for A and B respectively.
We can consume $z_A$ and $z_B$ units of $A$ and $B$ respectively, where $z_A + z_B = z.$

The amount of spoiled fruit at the end of the day is
$m_Ad(x-z_A) + m_Bd(y-z_B),$ the cost of the spoiled fruit is
$m_Ad(x-z_A)c_A+m_Bd(y-z_B)c_B.$

Using $z_B = z - z_A,$ the cost of the spoiled fruit is $m_Ad(x-z_A)c_A+m_Bd(y-z+z_A)c_B.$ Expanding we get

$m_Ac_Adx-m_Ac_Adz_A+m_Bc_Bdy-m_Bc_Bdz+m_Bc_Bdz_A$
which reduces to $= z_A(m_Bc_B - m_Ac_A)d + m_Ac_Adx + m_Bc_Bdy - m_Bc_Bdz.$

Taking the derivative with respect to $z_A$ we obtain $(m_Bc_B - m_Ac_A)d.$
If $m_Bc_B - m_Ac_A$ is greater or equal to zero, then $z_A = 0, z_B = z$ minimizes the cost of spoiled fruit; otherwise $z_A = z, z_B = 0$ minimizes the cost of spoiled fruit.

From the above it’s clear that introducing the factor of fruit cost does not fundamentally alter the solution. But it does introduce some interesting factors, that warrant further consideration.