A factory creates different types of oils and mixes them together. There exists two types of vegetarian oils (veg1,veg2) and three types of non-vegetarian oils (oil1,oil2,oil3), the price of each oil (per ton) is:

veg1=$115$, veg2=$128$, oil1=$132$, oil2=$109$, oil3=$114$.

The final product is a mix of these oils and is sold for $180$ dollars for each ton. The goal is to maximize the profit of the factory, under the following restrictions:

  1. We can't refine more than $210$ tons of vegetarian oil, and more than $260$ tons of non vegetarian oil.
  2. There exists a restrictment on the viscosities (from google translate, hope it makes sense) of the final product, it can't be lower than $3.5$ and not higher than $6.2$. We assume that the oils are mixed in a linear manner and the viscosity of each oil is:
    veg1=$8.8$, veg2=$6.2$, oil1=$1.9$, oil2=$4.3$, oil3=$5.1$

Decision Variables:
let $x_1,x_2$ be the amount in tons that we bought from veg1 and veg2 oils.
$y_1,y_2,y_3$ the amount in tons that we bought from oil1,oil2 and oil3.

Our goal function should be the profit of the factory, and we need to maximize that.
First, we need to know our product sales money, and that is $180$ for each ton of the mix, I got confused of how to express it, but I think the most intuitive way is $180*(x_1+x_2+y_1+y_2+y_3)$, since the mix is made from all the oils (and they didn't mention them needing to have the same proportions).
Second, the cost of the oils which is $115x_1+128x_2+132y_1+109y_2+114y_3$.

So Our function is: $180*(x_1+x_2+y_1+y_2+y_3)-115x_1+128x_2+132y_1+109y_2+114y_3$.

From the first restriction, we get these inequalities: $x_1+x_2\le 210$ and $y_1+y_2+y_3\le 260$.

I was told than linear manner most likely means weighed average (I am still unsure why though), so:
$3.5 \le\frac{8.8x_1+6.2x_2+1.9y_1+4.3y_2+5.1y_3}{x_1+x_2+y_1+y_2+y_3}\le 6.2$.
And that's it for the first part with adding the last restriction $x_1,x_2,y_1,y_2,y_3\ge 0$.

Now, we add these restrictions:
3. The final product cannot include more than $3$ (types) of oils.
4. If one oil is in use while mixing, then we must use atleast $30$ tons of it.
5. If we used any vegetarian oil, then we must use oil2.

Let $z_1$ be a discrete variable that counts how many oils we used $0 \le z_1\le 5$.
Let $v_1,v_2,o_1,o_2,o_3$ be indicator variables, equal to $1$ if we used each oil and $0$ otherwise.
Let $t$ be an indicator variable, equal to $1$ if we used any vegetarian oil and $0$ otherwise.

From the third restriction we get $z \le 3$.

Now if any oil is in use or in other words, it's indicator is $1$, we must use $30$ tons or more ($M$ is a very big fixed variable):
$30-x_1 \le M(1-v_1)$, we add that restriction for all the four indicators.

For the last one, if $v_1\bigvee v_2 = 1$ then we must have $o_2 = 1$, so we add:
$o_2 \le v_1 + v_2, o_2 \ge v_1, o_2 \ge v_2$.

Another connection I saw, is that we always have $z=v_1+v_2+o_1+o_2+o_3$.
And that's all the new restrictions.

Any feedback will be really appreciated, sorry if it's too long, just wanted to explain my thoughts clearly.


1 Answer 1


See this example, which is a multi-period version of the same problem with slightly different data, from Model Building in Mathematical Programming by H. Paul Williams. Note that you do not need $z_1$, $z$, or $t$ and can instead express the desired constraints in terms of the other variables.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.