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 supplythe gradient in the objective function and set the GradObj option to 'on'.FMINCON will use the active-set algorithm instead. For information onapplicable 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!
Best Answer