Hessian only returns vector instead of matrix in fmincon
1 view (last 30 days)
I am using the following code to get Hessian for a three parameter function. It should be a 3*3 matrix. But instead I get a 3*1 vector. Do you know why?
A = [-1 -2 -2; ...
1 2 2];
b = [0;72];
options = optimoptions('fmincon','Algorithm','active-set','Hessian','on');
[xn,fval,exitflag,output,grad,hessian] = fmincon(@(x) -x(1) * x(2) * x(3),x0,A,b,,,,,,options)
and the result get for Hessian is
Alan Weiss on 2 Dec 2014
Take a look at the fmincon documentation. You will see that the correct function call is
[x,fval,exitflag,output,lambda,grad,hessian] = fmincon(...)
In other words, what you call hessian is, in fact, the grad output. You forgot the lambda argument.
You should also take a look at the documentation of the fmincon Hessian to see what the output means.
MATLAB mathematical toolbox documentation