# Giving options more or less weight

Printable View

• 09-26-2009
kermit
Giving options more or less weight
I am working on a program that will decide which meals will be prepared & served for the week. At first I thought it would be really easy - have a list of things I like to eat, and let the computer randomly pick a certain number of them - Voila! Instant menu plan. But then I was reminded that some meals are OK, but not every week - perhaps every third week or so. So then, it seems to me that my program has to give more weight to some options rather than others. My problem is that I have no idea of how to implement this, and worse yet, I don't even know the terminology to do a decent search for what I am after. it seems to me that the answer might lie with those who are well versed in game programming, hence why I am posting here. If anyone would care to set me on the right track, I would appreciate it.
• 09-26-2009
VirtualAce
You might want to look at weighted average calculations. For instance a Runge-Kutta integrator for a physics system takes a weighted average of 4 distinct points to arrive at the final answer. I'm sure mathworld has a lot of information on computing weighted averages.

Runge-kutta computes k1,k2,k3 and k4. Then it does: final = 1/6 * ((k1 + (2 * k2) + (2* k3) + k4))

One thing is for certain is you will have to assign coefficients to each meal or meal ingredient in order to calculate the end result. You will need some type of formula to come up with a good coefficient that might take into account the number of calories, various cholesterol types, sugars, etc.

A first glance nieve approach is to find out how much a human needs of each one of the key categories you are using and produce ingredient coefficients based on that. You can then either average the coeffs. or do a weighted average on them to arrive at the final coefficient for the ingredient or meal. Then it's a simple matter of having the computer do some math to make sure the final coefficient for the meal is near some number.

I recommend you use normalized data to make the math simple.
• 09-26-2009
abachler
use a neural network to decide, and train it based on how much you liked its choice, and a history of the meals it has served you over perhaps the last year, so it learns to serve holiday appropriate meals during holidays, but not necessarily at other times of the year.
• 09-26-2009
kermit
Quote:

Originally Posted by Bubba
You might want to look at weighted average calculations. For instance a Runge-Kutta integrator for a physics system takes a weighted average of 4 distinct points to arrive at the final answer. I'm sure mathworld has a lot of information on computing weighted averages.

Runge-kutta computes k1,k2,k3 and k4. Then it does: final = 1/6 * ((k1 + (2 * k2) + (2* k3) + k4))

One thing is for certain is you will have to assign coefficients to each meal or meal ingredient in order to calculate the end result. You will need some type of formula to come up with a good coefficient that might take into account the number of calories, various cholesterol types, sugars, etc.

A first glance nieve approach is to find out how much a human needs of each one of the key categories you are using and produce ingredient coefficients based on that. You can then either average the coeffs. or do a weighted average on them to arrive at the final coefficient for the ingredient or meal. Then it's a simple matter of having the computer do some math to make sure the final coefficient for the meal is near some number.

I recommend you use normalized data to make the math simple.

Thanks for the info. Now I have an idea of where to begin.
• 09-26-2009
Sebastiani
I hope your algorithm takes into account the proper balance of flavors. :p
• 09-26-2009
abachler
Quote:

Originally Posted by Sebastiani
I hope your algorithm takes into account the proper balance of flavors. :p

And balances nutritional requirements.