Optimizing resources with Linear Programming

Diet problem

The diet problem was the first of some about optimization. The goal was to find the cheapest way to feed the army but insuring at same time some determined nutrition levels.

This kind of problem can be questioned in several ways such as minimizing purchase expenses, diet for the cattle, slimming diet that meets certain levels of calories, proteins, carbohydrates, ...


We want to feed the cattle in a farm using a diet as cheap as possible. Such diet must contains four types of nutrients that will call A, B, C, and D. This components can be found in two kind of fodders, M and N. The amount of every component in grams per kilogram of these fodders is shown in the next table:

  A B C D
M 100 - 100 200
N - 100 200 100

An animal's daily diet must be mixed at least with 0.4Kg of A component, 0.6Kg of B component, 2Kg of C component and 1.7Kg of D component. The M fodder cost 0.2€/Kg and the N fodder 0.08€/Kg. What quantities of fodders M and N must be purchased to minimize the cost?

Note: 1 kilogram (Kg) are 2.205 pounds.


Determining decision variables and expressing them algebraically. In this case:

Determining the restrictions and expressing them as equations or inequalities in function of the decision variables. Such restrictions can be obteined from required composition to daily diet (in Kg):

Expressing all implicit conditions established by the origin of variables: negativeness, integer, only a few allowed values... . In this case, the only restriction is that the quantities of fodder that make the diet can't be negatives:

Determining objective function:

Solve with PHPSimplex.

Copyright ©2006-2024 PHPSimplex. All rights reserved.Update cookies' preferences
Follow us on Twitter

Version 0.81

Copyright ©2006-2024. All rights reserved.

Developed by:
Daniel Izquierdo Granja
Juan José Ruiz Ruiz

English translation by:
Luciano Miguel Tobaria

French translation by:
Ester Rute Ruiz

Portuguese translation by:
Rosane Bujes