How do I include a user specified hessian function for fmincon?

6 次查看(过去 30 天)
I am working on an optimisation code and I have a Hessian function I wish fmincon to use. I'm currently having trouble trying to get the correct command to include the Hessian. I am currently using:
options = optimoptions('fmincon','SpecifyObjectiveGradient',true,'HessFcn','objective','Display','iter','OutputFcn',@outfun);
For which I get the following error:
> In Temperature_inverse_problem (line 51)
Error using feval
Undefined function or variable 'objective'.
Error in computeHessian
Error in barrier
Error in fmincon (line 813)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in Temperature_inverse_problem (line 53)
X=fmincon(t_fun,X_old,A,b,Aeq,beq,LB,UB,[],options);
The code for my objective function is:
function [Y,G,H] = Boundary_temperature(T_data,t,R,X,Joule)
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
diff=battery_temp(t,R,X,Joule)-T_data;
integrand=0.5*(diff.^2);
Y=trapz(t,integrand);
G=grad_F(T_data,t,R,X,Joule);
Temp=cylinder_temp(t,R,X,Joule);
T=Temp(:,end);
T_theta=theta_grad(t,R,X,Joule);
T_kappa=kappa_grad(t,R,X,Joule);
T_hop=h_grad(t,R,X,Joule);
T_t=T_theta(:,end);
T_k=T_kappa(:,end);
T_h=T_hop(:,end);
H=Hessian_F(T_data,t,R,X,Joule,T,T_t,T_k,T_h);
end
Here Y is the objective function, G is the gradient and H is the Hessian. I've trolled the internet and I've not found anything which works. What am I doing wrong?

回答(1 个)

Alan Weiss
Alan Weiss 2020-4-24
If you read the documentation for Including Gradients and Hessians, you will see that the fmincon 'interior-point' algorithm does not allow you to use 'HessFcn'='objective'. Instead, you must write a Hessian function that is the Hessian of the Lagrangian. See Hessian for fmincon interior-point algorithm.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 个评论
Matthew Hunt
Matthew Hunt 2020-5-11
The documentation for matlab typically is a mess for things like this. Some of it is out of date and you have to see other people's code to figure out what to do.
I have since found some code which works.
Alan Weiss
Alan Weiss 2020-5-11
I try very hard to keep the documentation clear, correct, and concise. If you ever find anything incorrect or unclear, please let me know either by emailing me directly or filing a bug report (we consider documentation errors to be bugs).
Alan Weiss
MATLAB mathematical toolbox documentation

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by