The main thing I wanted to optimize was menu planning. So I wrote a genetic algorithm which will generate a menu, add the score, mutate the menu in some way, and iterate. In my database I have a rough price per ingredient, and my families enjoyment of the recipe (though I have kind of a lagging gradient which reduces the score per recipe to prevent duplication). I also have included in my algorithm what I call slots. So something like a lasagna will take 4 slots where as a stir fry will be 1 slot. I sync my schedule and break it down to slots. This allows the algorithm to fit the recipe to the time available. I dont score slots though otherwise short recipes always win.
Since the algorithm optimizes based on the week, but keeps a running inventory it's pretty good at maximizing my grocery bill and family enjoyment. My average grocery bill is between $40-$60 a week. And I cook 5 times a week.