Keto Diets and Linear Programming

In today’s New York Times Magazine, there is an article on how a ketogenic (“keto”) diet can be used to control epileptic seizures in kids.  The diet is quite something.  Referring to his son’s diet, the author Fred Vogelstein writes:

His breakfast eggs are mixed with heavy cream and served with bacon. A typical lunch is full-fat Greek yogurt mixed with coconut oil. Dinner is hot dogs, bacon, macadamia nuts and cheese. We figure that in an average week, Sam consumes a quart and a third of heavy cream, nearly a stick and a half of butter, 13 teaspoons of coconut oil, 20 slices of bacon and 9 eggs. Sam’s diet is just shy of 90 percent fat.

The diet contains almost no carbs, making it reminiscent of an Atkin’s diet during a particularly anti-carb phase.  This diet has the effect of greatly reducing the number of seizures in many kids, including those who have not responded to any of the possible drugs.  In Sam’s case, the seizures went from hundreds per day to perhaps a half dozen.

While a diet of bacon and ice cream seems like heaven, it is actually very hard to do.

For Sam’s diet to be effective, he must eat a certain number of calories every day with specific ratios of fat, protein and carbohydrates. These are not back-of-the-envelope calculations, but ratios that have to be hit exactly at every meal. If Sam wants a snack after school, he gets 18 grams of bacon (about two slices), 14 grams of macadamia nuts (about seven nuts) and 18 grams of apple (less than an eighth).

You can’t just throw together everything without carbs and hope that things work:

To jump through these arithmetic hoops, Evelyn, who gave up her career to take on the now full-time job of feeding Sam, plans meals on the kitchen computer using a Web-based program called KetoCalculator. It is hard to imagine how to administer keto without it. A meal for Sam might have eight ingredients. Mathematically, there are potentially millions of combinations — a bit more of this; a bit less of that — that gets you to a 400-­calorie meal and a 3-to-1 ratio.

I don’t have access to the Calculator (you need to be referred to it by a doctor), but it would be interesting to know if the site goes beyond just being a calculator.  Putting together ingredients to meet dietary requirements is a classical problem for linear programming.   Rather than just determine if a set of ingredients meets the requirements, a linear-programming approach would put the ingredients together in an optimal way to meet the requirements while optimizing some objective (like maximizing use of ingredients you have not eaten in the last week, or maximizing use of some food you have a craving for).  No hit-or-miss calculating:  the combination would be guaranteed to meet the dietary requirements.

You can check out the NEOS server to experiment with putting together a traditional diet.  I would love to experiment with a site that creates keto diets.  Imagine being able to turn an illegal, but palatable, meal into a legal meal by adding 3 macadamia nuts (and have the linear program automatically suggest that).

In the past, I have used the diet problem for laughs, but this seems to be a real application for  operations research that could be very useful (if it is not already being used).