Non-existent fields in optimValues
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Steven Lord
el 4 de Sept. de 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 comentarios
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!