Solver based optimization passing extra parameters
古いコメントを表示
My solver function is giving an error: Unrecognized function or variable 'aa'.
c = sum(1./(1+exp(-x))*1./(1+exp(-y')).*(1.-aa),'all') - 0.1;
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
Caused by:
Failure in initial nonlinear constraint function evaluation. FMINCON cannot continue.
Objective function is:
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
I am using the solver based approach. Can you please tell me how can I pass the 'aa' variable inside the constraint function. I have seen the mathworks page but I couldn't implement it to my case. Can anyone please show me how can I do it for the solver based approach for my case.
回答 (1 件)
nonlcon=@(x)constraintFcn(x,aa)
4 件のコメント
Yagiz Dereboy
2021 年 9 月 17 日
You should be writing this:
aa=something;
nonlcon=@(x)constraintFcn(x,aa);
[solution,objectiveValue] = fmincon(@objectiveFcn,w,[],[],[],[],[],[],...
nonlcon,options4);
Yagiz Dereboy
2021 年 9 月 17 日
Matt J
2021 年 9 月 17 日
If you right-click on the task, you can convert it to editable code:

カテゴリ
ヘルプ センター および File Exchange で Solver Outputs and Iterative Display についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

