MATLAB: Linprog to maximise a function

linprog maximize code

Hello. I think, that I did a mistake in my program for maximize x8. I have a function: fx= -0.818×1 + 0.241×2 + 4.737×3 + 0.2×4 + 0.483×5 – 0.02×6 + 0.06×7 I made restriction for my resulting variable: it cant be more, than 100. And i have some other resrictions, which you can see in my cod. _________________________________________________________________
C = [-0.818 0.241 4.737 0.2 0.483 -0.02 0.06];
D = [-0.818 0.241 4.737 0.2 0.483 -0.02 0.06];
B = [100];
% Aeq = [1 -1 1];
% beq = [0];
lb = [22 52 3.5 12 105 300 800];
ub = [40 80 5.9 22 150 700 1200];
f = C;
A = D;
b = B;
[x,fval] = linprog(-f,A,b,[],[],lb,ub);
x
fval
____________________________________________________________________________
I got the result fval = -100 – is good, but when i change my restrictions – result still 100, only x changes. Maybe it's good, but I don't know it, or it's a code mistake.

Best Answer

You are maximizing f(x), subject to the constraint that f(x) cannot be larger than 100.
There are far too few constraints on x, except that the vector must lie with a rather large hyper-rectangle, and that f(x) must not exceed 100. So you can have a huge (infinite) variety of solutions, all of which will yield exactly 100 for f(x).
Change the bounds, who cares? You can still get f(x) == 100 in a different way. Were you to change the bounds on x by too much, eventually you can end up with a system with no solution at all.
Why is this even remotely surprising? It seems to have worked.