How to optimize an objective function with repect to two variables using fmincon?

6 views (last 30 days)
I want to maximize this objective function with respect to a and b using fmincon.
subjected to 3<=a ; b<=8

Accepted Answer

Star Strider
Star Strider on 8 May 2022
The general approach to maximising a function is to negate it so the minimum that the optimisation functions find is actually the function maximum.
f = @(a,b) (-90*a-90*b+540);
[ab,fv] = fmincon(@(ab) -f(ab(1),ab(2)), rand(2,1), [],[],[],[],[3 -Inf],[inf 8]);
Problem appears unbounded. fmincon stopped because the objective function value is less than the value of the objective function limit and constraints are satisfied to within the value of the constraint tolerance.
fprintf('\n\ta = %23.15E\n\tb = %23.15E\n\tfv = %23.15E\n\n',ab,fv)
a = 1.792516492505127E+12 b = -1.880962606528041E+18 fv = -1.692864732610394E+20
The problem appears to not be well-posed.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by