0

If we are given an equation say 3x + 2y <= 10, we want to find the value of x and y such that x + y = maximum and 10 - 3x - 2y is minimized. How can this be done? I am thinking of it as a dynamic programming problem ! but not sure if I am right.

In the above x = 0 and y = 5 will be the answer.

Thanks.

Varun Sharma
  • 2,591
  • 8
  • 45
  • 63

1 Answers1

5

There is an immense mathematical literature on this problem. If the equations are all linear, then the answer, if there is a unique one, has to lie on a vertex of the polytope described by the constraints. Look up linear programming. The Simplex algorithm is the classical method for searching along edges of the polytope to find a vertex that satisfies the minimization.

Gene
  • 46,253
  • 4
  • 58
  • 96
  • Thanke Gene ! However, answer always exist because we are trying to minimize 10 - 3x - 2y ! 10 - 3x - 2y doesn't need to be 0. Will simplex algorithm still work? – Varun Sharma Sep 08 '12 at 02:17
  • I regret that I don't understand what you wrote. Any problem that can be formulated as a linear program can be solved by the simplex algorithm. (In degenerate cases Simplex can require exponential time. Karmarkar's algorithm is always polynomial, but implementation is trickier. And for small problems it's often slower than Simplex.) – Gene Sep 08 '12 at 02:37
  • Oh, I think I get it now. Your problem is fairly meaningless because it's over-constrained. If you have a half-space and a single minimization or maximization objective, then there is a unique answer. You present 2 objectives. They happen to have the same solution. But nearly all problems of this sort will have different ones. If you need to solve this problem in general, you will have to find a single objective, for example a weighted sum of the two (or more). In this case an example would be `x + y - 10 + 3x + 2y = 4x + 3y 10` – Gene Sep 08 '12 at 02:53
  • Actually I was able to use a greedy algorithm to solve this problem. It always gives the correct answer. Thanks for your help. – Varun Sharma Sep 10 '12 at 02:08