Genetic Complete Foods
What is this?
Genetic Complete Foods is an attempt to automatically create a complete food recipe given a list of ingredients and a target nutrient profile.
You can play with it by pressing to step to the next generation, to step to next generations automatically and to reset the simulation.
Find the code at http://github.com/nick/genetic-soylent
How it works
- Generate 100 recipes, each recipe containing a random amount of each ingredient.
- Score each recipe based on how close all the nutrients are to 100%.
- Sort the recipes from best to worst.
- Show the best one in the table above.
On each subsequent 'generation', the following happens:
- Remove the worst 30 recipes from the list
- Create 30 new Child recipes containing ingredient amounts taken from two randomly selected Parent recipes.
- Ingredient amounts in each Child can also be mutated if the 'mutation probability' is met.
- A mutation works by taking a random ingredient and increasing or decreasing the amount defined by the 'mutation multiplier'. For example, a mutation multiplier of 0.1 will increase or decrease the amount of an ingredient by 10%.
- Finally, we re-calculate the scores for each recipe, sort them, and show the best one in the table.