Verbal formulation of the diet problem.


Minimize the "cost of the menu" 
subject to the nutrition requirements: 
        eat enough but not too much of Vitamin A
                        .
                        .
        eat enough but not too much Vitamin C 

Additional constraints can be added to the diet problem. One can put constraints on the amount of which foods are consumed:

  Eat at least a certain minimum number of servings of beef but not more
  than the maximum number of servings of beef you want.
                        .
                        .
  Eat at least a certain minimum number of servings of carrots but not
  more than the maximum number of servings of carrots you want
In order to create a mathematical version of this model, we need to define some variables:
 
  x(beef)     =  servings of beef in the menu
                        .
                        .
  x(carrots)  =  servings of carrots in the menu

and some parameters:

 
  cost(beef)    =  cost per serving of beef
  min (beef)    =  minimum number of servings to eat
  max (beef)    =  maximum number of servings to eat
                        .
                        .
  cost(carrots) =  cost per serving of carrots
  min (carrots) =  minimum number of servings to eat
  max (carrots) =  maximum number of servings to eat

  A(beef)     =  amount of Vitamin A in one serving of beef
  A(carrots)  =  amount of Vitamin A in one serving of carrots
                        .
                        .
  C(beef)     =  amount of Vitamin C in one serving of beef
  C(carrots)  =  amount of Vitamin C in one serving of carrots
and
  min(A)  =  minimum amount of Vitamin A required 
  max(A)  =  maximum amount of Vitamin A required
                        .
                        .
  min(C)  =  minimum amount of Vitamin C required 
  max(C)  =  maximum amount of Vitamin C required


Basic Formulation


Given this notation. The model can be rewritten as follows.

Minimize:

 cost(beef) * x(beef) + . . . + cost(carrots) * x(carrots)

Subject to:

 min(A) 


Mathematical Formulation


The formulation can be made more mathematical if we define a set of foods and a set of nutrients.

Let Foods = { beef, . . . , carrots}
Assume there are f foods in Foods.

Let Nutrients = { A, . . . , C}
Assume there are n nutrients in Nutrients.

and a set of parameters:

cost[i]     = costs of the foods for 1 < i < f.
x[i]        = unknown amounts of foods to eat for 1 < i < f.
nutr[j][i]  = amount of nutrient j in food i for 1 < i < f and 1 < j < n.
min_nutr[i] = minimum amount of nutrient i required for 1 < i < n.
max_nutr[i] = maximum amount of nutrient i allowed per day for 1 < i < n.
min_food[i] = minimum amount of food i desired per day for 1 < i < f.
max_food[i] = maximum amount of food i desired per day for 1 < i < f.

Minimize

Subject to:

for 1 < j < n, and

min_food[i] < x[i] < max_food[i] for 1 < i < f.


The AMPL code is provided below.




set NUTR; 
set FOOD;

 
param cost {FOOD} > 0;
param f_min {FOOD} >= 0;
param f_max { f in FOOD} >= f_min[f];

param n_min { NUTR }  >= 0;
param n_max {n in NUTR } >= n_min[n];

param amt {NUTR,FOOD} >= 0;

var Buy { f in FOOD} >= f_min[f], <= f_max[f];

minimize total_cost: sum { f in FOOD } cost [f] * Buy[f];

subject to diet { n in NUTR }:
        n_min[n] <= sum { f in FOOD} amt [n,f] * Buy[f] <= n_max[n];