Here is my web app, NutrientCraft.com
A couple of months ago I was inspired by Rob Rhinehart’s soylent experiment in which he claims to have stopped eating food by consuming only the ingredients the body requires. From his blog, “There are no meats, fruits, vegetables, or breads here… I researched every substance the body needs to survive.. and purchased all of them in nearly raw chemical form from a variety of sources.”
I like the idea of 100% efficiency, however Rob’s approach is too extreme for me. There is, for example, the possibility that nutritional science is incomplete or the that the production of the raw nutrients is flawed. I wanted something in between a traditionally healthy diet and a futuristic nutrient goo.
I was unable to find a tool that could take a list of whole foods and fit their nutrients into a diet, or target set of nutrients. For example, if you are trying to create a list of food portions to meet your daily vitamin C requirements, you will probably find the list of foods has too little or too much of another nutrient. So if you try to balance for this next nutrient, vitamin C will now be unbalanced.
The challenge to me seemed similar to “bin packing” algorithms, like this one. I treated all foods as n-dimensional vectors of nutrients (percent of daily nutrient requirements). I then set a target vector of (1,1,1…), or 100% of daily nutrient requirements. I figured the problem is NP-hard like the bin packing problem, so I wrote a brute force algorithm that tries every possible combination until it finds the best. The best combination of vectors is the one with the smallest angle between itself and the target vector. When I had something working, I ran it on the full National Nutrient Database and it spit out the nastiest meal I’ve ever seen, but it was EFFICENT! Here is my first full database test, graphed with matplotlib: