nlopt icon indicating copy to clipboard operation
nlopt copied to clipboard

SLSQP vs MMA

Open nicolapiccinelli opened this issue 5 years ago • 5 comments

Hi, I'm trying to use SLSQP to solve an MPC problem with Matlab, but without any luck. So I've tried to run the example that can be found here NLopt_Tutorial and for SLSQP I'm obtaining very strange results. I put here a comparison of the outcome of the optimization:

MMA nlopt_optimize eval 92: 0.544331 xopt = 0.3333 0.2963 cost = 0.5443 retcode = 4

SLSQP nlopt_optimize eval 43: 0.544331 xopt = 0.5078 4.7625 cost = 2.1823 retcode = 3

The parameters used are the same for both the optimizers:

opt.ftol_rel = 1e-10
opt.ftol_abs = 1e-10
opt.xtol_rel = 1e-10
opt.maxeval = 400

It's normal that SLSQP isn't able to give the same optimal variables and cost even if it converges to the same evaluation value?

nicolapiccinelli avatar Feb 05 '20 11:02 nicolapiccinelli

what do you mean by "same evaluation value" ?

jschueller avatar Feb 05 '20 11:02 jschueller

what do you mean by "same evaluation value" ?

I mean the value print in the console when the verbose mode is activated, they are both to 0.544331

nicolapiccinelli avatar Feb 05 '20 11:02 nicolapiccinelli

what do you mean by "same evaluation value" ?

I mean the value print in the console when the verbose mode is activated, they are both to 0.544331

I've added also the print of the vector x and at each iteration, it doesn't coincide with the value returned by nlopt_optimize.

nicolapiccinelli avatar Feb 05 '20 11:02 nicolapiccinelli

yes, this typically happens with some algorithms that have an inner loop to compute some direction and only check the cost enhancement from the points evaluated in the main loop.

jschueller avatar Feb 05 '20 13:02 jschueller

yes, this typically happens with some algorithms that have an inner loop to compute some direction and only check the cost enhancement from the points evaluated in the main loop.

There is something strange, now I've started the optimization again and I'm able to get in the output the same values of MMA. I don't understand why, but, what I see in the code is that even if ftol is reached the main loop (do-while with the switch-case) makes a further slsqp iteration. Is this correct?

nicolapiccinelli avatar Feb 05 '20 13:02 nicolapiccinelli