Cannot supply fmincon with Hessian

I am trying to help fmincon to converge faster by supplying gradient vector and Hessian matrix. I am using interior-point algorithm and I realize that in such case, I have to supply Hessian using a call to another function which is assigned to HessFcn of my OPTIOINS. I also realize that the Hessian for fmincon is the second derivatives of the Lagrangian as described here in equation 14-1. I am supposed to use the following function definition to have access to my fitting parameters and lambda while calculating the hessian
hessian = hessianfcn(x, lambda)
From this point on I have some difficulties figuring out the procedure. First of all how should I calculate the second and third terms in equation 14-1? Also, although my problem is constrained, lambda structure is empty i.e. whenever I try to access it from hessianfcn, it returns:
lambda =
eqnonlin: [0x1 double]
ineqnonlin: [0x1 double]
Any idea how to fix this problem and also how to calculate second and third terms in equation 14-1?

 Accepted Answer

Matt J
Matt J on 9 Mar 2015
Edited: Matt J on 9 Mar 2015
The second and third terms sum over the Hessians of your constraints (weighted by the corresponding lambda). Essentially, you need to be computing the Hessian of your ceq(i) and c(i) as well as the Hessian of your objective, f, inside the HessFcn. Then you need to apply the lambda(i) as weights to all those Hessians and sum them all up.
Why the lambda structure is empty is not something we can determine without seeing code. My guess is that you defined a nonlcon function for your nonlinear constraints, but neglected to actually pass it to fmincon. Or, your input arguments to fmincon are not in the proper sequence.

5 Comments

Thanks for your reply. I think now I now how to compute it, but I still have the second problem. Are you telling me that my problem has to have nonlinear constraint? Well it only has linear inequality constraints. I have defined nonlinear constraints to be an empty vector and passed it to fmincon as follows
NONLCON = [];
[X,fval,exitflag,output,lambda]=fmincon(@(ftprm)objFunc(ftprm,[otherInputs]),[initialValues],A,B,Aeq,Beq,LB,UB,NONLCON,OPTIONS)
Now does it mean that I cannot supply hessian? I also wanted to add something that might help here. After fmincon converges, it actually returns a valid structure to the lambda variable (last variable on the left hand side). Finally, I believe my input arguments to fmincon are actually in the right order since if I set "hessian" to off, it will be able to converge to the correct answer. FYI, I also use the "user-defined" gradient for fmincon.
If you have no nonlinear constraints then it is natural that lambda is empty for those constraints. Just return the hessian of the objective.
So you suggest me to ignore second and third terms in the equation although my problem is constrained?
Matt J
Matt J on 11 Mar 2015
Edited: Matt J on 11 Mar 2015
Yes. All linear constraints have a Hessian of zero. Therefore, if you have no nonlinear constraints, only the objective function contributes non-trivially to the total Hessian of the Lagrangian.
Thanks very much!

Sign in to comment.

More Answers (0)

Asked:

on 9 Mar 2015

Edited:

on 11 Mar 2015

Community Treasure Hunt

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

Start Hunting!