Maximization problem in MATLAB Optimisation Toolbox

Basically by default MATLAB OPtimisation Toolbox fminocon and ga algorithms minimise the objective function.
To maximise normally we use duality prinicple i.e., "multiplying objective function by -1". Will it work same here?
Becasue I have tried doing this and I couldnt get proper results. Is there any solution for this?
Thank you in advance!!

 Accepted Answer

Will it work same here?
Yes. Example:
fun=@(x) -x^2; %maximize this
xmax=fmincon( @(x) -fun(x) , 1)
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
xmax = -7.4506e-09
It worked!!
But another principal is that you need a good initial guess, when the problem is non-convex. That might be why it "doesn't work" for you.

7 Comments

Thank you @Matt J
Yes ...the problem is non-convex ...and there are many constraints ...any idea what to do in such conditions?
"fmincon" and "ga" are the only solvers that MATLAB offers. So why do you think you have a choice ?
@Vivek you can try one of the solvers in the Global Optimization Toolbox. In any case, that is a separate issue from your posted question. The problem of getting stuck in local minima/maxima is independent of whether you are minimizing f or -f.
@Torsten yes but by default they do minimise the function. I want to maximise the function which is done by using duality principle. This isnt working properly for my problem.
yes but by default they do minimise the function. I want to maximise the function which is done by using duality principle. This isnt working properly for my problem.
According to your other questions in the forum, you seem to have problems formulating your objective function and your constraints. You should first work on your code before asking for different solvers.
Yes it did work properly. Constraints and Objective function is formulated properly. Everything is working fine now.
The problem was because of the variable bounds in which constraints had to be satisfied. I was expecting it to converge and give positive exit flag. But the optimum point wasn't in that region where it had to satisfy all constraints also. I got to know that all constraints can't be satisfied at same time because the final region becomes infeasible and the exit flag shows up to be negative eventhough was single constraint isn't satisfied.
Thank you @Torsten and @Matt J for the help and support.
You're welcome, but please Accept-click the answer to indicate that question is resolved.

Sign in to comment.

More Answers (0)

Products

Release

R2022a

Asked:

on 2 Feb 2023

Commented:

on 5 Feb 2023

Community Treasure Hunt

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

Start Hunting!