I'm putting together a personal list of recipes that I enjoy, and would like to construct an algorithm that parses this recipe database and automatically builds me a meal plan for the week.
For N number of meals per day, find permutation of recipes that comes the closest to satisfying these conditions:
- Sum of meal calories ~= my defined daily calorie limit
- Average recipe macros* (weighted by recipe calories) ~= my desired macros (i.e. (30/40/30))
(*: Macros are the ratio of carbs/protein/fats in a meal, and are usually found in a tuple form: (CC/PP/FF))
Each recipe can be assumed to be in the form:
'name': {
'calories': a,
'protein': b,
'carbs': c,
'fats': d
}
In other words:
Inputs: n_meals, max_cals, (cc,pp,ff) # <- macros
Output: [recipe_1, recipe_2, ..., recipe_n]
I have no formal training in algorithms, so I'm not really sure where to start. The naive approach would be to take every permutation of recipes in the list and use the permutation which satisfies the criterion the closest.
This is definitely a multi-dimensional optimization problem but that's the depth of my knowledge. Perhaps something like a breadth-first search algorithm would be most appropriate?
Thanks all.