fmincon do not work with "objective gradient and hessian" only

I have a optimization problem with nonlinear constraints. Because my constraints are realy big I dont want to deal with gradient and hessian of "constraints". But my objective function is small and I construct objective function with gradient and hessian. also set up below option:
options = optimoptions(options,'SpecifyObjectiveGradient', true,'SpecifyConstraintGradient', false);
[x12,fval2] = fmincon(ValAndGrad,x00,[],[],[],[],A,B,@confun,options);
but I get error:
Error using fmincon (line 795) Must set SpecifyObjectiveGradient and (if the problem has nonlinear constraints) SpecifyConstraintGradient to true in order to use option HessianFcn.
Gradient and hessian of only objective is not working. If Hessian is used in objective function, must it be used in constraint function also??

Answers (1)

Sorry, as the error message states, to use a Hessian, you must pass the constraint gradient and Hessian, too.
It does you no good to pass the objective gradient and Hessian alone, because the Hessian that the solver needs is the Hessian of the Lagrangian. See Direct Step in the interior-point algorithm description.
Alan Weiss
MATLAB mathematical toolbox documentation

Asked:

on 23 May 2018

Answered:

on 23 May 2018

Community Treasure Hunt

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

Start Hunting!