I actually think a genetic algorithm for recipes is BRILLIANT, and I think I have figured out how to implement it, relatively simply (read: ghetto-rig it).
Now, I don’t think you could use it to come up with really detailed recipes, but I think you can use this approach to come up with ideas, or high level recipes.
Basically, a “recipe” object is made up of ingredients and maybe a couple of cooking methods.
In order for this to make complete sense to everyone, I’ll have to give you folks a rundown on genetic algorithms, but that’s going to have to wait until after the Easter holiday starts. (Wait with bated breath, folks, genetic algorithms are sexy, sexy magic.) But the short story of genetic algorithms is that they are a simulation of evolution. You have a population of items, whatever they may be (in this case, they would be recipes). The best, or most fit, items get to reproduce, just like it’s supposed to work in the real world.
The problem with a genetic algorithm for recipes is that it’s hard to evaluate what is “best” or “most fit” without actually making the food and having someone rate it manually. This would take forever, and result in meals much like those in the xkcd strip. So, I have come up with a way to ghetto-rig it.
You rate the recipes by searching for the ingredients in Google and then adding the number of results. I’ll do a short example to make this more clear.
Let’s say we have a recipe: “Cod, kale, stir-fry”.
First we Google “cod kale recipe”, which gives us 1,100,000 results.
Then we Google “kale stir fry recipe”, which gives us 1,660,000 results.
Then we Google “cod stir fry recipe”, which gives us 107,000 results.
Then we Google “cod kale stir fry recipe,” which gives us 532,000 results.
That gives us a grand total of 2,312,700, which is our recipe’s fitness.
Compare this to a recipe of “grapefruit bacon salad”
“grapefruit bacon recipe” gives us 200,000 results.
“bacon salad recipe” gives us 1,380,000 results.
“grapefruit salad recipe” gives us 168,000 results.
and “grapefruit bacon salad recipe” gives us 252,000 results.
That gives us a grand total of 2,000,000. So, our first recipe would have a higher fitness than our second recipe, and would probably be better.
I can’t wait to implement this. I actually think it might work very well. Particularly if, instead of doing it by straight addition, you use a linear combination. That way you can tweak the kind of recipes you want it to produce. If you want to reward highly innovative recipes, you multiply the number it comes up with when you search for all of the ingredients and the method together (that’s the last line in both of the above examples) by a negative number, so that it detracts from the overall score. As a result, “pecan cream cheese cake recipe”, which returns 821,000 results, would score lower than ” ‘green tea’ ‘dark chocolate’ ‘ice cream’ recipe”, which only returns 61,200 results and is therefore more innovative.
I am doing a terrible job explaining this. Sorry–it’s 1:21 am and I am both very excited about the prospect and very tired. It will make more sense when I can lay out some vocabulary and a teeeeny bit of math so that we’re all on the same page.
I think the moral of the story is that the culinary world should be afraid. Very, very afraid. Can you imagine a cookbook full of recipes invented by an algorithm? I CANNOT WAIT. I will call it “Cooking with Robots”.