fmincon function help answer does not converge

8 Ansichten (letzte 30 Tage)
pingle
pingle am 4 Mai 2013
We have a group project that need to price series caps using two different method: a theoretical one and a practical one.
We want to set parameters to minimize the square errors.
In the main script, we have set an initial set of parameters.
But when we run the code, since the function we need to minimize is non linear and we are not able to calculate a gradient, the parameter just does not converge.
The result looks like follows:
Warning: To use the default trust-region-reflective algorithm you must supply
the gradient in the objective function and set the GradObj option to 'on'.
FMINCON will use the active-set algorithm instead. For information on
applicable algorithms, see Choosing the Algorithm in the documentation.
> In fmincon at 492
In main at 36
Solver stopped prematurely.
fmincon stopped because it exceeded the function evaluation limit,
options.MaxFunEvals = 300 (the default value).
x =
NaN
NaN
NaN
our main code is this:
r_guess=0.003;
sigma_guess=0.02;
k_guess=0.3215;
x0=[r_guess;sigma_guess;k_guess];
%options.MaxIter = 1000;
%options.MaxFunEvals = 1000000000000;
[x]=fmincon(@HW_Cap_Optimizer,x0,[ ] ,[ ] ,[ ],[ ],[0;0;0])
%%%%%%%%%%%%%%%%%%%%%%%%%%%done
HW_Cap_Optimizer function calls a bunch of other functions which are non linear.
Really need help from you guys, thank you!

Akzeptierte Antwort

Shashank Prasanna
Shashank Prasanna am 4 Mai 2013
1) Is your objective function sum of squares? if it is then LSQNONLIN will be a better suited solver.
2) I see that you are setting MaxFunEvals to be a large number, but I don't see it being passed to FMINCON. Take a look at the doc of fmincon you have to pass the options as follows:
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)
3) If none of those work for you, you may have to share your code with us to look through further. But please make sure you try the above and other different options as well. This is an excellent doc page that talks about what to do When the solver fails
  1 Kommentar
pingle
pingle am 4 Mai 2013
Hi, thank you for the quick reply!
1) i have tried the LSQNONLIN and it works great! But I do find a little problem because I need to be cautious about setting the upper and lower boundary, since locally converges so soon.
2) about the MaxFunEvals, the reason I do not include it is because it take forever to converge and I decided to drop it.
Thank you a lot!!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by