Supplying 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. Although my problem has linear constraints and upper and lower bounds, 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?

P.S. I am following the instructions given here which works until I deliberately replace the nonlinear constraint with some random linear constraints and then I will have the same problem again (empty lambda structure).


lambda is not a direct value, but a structure in which you can access many information. Matlab is telling you that there are 2 values currently in lambda. Choose what you need by


Here is an example of using user-supplied hessian

Need Your Help

tinyMCE's iframe or table height is not resizing properly

javascript jquery jquery-ui tinymce

I have successfully added a tinyMCE editor to my web-app so that users can make notes. I have the textarea it replaces inside a div, so that the div can resize with the page, and the textarea can a...

Getting the errors for code in unopened .aspx pages visual-studio compiler-errors

Is there a way to check for errors in unopened *.ASPX pages. For example, if you change the name of a function Visual Studio will catch the error on the page and list it in the "Error List" only i...