Non-existent fields in optimValues
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Nonlinear Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!