Non-existent fields in optimValues

조회 수: 3 (최근 30일)
Hau Kit Yong
Hau Kit Yong 2018년 9월 4일
답변: Steven Lord 2018년 9월 4일
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

답변 (1개)

Steven Lord
Steven Lord 2018년 9월 4일
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.

카테고리

Help CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by