I watch my girlfriend spend an hour generating her meal plan for the week and figured I could make something that would work in seconds with C++/Qt.
The algorithm I am trying to produce is optimization based on:
- Per day, one meal for breakfast, lunch, dinner and a snack(s).
- Per day, a certain amount of protein, grains, fat, vegetables and dairy need to be consumed, well-defined for each meal.
From what I can tell, the situation I have is:
- A system of 5 equations, one for each type of nutrient type.
- Each equation has 4 variables, one for each type of meal.
- The coefficients of each variable are linked, based on the meal chosen.
\begin{equation} P_{B}x_{B} + P_{L}x_{L} + P_{D}x_{D} + P_{S}x_{S} = R_P \\ V_{B}x_{B} + V_{L}x_{L} + V_{D}x_{D} + V_{S}x_{S} = R_V \\ D_{B}x_{B} + D_{L}x_{L} + D_{D}x_{D} + D_{S}x_{S} = R_D\\ F_{B}x_{B} + F_{L}x_{L} + F_{D}x_{D} + F_{S}x_{S} = R_F\\ G_{B}x_{B} + G_{L}x_{L} + G_{D}x_{D} + G_{S}x_{S} = R_G\\ \end{equation}
The coefficients $P, V, D, F, G$ are the serving size that a particular meal has for each nutrient type (protein, veggies, dairy, fat, grain), $B, L, D, S$ are meal types (breakfast, lunch, dinner and snack) and $R$ corresponds to required servings per day for each nutrient. The latter is of course known and constant.
The serving size coefficients need to be chosen so that these conditions are best met, corresponding to the optimized selection of meals each day. Since the coefficients for each meal type are linked, I am not sure how to approach this problem using programming algorithms that don't involve just brute force randomization and iterations. Could anyone help me out?