Computational Nutrition: An Algorithm to Generate a Diet Plan to Meet Specific Nutritional Requirements

Many methods have been proposed to generate meal plans, but most of them only consider prox-imates. However, the human body requires a combination of proximates and several macronu-trients, micronutrients, vitamins, and minerals. Furthermore, the models designed to generate these meal plans do not take into account an individual’s specific nutritional needs. These needs are often expressed as a combination of lower bound amount (LBA), ideal amount (IA), and upper bound amount (UBA) necessary for the human body to thrive. The aim of this project is to generate an algorithm to produce a list of food items that will meet specific nutritional requirements. With the proposed algorithm, each nutrient receives a score based on the amount of nutrient contained in the food list in relation to the LBA, IA, and UBA. These scores are aggregated to give the meal plan an overall score.


Introduction
The United States has the highest health expenditures as a percentage of Gross Domestic Product (GDP) among developed countries [1].The US also spends the most of any country on healthcare [1].In 2006, health care cost for an overweight person was $1429 greater per person than spending for normal weight people.More than one third of all US adults over the age of 19 are obese [2].This ranks the US among the top ten most obese countries in the world [3].Given the high rate of obesity and the increased medical spending, reducing the obesity rate in the US will contribute to a significant reduction in health care spending.Adopting a healthy lifestyle can help prevent and reduce obesity [4].
Fortunately, people are becoming more aware of their heath and how simple things like diet and exercise can contribute to an overall healthy life.Furthermore, technology is helping more people become increasingly aware and engaged in maintaining a healthy life.As evidence, there are literally thousands of apps in the Apple App Store related to health and fitness [https://itunes.apple.com/us/genre/ios-health-fitness/id6013?mt=8], not to mention the thousands of website devoted to health.Wearable computing is also revolutionizing how people monitor and maintain their well-being.
Diet is one important aspect of health that people are increasingly taking notice of.There are dozens of mobile apps and website devoted to tracking calorie consumption, meal planning, grocery shopping, etc.Besides maintaining general health, diet is also known to be the "cheapest and most accessible medicine" [5] [6], offering alternatives to pharmaceutical drugs for the prevention and treatment of disorders and diseases.Traditionally, a registered dietitian could be hired to plan meals and food choices to help reach nutritional goals.However, this kind of specialized advice is cost-prohibitive for the average person.What is needed is an inexpensive tool to allow the average health-conscience consumer a way to make positive food choices tailored to a set of nutritional goals.This paper proposes a method that aids a person in creating customized food lists that meet specific nutritional requirements.In addition, the tool could be used as an aid to a registered dietitian in creating a diet plan aimed at treating patients with specific disorders, such as diabetes or food sensitivities.

SSC3gd
The SSC3gd model is nutrient profiling method developed to rate foods from less healthy to more healthy.It ranks foods based on energy density, saturated fat, non-milk extrinsic sugars, sodium, calcium, iron, and n-3 polyunsaturated fatty acids [7].SSC3gd is a very good model for ranking the nutritional value of foods.However, it does not take into account a person's specific nutritional requirements when assigns a food its SSC3gd [7].

EatThisMuch
There are several websites with the purpose of creating a tailored meal plan.These websites offer a fast way of creating a meal plan to meet certain types of diets such as paleo, vegetarian, or ketogenic type diet.However, one major shortcoming of these websites is that they do not take into account the various macronutrients, micronutrients, vitamins, and minerals that are essential to the human body's overall health.
EatThisMuch.com is a feature rich system for creating a daily meal plan.It generates the meal plan based on the number of calories, number of meals, and a range of protein, carbohydrate, and fat targets.It provides a breakdown of the percentage of calories from proteins, carbohydrates, and fats for the generated list of meals.It provides a daily weight tracker to give the user feedback on the effect their diet is having on their weight.However, it does not provide the user with the opportunity to limit or increase the micronutrient makeup of the meals.

Custom Meal Planner
Custom Meal Planner.com is another website dedicated to generating a personal diet plan.It provides a different set of features than EatThisMuch.com.It generates its meals based on a given Basal Metabolic Rate (BMR) Model, in conjunction with a certain diet type, goal, and activeness.It does not appear to take into account specific nutritional requirements that a person may have.

Proposed Method
We propose a method that generates a customized meal plan to meet personalized nutritional goals.Our daily meal plans are based on the nutrients referenced in Table 1.All nutrients under consideration for this project are given a Lower Bound (LB).The LB is the absolute least amount of that nutrient that will be accepted in order for the meal plan to be accepted.As explained later, a default LB is provided for all nutrients, and users are given the ability to customize the LB to account for deficiencies or excesses to provide better health outcomes.For example, a nursing mother will require a different set of nutrients than a pregnant mother.All nutrients are also given an Ideal Amount (IA).The IA is the amount of the nutrient that will result in the meal plan receiving a perfect score for the specific nutrient.It is possible for the LB and IA to be the same.Some nutrients could also have an Upper Bound (UB).The UB is the maximum amount that will be accepted beyond which the meal plan will be deemed unacceptable.The UB provides the user with the ability to limit undesirable qualities of a meal plan.For example, if someone is suffering from high blood pressure the UB of nutrients can be altered to levels that will contribute to the lowering of blood pressure.
To determine if a meal plan meets a given set of nutritional goals, we calculate a numerical score for a meal plan, called the MSCORE.The MSCORE is a summation of each nutrient's score (NSCORE).If we look at two MSCOREs generated with an identical set of nutritional goals, the larger MSCORE correlates to a meal plan that more closely fits the nutritional requirements.
An NSCORE is generated using one of a set of three linear functions.The selection of which of the three functions to use is based on the amount of nutrient currently in the meal plan (X nut ) in relation to the nutrient's UB, IA, and LB.If X nut is greater than the IA and less than the UB the first function below is used.If X nut is less than the IA and greater than the LB, the second function is used.Finally, if X nut is less than the LB the third function is used.Essentially, the three functions differ in the "weight" and "default score" used.As shown below, our method allows for three different weights and three different default values, allowing users to place a numerical emphasis on the LB, IA, or UB for a given nutrient.
Graphically, the nutritional functions are displayed in Figure 1.The X axis is the amount of the nutrient present in the meal plan (in this case in milligrams).The Y axis is the corresponding NSCORE for this nutrient.The weights in the functions correspond to the slope of the line segments.A slope of (1) correlates to a weight of (1), a slope of (2) correlates to a weight of (2), etc.The default scores in the functions correspond to the intercepts of the line segments.The line segment in red is the function that is used if the nutrient amount falls between 0 and LB.Notice that the slope is quite steep, indicating that the user feels it is important to get at least the LB for this nutrient.The green line segment is the function that is used when the nutrient amount falls between LB and IA.Note here that if the meal plan includes the IA (2500 mg), then the maximum NSCORE is generated (2).Finally, the purple segment is the function is used if the nutrient amount exceeds IA but is less than UB.Notice that the further away from IA, the more the NSCORE decreases.

Effects of Customization
Our method provides three distinct ranges and functions to calculate an NSCORE in order to allow the meal plan to be customized.Numerically, it provides the user with the ability to apply a benefit or penalty to the NSCORE if the amount of a nutrient falls within a desirable or undesirable range.Customizing the weight and/or default values can be used to achieve specific nutritional outcomes.For example, users that are pregnant may require an increase or decrease in Folate.Users with high blood pressure may be sensitive to sodium.
To demonstrate this, consider calcium as defined in Table 2.This table shows that a user is interested in generating a meal plan that has at least 1000 mg of calcium (the LB), ideally 2500 mg (the IA), and no more than 5000 mg (the UB).Table 2 also shows that our method has generated a food list that results in 1164 mg of calcium (between the LB and IA).We will use information to show how altering the weights and defaults can affect the NCSORE (summarized in Table 3).
First, consider a control case with the weight and default values set to 1.This results in the NSCORE being the ratio of the amount of calcium to the IA (1164/2500) plus an additional point for the default value (1).This will result in an NSCORE of 1.466.Now consider if the weight is doubled from 1 to 2 (graphically, this increases the slope of the line).By raising the weight we double the effect the ratio of calcium to IA.Now the calculation is 2 × (1164/2500) + 1.The final NSCORE for the second set of weights and defaults is 1.931.With the ability to adjust the weights and defaults  across three separate ranges the user will have fine grained control over the impact each nutrient range will have on the NSCORE and MSCORE.

Prototype Implementation
To demonstrate the utility of our method, we built a prototype implementation in Python Programming Language.The prototype uses the United States Department of Agricultures (USDA) National Nutrient Database (NND) for nutrient information of 8789 foods as of Standard Reference Release 28.For an overview of the algorithm see Figure 2. The prototype starts with an empty meal plan and incrementally adds foods in an attempt to increase the meal plan's MSCORE.The prototype operates by examining each nutrient in turn.For each nutrient the prototype selects a random food from a list of 100 foods that contain the highest amount of that nutrient (the NND can generate such a list).The food is added to the meal plan and a new MSCORE is calculated.If the food does not cause any X nut to exceed the UB nut the food is kept in the meal plan.The next nutrient in the list is selected and the process repeats.Foods are added until each nutrient exceeds its LB.The meal plan is complete when all nutrient minimum requirements.Adding a food, whoever, may cause a nutrient to exceed its upper bound.When that happens the food is removed, and a new food is attempted.For example, adding bacon to the meal plan to increase phosphorus may cause sodium to increase beyond its UB.During this looping process our prototype keeps a record of the number of times a nutrient causes a food rejection.If a nutrient causes a food rejection four or more times we remove the food item from the meal plan with the highest amount of that nutrient.Continuing with the example above, once bacon is rejected, the algorithm may add peanuts, which may also increase sodium above its UB.Assume two more foods are added that cause sodium to exceed its UB.Our assumption is that the meal plan is already high in sodium, and the algorithm is having trouble adding foods that maintain sodium below its UB.Therefore, the algorithm removes the food currently in the meal plan that has the highest sodium content.
Below is a sample output from the prototype on its first loop through the nutrient list.Note line 12.While looking for a food to add calcium, the prototype selected a food that would have caused sodium to exceed its UB and was rejected.On line 22, while attempting to fit a food for vitamin E, sodium caused a food to be rejected for the fourth time.Because of this before we start the next loop the prototype will remove the food with the highest amount of sodium (line 24).
1) Looking for Vitamin C.

