Non-existent fields in optimValues
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am writing an output function to plot out certain parameters during an optimization. I am using fmincon with the SQP algorithm and the optimization problem involves nonlinear constraints. I referred to the optimValue fields as documented in the attached link: optimValue fields
I am able to extract most of the fields except directionalderivative and lambda, which when called return a 'Reference to non-existent field' error. My code is as follows:
function stop = myoutput(x,optimvalues,state)
stop = false;
if isequal(state,'iter')
history.iteration = [history.iteration;optimvalues.iteration];
history.x = [history.x;x'];
history.fval = [history.fval;optimvalues.fval];
history.funccount = [history.funccount;optimvalues.funccount];
history.gradient = [history.gradient;optimvalues.gradient'];
history.stepsize = [history.stepsize;optimvalues.stepsize];
history.directionalderivative = [history.directionalderivative;optimvalues.directionalderivative]; % ERROR
history.lambda = [history.lambda;optimvalues.lambda.ineqnonlin]; % ERROR
history.firstorderopt = [history.firstorderopt;optimvalues.firstorderopt];
history.constrviolation = [history.constrviolation;optimvalues.constrviolation];
end
end
0 commentaires
Réponses (1)
Steven Lord
le 4 Sep 2018
Look at the "Returned by Functions" column of the table on that page you linked, specifically the values in that column for the directionalderivative and lambda rows. The lambda field is not passed into the output function by fmincon at all, and the directionalderivative is passed into the output function by fmincon only if you're using the active-set algorithm. Since you're using SQP, neither field gets passed into the output function.
0 commentaires
Voir également
Catégories
En savoir plus sur Nonlinear Optimization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!