Maximizing X & Y

7 views (last 30 days)
Suraj Patil
Suraj Patil on 8 May 2021
Commented: Walter Roberson on 11 May 2021
I want to maximize the value of X & Y in the below equation. The sum of X & Y cannot exceed 260.
55 * X + 100 * Y
  4 Comments
John D'Errico
John D'Errico on 8 May 2021
Edited: John D'Errico on 8 May 2021
This is a basic linear programming problem, one typically assigned to students. So you might use linprog. Are you asking how to do what appears to be a (your) homework problem? Note that this problem has no maximum as you have posed it so far, since the problem is not sufficiently bounded. So if the sum of x+y cannot exceed 260, then you will maximize the term
55 * X + 100 * Y
by making y approach inf, as x goes to -inf. Since the coefficient of y is the larger, even though the sum will be bounded by 260, the above expression can be made arbitrarily large.
And that suggests your question is not a homework assignment, but merely an improperly formulated problem in mathematics, one with no solution.
If you then counter, oh, I forgot to add one more piece of information, that X and Y must both be non-negative values, then I would point out that then X must be zero, and Y as large as possible, therefore Y = 260. That must maximize the indicated expression.
55*0 + 100*260 = 26000.
So in any case, your problem reduces back to to something that would be assigned to a student to solve, probably using graphical methods or simple linear programming, but MATLAB is not necessary.
Suraj Patil
Suraj Patil on 11 May 2021
Dear John,
Thank you for your response and the feedback that MATLAB is not necessary and it is a Linear programmaing. But rephrasing my question so far:
I am trying to maximize 55 * X + 100 * Y >= 12,000 with the constraints that
  1. sum of X & Y cannot exceed 260
  2. X & Y must not be less than zero
  3. X & Y must be greater than zero

Sign in to comment.

Answers (1)

DGM
DGM on 8 May 2021
Edited: DGM on 8 May 2021
Okay, well that still leaves the question of what we're actually trying to maximize. Let's look at a graph of what's going on:
The contour plot is x+y, demonstrating the constraint of x+y<=260. The red overlay is 55x+100y>=12E3. All solutions to this optimization problem lie in the illustrated triangular region.
If there are no further constraints on x or y, there is no unique and finite maximizing x,y. If we're trying to maximize x+y, then the maximal sum is 260. There are an infinite number of solutions along the edge of x+y=260 from the point of intersection, extending northwest to [-inf inf].
If instead we're trying to maximize one or the other, then the answer tends to follow the same trajectory. [130 130] is a solution, just as is [1000000 -999740]. You can pick any arbitrarily large value for y and there is an x which satisfies the given constraints. If it's asserted that x >=0, then the largest satisfying value of x or y occurs for x at the point of intersection.
I mentioned the point of intersection. If it's relevant to the actual solution, we can find it.
syms xx yy aa
e1 = -0.55*xx + aa/100;
e2 = -xx + 260;
ax = solve(e1 == e2,xx)
ay = subs(e1,xx,ax)
double(subs([ax ay],aa,12E3))
ans =
311.1111 -51.1111
Though I don't know if this is actually helpful.
  4 Comments
Suraj Patil
Suraj Patil on 11 May 2021
Dear DGM,
I think I know where you are going with the answer. Let me use a graphical representation to understand my possible set of solutions where X + Y is less than 260 and also 55x+100y >= 12000. X & Y of course reflect two real life variables for a business.
Warm regards
Walter Roberson
Walter Roberson on 11 May 2021
[X, Y] = ndgrid(linspace(eps, 260, 500));
Z = 55*X + 100*Y;
Z(X+Y > 260) = nan;
Z(Z < 12000) = nan;
surf(X, Y, Z, 'edgecolor', 'none')
xlabel('X'); ylabel('Y'); zlabel('Z')
So the maximum is where X is as close as possible to 0 and Y = 260 - X .
Which makes sense, since Y is weighted nearly twice as highly as X is in the sum, so you want as much Y as you can get, at the expense of X.

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!