Why option for fmincon is not working ?

11 ビュー (過去 30 日間)
HN
HN 2020 年 11 月 6 日
コメント済み: HN 2020 年 11 月 6 日
I defined the option as follows and it is not working. I tried many other options as well. Could anyone gives some idea ? Thanks
options = optimoptions('fmincon','Algorithm','interior-point','Display','iter-detailed',...
'MaxFunctionEvaluation',100000,'MaxIterations',2000,'FunctionTolerance',1e-10);
A=[]; b =[]; Aeq =[]; beq =[]; %x is vector
[V,fval,exitflag,output,lambda,grad,hessian] = fmincon(fun,x,A,b,Aeq,beq,LB,UB,options)
  2 件のコメント
Steven Lord
Steven Lord 2020 年 11 月 6 日
What does "not working" mean?
  • Did the code throw an error? If so what is the full and exact text of the error message (all the text displayed in red)? If you also received warning messages show all the warning text displayed in orange as well.
  • Did the code give you a different answer than you expected? If so show the answer you received and the answer you expected and explain why you believe the answer you expected is the correct answer.
  • Did MATLAB crash? If so please find the crash log file and send it to Technical Support for investigation.
  • Did something else unexpected happen? If so, what happened?
HN
HN 2020 年 11 月 6 日
Sorry for misleading Steven Lord . Here is the error message I got. The problem is related to my definition not with Matlab. Thanks
Error using optimfcnchk (line 99)
NONLCON must be a function.
Error in fmincon (line 437)
confcn = optimfcnchk(NONLCON,'fmincon',length(varargin),funValCheck,flags.gradconst,false,true);
Error in Main_Opt (line 30)
[V,fval,exitflag,output,lambda,grad,hessian] = fmincon(fun,x,[],[],[],[],LB,UB,options)

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

採用された回答

HN
HN 2020 年 11 月 6 日
I got it why. The nonlcon argument has been skipped.
[V,fval,exitflag,output,lambda,grad,hessian] = fmincon(fun,x,[],[],[],[],LB,UB, [],options);
Thanks

その他の回答 (1 件)

Steven Lord
Steven Lord 2020 年 11 月 6 日
If you want to provide an options structure to fmincon you must provide all the input arguments that precede it. While you've passed in fun, x, A, b, Aeq, beq (these four as empty matrices), LB, and UB you haven't passed in nonlcon which is the nonlinear constraint function. The documentation page for fmincon provides this advice: "If there are no nonlinear inequality or equality constraints, set nonlcon = []."
  1 件のコメント
HN
HN 2020 年 11 月 6 日
Thank you Steven Lord .

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

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by