0
$\begingroup$

I am trying to create an online calculator that tells you how many units of a certain food you can eat.

I already have a calculator that takes age, weight, and other such input, and determines how many calories, and grams of fat, carbohydrate, and protein someone can consume on a daily basis to meet some chosen goal.

What I want to do is convert that into units of food. For example, how many slices of pizza a person can eat.

So in that example, a slice of pizza has some quantity of calories, carbs, fats, and protein, and I need to determine how many slices of pizza someone can have before ONE of those parameters ends up exceeding the limits set by my calculator.

Take this demonstration. Say a slice of pizza has 285 calories, 10g of fat, 36g of carbs, and 12g of protein. If my daily intake allows for 1650 calories, 66g of fat, 100g carbs, 165g protein, then that means I can have 2.7 slices of pizza per day before I exceed my daily carbohydrate limit. That same amount of pizza though, would not cause me to exceed any of the other limits for calories, fat, or protein.

Is there some mathematical method that would allow be to easily determine how many units of a food can fit into the daily limits before one of the parameters exceeds one of the limits?

  • 1
    Check [this](https://www.coin-or.org/PuLP/CaseStudies/a_blending_problem.html) out2017-02-01
  • 0
    That's bang on the money. Thanks, @Kuifje2017-02-02

1 Answers 1

0

Thanks to @Kuifje, I found out that this is a classic linear programming problem, with many example solutions online. Here is a good introduction to linear programming problems, with an answer to the specific problem that I had posed: http://www.math.ucla.edu/~tom/LP.pdf