MATLAB: Optimization giving unexpected results

optimization

Hi, I'm trying to optimize a function which I know the results but matlab is giving me weird results. Here's what I'm trying to do:
max: f(x)= 1815×1+379×2
subject to: -1475×1-112013×2 >= -700000
x1,,x2<=80
x1,x2>=0
How would you do it?

Best Answer

Hi Gimpy
Since linprog finds the minimum for the function f(x) but the problem you are trying to solve is a maximization problem, I suggest you change f = [1815;379] to f = -[1815;379]. That is to say, you solve the following problem instead
min: f(x)= - 1815x1 -379x2
subject to: -1475x1-112013x2 >= -700000
x1,,x2<=80
x1,x2>=0
There will only be a sign difference on the objective function. The optimal solutions x will be the same.
-Yu