Evaluation
We have run the prototype implementation dozens of times using both the baseline configuration as well as custom weights and default values.The prototype never failed to produce a valid meal plan.The random nature of the food choices has effects, however.First, meal plans are seldom the same.It is theoretically possible to produce the same meal plan twice, but selecting from 100 foods for each of 19 nutrients makes it highly unlikely.The random nature of the food choices combined with the large number of food choices makes achieving a perfect score effectively impossible.Second, some meal plans have some interesting food combinations.For example, one meal plan included a Red Bull and a Twinkie, yet still met the nutritional goals.A model such as SSC3gd could be used to pare down the food list prior to it being passed to our method.All else being equal, we tend to err on the side of variety.
Finally, because of the way the prototype generates a meal plan, achieving a valid meal plan takes more comparisons as the difference between the LB and UB shrinks.The algorithm will require even more comparisons as more nutrients have smaller ranges between their LB and UB.This is due to the randomized food choices.The prototype would need to select foods based, in part, on their effect on the MSCORE.We erred on the side of variety and decided to stay away from making the food selection too smart because this could potentially lead to the same foods always being selected, and the same meal plan being generated.

Future Improvements
The prototype exists only as a command line app.We would like to build a fully functional website using the core scoring algorithm implemented in the method.The website will have a pantry feature that would allow users to track the foods that they currently have in their pantry/house.We would use this information, along with the food list for generated meal plans, to provide the users with a shopping list.The website would also present users with nutritional goal templates, an example being "Post race recovery".The template would recommend the LB, IA, and UB, and would insert the nutrient defaults and weights.The website would provide the user with recipes, as opposed to a simple food list.The recipes would be user submitted, along with the selecting what foods from the USDA database to use.

Figure 1 .
Figure 1.A graphical representation of a nutrient's score functions.

Figure 2 .
Figure 2. Graphical representation of the algorithm used to generate a food list.