Determining Cheapest Food Combinations (Seems like ILP problem, but also not)

In summary, the problem is to find the cheapest way to get full, given the options of Fish and Bread with different calorie and price values. After exploring linear programming as a possible solution, it is discovered that the optimal result is always all of just one item, which may not be desirable. Brute force method is then used to find all possible combinations of Fish and Bread that give exactly 10 calories and the minimum cost. However, this method may not be feasible for larger number of food items. Other approaches, such as imposing constraints, are suggested but may not be flexible enough. Finally, it is mentioned that the simplex method may not be suitable for this problem as it deals with integer numbers of servings.
  • #1
Martin III
4
0
This is a problem I created for myself, and I've been thinking about for a while and would like some other opinions on the matter. I'm using simple numbers just for example.

The problem:
Suppose you are hungry, and you need to eat at least 10 calories worth of food to get full, and you'd like to not go very much over that (you don't want a tummy-ache!). The foods available to you are Fish and Bread. A serving of fish has 2 calories, and a serving of bread has 4 calories. However, a serving of fish costs $1 and a serving of bread costs $5. What are the cheapest ways to get full?

The solutions:
Let f be the number of servings of fish and b be the number of servings of bread. Also, let c be total calories and p be the total price.

Now we have that:
[tex]2f + 4b \geq 10[/tex]

[tex]f + 5b = p[/tex]

At first this seems a lot like a linear programming problem, but if you actually work it out you'll soon see that you won't find the desired results (I won't fill up space with tableaus and pivots and whatnot). And that should be obvious, because one of the items will always have a lower price to calorie ratio: the optimum result will be all of just one item.

The problem is that the desired answer is one that doesn't go much over the target number of calories, and choosing all of one item will, in most cases, go over. BUT if the problem is changed to strictly equal to, there won't always be answer given certain parameters. And the entire time, we're trying to minimize cost, but also want to allow options (all of one item is boring!)

My solution, which illustrates the problem with treating it as an LP problem, is to "brute-force" the result.
[tex]
\begin{tabular}{ | c | c | c | c | }
\hline
t & b & c (2f+4b) & p (f+5b) \\
\hline
0 & 3 & 12 & 15 \\
1 & 2 & 10 & 11 \\
2 & 2 & 12 & 12 \\
3 & 1 & 10 & 8 \\
4 & 1 & 12 & 9 \\
5 & 0 & 10 & 5 \\
\hline
\end{tabular}
[/tex]

So in this case, solving the corresponding LP problem would've given 5 servings of fish and no bread, giving exactly 10 calories and only 5 dollars, the cheapest combination.

But we also see that you get exactly 10 calories with 1 fish and 2 bread, and 3 fish and 1 bread. And I would want these results as a hungry person, because even though I'm trying to be cheap, perhaps I wouldn't mind paying $3 more to get some variety in my diet.

Is there a better way to calculate these combinations than by brute-force? I feel like there should be but have so far come up dry. I would like a method that could accommodate an arbitrary number of food items.
 
Mathematics news on Phys.org
  • #2
Actually, there is a simpler way to figure it out: for fish, $1/2 = 50 cents per calorie, for bread, $5/4 = $1.25 per calorie. The fish is cheaper.
 
  • #3
Indeed, here it is quite easy to solve. I once had the same idea but for
protein, carbohydrate, fat and sugar intake. Or even the same for vitamins. Maybe Martin is interested in doing that? :)

Btw, did you know that all kinds of cabbage are by far the cheapest providers of vitamin C? :D
 
  • #4
Martin III said:
But we also see that you get exactly 10 calories with 1 fish and 2 bread, and 3 fish and 1 bread. And I would want these results as a hungry person, because even though I'm trying to be cheap, perhaps I wouldn't mind paying $3 more to get some variety in my diet.
Well, you could always impose the constraint that you must order at least one serving of each item.

In fact, problems similar to this one involved imposing several constraints and then figuring out how to either minimize or maximize some linear function (like cost) of the variables involved. For example, the list of constraints might look something like this:

