I have to solve a non-linear optimization problem repeatedly with different values. Hence, inside the calculation of the hessian, a model is evaluated. Here is a pseudocode example:
z = ones(Elements,1)*i;
hess = @(x,lambda) analyticHessian(x,lambda,z);
options = optimoptions('fmincon','Algorithm','interior-point','SpecifyConstraintGradient',true,'SpecifyObjectiveGradient',true,'HessianFcn',hess);
x = fmincon(costfun,x_0,,,,,,,@constraints,options);
Inside the analyticHessian-Function, the model is evaluated with the different values of z. To account that, I have to set the options again in every iteration. I've tried to only set them once but then the values of z, and therefore the model, doesn't get evaluated with the new values. Is there any possibility to set the options only once to save time?