Optimal Nutrition Through Linear Programming
Optimal Nutrition Through Linear Programming
Optimal Nutrition Through Linear Programming
00
Printed in Great Britain. All rights reserved Copyright Q 1990 Pergamon Press plc
TABLE OF CONTENTS
1. Introduction
2. Hypothetical problem
2.1. Problem statement
2.2. Graphical solution
2.3. The simplex method of solution
3. Model of the ideal diet plan
3.1. Food list
3.2. Constraints
3.3. Formulation of the model
3.4. Sample solutions
4. Conclusion
5. References
6. Exercises
I. Answers
1. INTRODUCTION
Many people are confronted daily with the problem of obtaining a nutritionally balanced diet.
Several factors have to be taken into consideration-calories, protein, iron, the various vitamins
and, of course, variety. Personal characteristics and lifestyle also have to be taken into account-
for example, an athlete’s optimal menu would differ markedly from a hospital patient’s ideal
meal plan.
We would like to develop a mathematical model for the ideal diet plan for different classifications
of people, i.e. athletes, patients, vegetarians, children and “average” male and female adults. Such
a plan should insure that over a specified period of time the diet supplies the proper nutrients
without exceeding certain caloric bounds. It also seems desirable to attempt to minimize the cost
of the plan. The presence of these nutritional constraints and the cost objective function suggests
that the development of the ideal diet plan is actually a linear programming (LP) problem.
2. HYPOTHETICAL PROBLEM
Table I
Protein/lOOg Vitamin C/l00 g Cal/100 g Price/l00 g (S)
Green beans 1.5 20 I8 0.20
Corn 3.5 IO 100 0.15
Minimums 20 g/day 70 mg/day -
Maximums - - 600 calidav -
94 Educational Mathematical and Computer Modules
Let x, be the number of 100 g units of green beans and x2 the number of 100 g units of corn.
The total cost of these items will be
f = 0.2x, + 0.15x,. (1)
Nutritional balance in our diet requires that we meet the daily minimums and maximums of
protein, vitamin C and calories indicated in the last two rows of Table 1. The constraints can be
expressed as
1.5x, + 3.5x, > 20, (2)
20x, + 102> 70, (3)
and
18x, + 100x, < 600. (4)
Since we cannot eat a negative amount of food, we must also have
x, 2 0 and x2 > 0. (5)
2.2. Graphical solution
We will first attempt to solve this problem graphically. In Fig. 1, the three constraint inequalities
(2)<4) have been plotted. The shaded area represents those point which satisfy all the constraints
(2)-(4). They can be thought of as all possible solutions to the LP problem and are called the
feasible set.
We must now find the point (x: , xf ) which makes the cost function (1) smaller than would any
other point in the feasible set. To do this, some of the family of lines f = c have been drawn in
Fig. 1. Since the line f = 0.9 does not intersect the feasible set, but f = 1.2 does, the minimum of
f should be between these two values. In fact, the first member of the family f = c to intersect the
/ 1.5x, +3.5x2 l 20
XI
12
10
6
f =1.5
f-1.2
110.9
4
0 2 4 6 6 10 xp
Fig. 1
Optimalnutrition through LP 95
feasible set will be that line which touches the lower left-hand corner. Reading the values of x, and
x2 from the graph at this point we have that x : = 0.8, x: = 5.4 so that the value of the program
(the cost of the food) will be f = 974.
If x, and x2 were restricted to integer values, i.e. if corn and beans were only sold in units of
100 g, the optimal solution in the feasible wet would be XT = 2, XT = 5, and the value of the
program would be f = $1.15.
O.l8x,+x,+s,=6, (6)
where x, , x2, s, , s2 and s3 > 0. Note that the surplus variables, sl and s2, are preceded by minus
signs while the slack variable, s3, is preceded by a plus sign.
The standard form also requires that the objective function be maximized. In our problem we
are seeking to minimize the cost of the food so we must alter the objective function by negating
it. The solution maximizing the negative of the function will also minimize the function itself. Thus,
the objective function for our problem becomes
Theorem 1. If an optimal solution exists then there exists an optimal solution which
is also a basic feasible point, i.e. at least n - m of its coordinates are zero.
Thus, the simplex method need only be concerned with basic feasible points. Once such a point
has been found, we move to another basic feasible point which will increase the value of the
objective function. If no such increase can be made, then the current basic feasible point is the
optimal solution.
96 Educational Mathematical and Computer Modules
2.3.3. The simplex algorithm. In order to facilitate the use of this method in the solution of our
problem, we will first summarize the basic steps in the following manner:
1. Find a basic feasible point at which the iteration can begin by dividing the n
variables into n - m independent and m dependent variables.
2. Express the dependent variables and the objective function in terms of the
independent variables.
3. If none of the coefficients in the expression of the objective function in terms of
the present independent variables is positive, then the present basic feasible point
is an optimal solution, so stop.
4. For each of the independent variables, yi, which have positive coefficients in the
objective function, determine the largest possible positive increment, Ayi, one can
make in the independent variable without making any of the independent
variables negative. Note the values of these increments for each independent
variable as well as the corresponding increment in the objective function and the
dependent variable, y,, which inhibits any further increase in y, by becoming zero.
5. Interchange the independent variable yi with the dependent variable y, from
Step 4.
6. Return to Step 2.
The condition for completion of the process which is stated in Step 3 is known as the optimality
criterion. If the optimality criterion is satisfied, the objective function cannot increase when one
(or more) of the independent variables are given positive values. Since negative values are not
allowed, this insures that the objective function is maximized.
2.3.4. Solution of the nutrition problem. We are now ready to apply the simplex method to the
solution of the hypothetical nutrition problem. We will start by selecting x, and x2 as independent
variables. The objective function (7) is already in terms of these variables so we need only to rewrite
the constraints as
s* = 2x, + x* - 7,
Our objective is to find a basic feasible point. To do this we fix x, = 0, and determine the minimum
value of x2 which will satisfy s, , s2, s3 > 0. It can be seen that when x, = 0, s2 > 0 requires x2 > 7
and sj 2 0 requires x2 < 6. So there is no such x2. Therefore, fix x2 = 0 to get
s2 20*x, 2 3.5,
Since the coefficient of x, in the objective equation is negative, we want to choose the minimum
x, which insures that all the slack variables will be nonnegative. Thus, the limiting constraint is
s, 2 0 and we exchange s, and x,, making s, and x2 the new independent variables.
We next solve for the others in terms of sl and x2:
The objective function must also be put in terms of the new independent variables:
Since x2 has a positive coefficient in the objective function, we want to fix s, = 0 and increase x,
as much as possible. If s, = 0, then
The least of these upper limits is 59/ 11, imposed by s2. Following the same procedure as previously,
we switch s, and x,, making s, and s2 our independent variables. Constraints (8) can now be written
as
x2= 1/11(4s,-3s,+59),
x, =6/33s, +7/11s,+9/11,
Since s, and s2 both have negative coefficients in the objective function, and all the constraints (i.e
XI, x2, s3 > 0) are satisfied when s, = 0 and s2 = 0, the optimality criterion of Step 3 is satisfied.
Substituting s, = 0 and s, = 0 into equations (10) gives
f = -g = $0.97.
It should be noted that the optimal solution (XT, xf) as well as the value of the program were
the same whether the problem was solved graphically or by the simplex method. The advantages
of the simplex method are that it yields answers algebraically which may be only approximately
readable from a graph and it allows the solution of LP problems of higher dimension.
3. I. Food list
A diet composed of only green beans and corn would be monotonous and nutritionally
unbalanced. The development of an ideal diet plan requires that the problem be expanded to
include a variety of foods including meats, fruits, vegetables, milk products, breads and cereals and
“junk” foods. A list of 38 foods and their nutritive content and cost per 100 g is presented in
Table 2.
3.2. Constraints
A balanced diet should, in the long run, contain the minimum daily requirements of vitamins
A, C and B6, iron and protein, while staying within a specific calorie range. These requirements
are summarized in Tables 3 and 4. The minimums and maximums vary from person to person
depending on age, weight and sex.
In addition to caloric and nutritional constraints it also is desirable to place some variety
constraints on the diet so that we do not end up eating a constant diet of liver and oranges for
instance. Also, if some foods of low nutritional value, for example candy bars, are desired, we must
put some minimum constraint on them.
98 Educational Mathematical and Computer Modules
Table 2
Food Protein Iron Vit C Vit A Vit 86 Calories cost (S)
Chicken 30 I.5 0 75 0.35 I83 0.23
Ham 18 2.5 0 0 0.5 246 0.48
Liver I9 I7 25 12,000 0.6 I55 0.12
Bologna 13 2 0 0 0 350 0.57
Pork 24 2.5 0 0 0.1 390 0.28
Sirloin steak 28 4.5 0 0 0.08 440 0.59
Fish I7 0.8 0 0 0.2 220 0.35
Peanut butter 30 2 0 0 0.45 350 0.28
Eggs 13 2.5 0 1000 0.2 80 0.06
Skim milk 3.5 0.1 I 0 0.04 34 0.05
Am. cheese 25 0.7 5 705 0.3 331 0.47
Yogurt 4 0 I 12s 0.04 280 0.15
Cottage cheese 30 0 0 4 8 95 0.23
Butter 0.5 0.1 0 3500 0 750 0.19
Ice cream 4.5 0.2 I 450 0 II6 0.07
Whole milk 3.5 0 2 I25 0.04 65 0.06
White bread 8 2 0 0 0.07 250 0.13
Wheat bread 8 8 0 0 2 265 0.08
Special K 28 IO 70 5000 2 388 0.27
Sugar pops 5 4 62 4400 2 380 0.35
Rice 2 0.2 0 0 0.07 380 0.09
Spaghetti 3.5 0.4 0 0 0 I05 0.1 I
Donuts 7 0.1 0 0 0 500 0.30
Coca-Cola 0 0 0 0 0 38 0.04
Candy bar 0 0 0 0 0 530 0.59
Apples 0.2 0.3 6 75 0.05 42 0.11
Oranges 0.9 0.3 50 I50 0.05 38 0.1 I
Bananas I 0.5 IO 300 0.3 85 0.07
Strawberries 0.7 0.7 60 7s 0.05 27 0.12
Green beans I.5 0.8 20 600 0 18 0.20
Corn 3.5 0.6 IO 400 0.1 100 0.15
Carrots I 0.6 6 12,000 0.08 27 0.09
Potatoes 2 0.6 25 0 0.3 75 0.02
Tomatoes I 0.5 25 1000 0.09 I6 0.22
Chicken soup I4 2.5 0 325 0 350 0.12
Ted 0.1 0 0 0 0 I 0.07
Coffee 0.3 0 0 0 0 3 0.75
F R,xi 3
i= I
&in (12)
Note that in the more realistic problem under consideration we must also require that a certain
minimum number of calories be consumed on a daily basis. We can insure variety by requiring
The results of this problem were used to plan the menu in Table 5. The menu was obtained by
multiplying the number of days by the proportions provided by the LP problem. The daily
expenditure for food for this menu is $1.86.
4. CONCLUSION
The methods of LP could be applied to the nutrition problem to vary the menu to the particular
needs of individuals. For instance, a vegetarian could substitute other foods for the meats listed,
or a “weight watcher” could minimize the calories instead of the costs. Whether it is a hospital
planning menus or a family working with a limited income, this model will provide a nutritionally
sound menu, catering to individual situations, at a minimum cost.
In general, LP can be used to solve constrained minimization or maximization problems in a
variety of fields. Some examples of such applications are the product-mix problem, personnel
assignment, transportation problem and scheduling.
5. REFERENCES
I. S. P. Bradley, A. C. Hax and T. L. Magnanti, Applied Mathematical Programming. Addison-Wesley, Reading, Mass.
(1977)
2. F. Hart, A. M. Leslie and H. J. Fisher, Modern Food Analysis. Springer, New York (1971).
3. K. L. Jones, L. W. Shainberg and C. 0. Byer, Foods, Diet and Nutrition. Canfield Press, San Francisco, Calif. (1970).
4. D. R. Osborn and P. Voogt, The Analysis of Nutrients in Food. Academic Press, London (1978).
5. C. Rorres and H. Anton, Applications of Linear Algebra. Wiley, New York (1977).
6. EXERCISES
Suppose that your diet consisted of only cottage cheese and wheat bread and the only constraints on your diet were
that your protein must be > 30 g/day and your calorie intake must be <950/day. You would like to minimize the daily
cost of this diet.
(a) Formulate the LP problem.
(b) Solve the problem graphically
(c) Construct the standard form of the problem and solve it using the simplex method.
Suppose that instead of a maximum caloric intake of 950 calories we needed a minimum of 265. Make the appropriate
changes in the LP problem and solve it graphically and by means of the simplex method.
What would the maximum food cost be under the constraints of Exercise I? Of Exercise 2?
Optimal nutrition through LP 101
4. Instead of solving the problem as stated (the primal problem), one could instead formulate and solve the dual problem.
To change the primal to the dual problem you follow four steps:
(a) interchange the number of variables and the number of constraints;
(b) interchange the constraint vector and the cost vector;
(c) reverse the constraint inequalities;
(d) change maximums to minimums and vice versa.
The value of the dual problem is the same as the value of the primal problem. Formulate and solve the dual problem
associated with Exercise 1.
5. Use a computer package to develop an ideal diet plant for yourself or someone you know.
I. ANSWERS
I. (a) X, = amount of cottage cheese, x2 = amount of wheat bread. Constraints:
Minimize:
f = 0.23x, + 0.08x,.
(b)
X2
6
2 4 6 6 10 x,
308, / + 6x2 b 30
Maximize:
g = -0.23x, -0.08x,.
For x, = 0, S, 2 0 requires x2 > 3.75, s2 > 0 requires x2 Q 3.6. There is no such x2. Therefore, fix x2 = 0. s, > 0 requires
x I/> 19s 2A> 0 requires x, < 10. Since the coefficient of x, in the objective function is negative we choose the minimum
x, and exchange s, and x,. Solving for x, and s2 in terms of s, and x2, we have
4
x,=2--x,+ 1,
30 I5
s,=+9+9xx,+95o
and
-0.23
ps, - 0.02~~ - 0.23.
g= 30
102 Educational Mathematical and Computer Modules
Choosing S, = 0 and x2 = 0 will maximize g since their coefficients are negative and still insure sr and x, > 0. Thus,
-uF = 1 and .x: = 0, and the minimum cost is 0.23.
Notice that the caloric constraint did not affect the solution. This is an example of an inoperative
constraint.
New constraint:
95x, +265x, > 265.
Graphical solution
Simplex method
New constraint:
95x, f 265.x, - s2 = 265.
For x, = 0, r, 2 0 requires x2 2 3.75, s2 > 0 requires x2 > 1. Exchanging .r, and ~2, we have
sr = T - 898.75x, + 278.15
and
g = 0.07x, - O.OlS, - 0.3
Since s, and s2 both have negative coefficients in g and all the constraints are satisfied, take S, = 0 = s2. Thus, x7 = 0.811
and x: = 0.709 and the minimum cost is f = $0.24.
The constraints stay the same; maximizef= 0.23x, + 0.08.x,. Graphically for Exercise I: (x;, x;) = (10, 0), f = $2.30.
Graphically for Exercise 2: (XT. x!) = (co, co).
Simplex method for Exercise 1
Let S, + x, be independent:
x,=$-gx’+ 10,
-30
s, = 95 s2 - 75.7x, + 270
and
-0.23
ps2 - 0.57x, + 2.30.
f= 95
Thus, the maximum off is attained for s2 = x2 = 0 which means (xr , x$) = (10, 0).
Optimal nutrition through LP 103
4. Since only the first constraint was operative in Exercise 1, we will only use it to formulate the dual problem. Thus, we
have one variable an two constraints:
3Oy, c 0.23,
Sy, 6 0.08.
Maximize:
h = 3Oy,.
The constraints imply that y, < 0.23/30 and the maximum of the objective function will be h = 0.23. Note that this is
the same as the value of the program in Exercise 1. In general, it the number of constraints of a problem is much greater
than the number of variables, it is usually better to formulate and solve the dual problem.