1. At least 1 of each item.
2. Total Calories ≥ Cmin
3. Total fat ≤ Fmax
4. Total cholesterol ≤ Chmax
5. etc.

If you're new to linear optimization problems like this, here's a reasonable place to get started:
http://en.wikipedia.org/wiki/Simplex_algorithm
 
  • #5
Actually, there is a simpler way to figure it out: for fish, $1/2 = 50 cents per calorie, for bread, $5/4 = $1.25 per calorie. The fish is cheaper.
Yes, that will result in answers that I don't want. Let me refer back to my original post to answer you:
And that should be obvious, because one of the items will always have a lower price to calorie ratio: the optimum result will be all of just one item.

Well, you could always impose the constraint that you must order at least one serving of each item.

In fact, problems similar to this one involved imposing several constraints and then figuring out how to either minimize or maximize some linear function (like cost) of the variables involved. For example, the list of constraints might look something like this:

1. At least 1 of each item.
2. Total Calories ≥ Cmin
3. Total fat ≤ Fmax
4. Total cholesterol ≤ Chmax
5. etc.

If you're new to linear optimization problems like this, here's a reasonable place to get started:
http://en.wikipedia.org/wiki/Simplex_algorithm

I thought of this, but it doesn't feel quite flexible enough. For one, I still might want the option of all of one food item, and two, I might want options with more than one required. By adding more restraints I cut out sections of results that I might be interested in.

As an aside, I'm not new to the simplex method :) Those were the tableaus and pivots to which I referred in my original post. The simplex method isn't, however, quite what I need for this problem, because I'm looking for integer numbers of servings. I could use it to get reasonable estimates, of course. (http://en.wikipedia.org/wiki/Integer_linear_programming#Integer_unknowns)

My method (which I realize I didn't really describe, just showed the results) is to set all but one of the foods to 0 servings, and find out the minimum number of servings of the nonzero food that makes the calories greater than the target calorie count. Then I subtract one from that, and increment one of the other foods, and so and and so forth, until I find all of the good options.

I'm thinking about this from a computational perspective; if I calculated it with some linear programming library I'll get a lot of library overhead (restricting to integers is especially computationally intensive). If I use my brute-force method, I'll get superior results but it doesn't scale well. I haven't actually written any software or algorithms, but I'd imagine it's O(n!) because of its combinatoric nature.

If it wasn't obvious, I'm interested in implementing this in software, so it's to my advantage to find a more efficient way. I think it could be a really interesting project (even if no one thinks it's worth using). Anyone have other ideas?
 

FAQ: Determining Cheapest Food Combinations (Seems like ILP problem, but also not)

1. What is an ILP problem?

An ILP (Integer Linear Programming) problem is a mathematical optimization problem that involves finding the best possible solution to a given set of constraints and objectives, where the decision variables are required to be integers. In the context of determining cheapest food combinations, an ILP problem can be used to find the most cost-effective combination of food items to meet a specific set of nutritional requirements.

2. How is determining cheapest food combinations different from a traditional ILP problem?

Determining cheapest food combinations involves finding the most cost-effective combination of food items while also considering factors such as nutritional requirements and dietary restrictions. This adds an additional layer of complexity to the traditional ILP problem, which only focuses on optimizing a single objective.

3. What factors are typically considered when determining cheapest food combinations?

When determining cheapest food combinations, factors such as the cost of food items, nutritional content (e.g. calories, protein, etc.), dietary restrictions (e.g. allergies, dietary preferences), and serving sizes are typically taken into consideration. These factors are used to create constraints and objectives for the ILP problem.

4. Can determining cheapest food combinations be done manually?

While it is possible to manually determine the cheapest food combinations by considering all the relevant factors, it can be a time-consuming and complex process. This is where ILP and other optimization techniques can be useful in finding the most cost-effective solution in a more efficient manner.

5. How accurate are the results of determining cheapest food combinations using ILP?

The accuracy of the results obtained from using ILP to determine cheapest food combinations depends on the quality of the input data and the constraints and objectives set for the problem. With proper data and constraints, ILP can provide highly accurate and optimal solutions.

Similar threads

Back
Top