Why option for fmincon is not working ?

5 次查看(过去 30 天)
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 = []."

类别

Help CenterFile 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!

Translated by