フィルターのクリア

Non-existent fields in optimValues

1 回表示 (過去 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 Center および File ExchangeNonlinear Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by