Optimisation of food items problem - how do I find the cheapest combination?

79 Views Asked by At

I have a table of data of food items, about 200-300 of such food items. Each food item has a cost price, weight/volume, nutritional info (like total weight of protein, total weight of carbs etc.) per unit (eg. bottle, can, packet).

Given the following constraints, how can I find (1) the combination of food items I should buy that would fulfil my nutritional needs at the cheapest price, and (2) the combination of which food items (and how much) I should be eating for each meal?

Say my daily nutritional needs are

  • 250g of protein
  • 23g of fat
  • 200g of carbs

The constraints:

  1. units can only be bought in discrete numbers. eg. you cannot buy 3.2 cans of sardine, you can only buy 3 or 4 cans
  2. Each food item usually has x protein, y carbs and z fat etc., and buying or increasing the intake of any food item will increase intake of all nutrients. ie you cannot isolate one nutrient from others
  3. (this constraint can be ignored if it makes the problem too difficult) some food items should go or should not go with others in a single meal. eg. canned salted sardine should not be eaten with a sweet dressing. Dressings should not be eaten altogether in one meal.

If this is not easy to answer in a single post, references to the appropriate mathematical literature eg. textbooks, lecture notes will suffice. Also, is this only solvable by a computer algorithm?