フィルターのクリア

"Too many output arguments" error while working with the fmincon solver inside the optimization tool.

3 ビュー (過去 30 日間)
Explenation after the code.
% Set nondefault solver options
options2 = optimoptions('fmincon','PlotFcn','optimplotfvalconstr');
% Solve
[solution,objectiveValue] = fmincon(@objectiveFcn,w,[],[],[],[],[],[],...
@objectiveFcn,options2);
% Clear variables
clearvars options2
These are at default.
function f = objectiveFcn(optimInput)
x = optimInput(1:8124);
y = optimInput(8125:end);
f = -sum(1./(1+exp(-x))*1./(1+exp(-y')),'all');
end
function [c,ceq] = constraintFcn(optimInput)
x = optimInput(1:8124);
y = optimInput(8125:end);
c = sum(1./(1+exp(-x))*1./(1+exp(-y')).*(1.-aa),'all') - 0.1;
ceq = [];
end
vector w is passed for optimInput which is a 8243*1 vector. aa variable inside the constraint is a 8124*119 matrix. I am getting the error too many output arguments. How should I model something like this?
  2 件のコメント
Jan
Jan 2021 年 9 月 11 日
Please post the complete error message, not just a part of it. Then the reades can see, where the problem occurs. We cannot run your code because w is missing.
Yagiz Dereboy
Yagiz Dereboy 2021 年 9 月 12 日
Oh ok thanks for the heads up. But may I ask how could I have shared a variable?

サインインしてコメントする。

採用された回答

Jan
Jan 2021 年 9 月 11 日
A bold guess:
[solution,objectiveValue] = fmincon(@objectiveFcn,w,[],[],[],[],[],[],...
@objectiveFcn,options2);
% ^^^^^^^^^^^^^ This should be "constraintFcn" ?!

その他の回答 (0 件)

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by