matlab 优化 fmincon函数 at least four input arguments. 请知道的同学帮帮忙。
答案:1 悬赏:10 手机版
解决时间 2021-04-13 07:53
- 提问者网友:骨子里的高雅
- 2021-04-13 02:05
matlab 优化 fmincon函数 at least four input arguments. 请知道的同学帮帮忙。
最佳答案
- 五星知识达人网友:荒野風
- 2021-04-13 03:42
有些语法上的小地方修改下,如下:(可以运行下)
————————————————————————
%zy2-3fun.m
function f=zy2_3fun(x)
f=x(1)^2*x(2);
%zy12-3con.m
function [c,ceq]=zy12_3con(x)
c(1)=10*x2-x(1)^3;
c(2)=6.25-x(1)^3;
c(3)=0.34*x(2)^3-x(1)^4;
ceq=[];
然后command window:
A=[];b=[];Aeq=[];beq=[];
lb=[1.7,5];
ub=[10,1];
x0=[3.684,5.0];
options=optimset('Display','iter','LargeScale','off');
[x,fval,exitflag,output,lambad]=fmincon(@(x) zy2_3fun(x),x0,A,b,Aeq,beq,lb,ub,@(x) zy12_3con(x),options)
运行结果如下:
Exiting due to infeasibility: 1 lower bound exceeds the corresponding upper bound.
x =
3.6840 5.0000
fval =
[]
exitflag =
-2
output =
algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
iterations: 0
funcCount: 0
stepsize: []
lssteplength: []
constrviolation: []
firstorderopt: []
message: 'Exiting due to infeasibility: 1 lower bound exceeds the corresponding upper bound.'
lambad =
[]
————————————————————————
exitflag=-2 指明程序退出的原因是在约束条件下,没有可行点,所以这题无解
————————————————————————
%zy2-3fun.m
function f=zy2_3fun(x)
f=x(1)^2*x(2);
%zy12-3con.m
function [c,ceq]=zy12_3con(x)
c(1)=10*x2-x(1)^3;
c(2)=6.25-x(1)^3;
c(3)=0.34*x(2)^3-x(1)^4;
ceq=[];
然后command window:
A=[];b=[];Aeq=[];beq=[];
lb=[1.7,5];
ub=[10,1];
x0=[3.684,5.0];
options=optimset('Display','iter','LargeScale','off');
[x,fval,exitflag,output,lambad]=fmincon(@(x) zy2_3fun(x),x0,A,b,Aeq,beq,lb,ub,@(x) zy12_3con(x),options)
运行结果如下:
Exiting due to infeasibility: 1 lower bound exceeds the corresponding upper bound.
x =
3.6840 5.0000
fval =
[]
exitflag =
-2
output =
algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
iterations: 0
funcCount: 0
stepsize: []
lssteplength: []
constrviolation: []
firstorderopt: []
message: 'Exiting due to infeasibility: 1 lower bound exceeds the corresponding upper bound.'
lambad =
[]
————————————————————————
exitflag=-2 指明程序退出的原因是在约束条件下,没有可行点,所以这题无解
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