Matlab中fmincon函数使用出错
我自己写的如下:functionf=myfun(x);f=-25.896-1.815*x(1)+0.765*x(2)-0.936*x(1)*x(2)+0.707*x(1)...
我自己写的如下:
function f=myfun(x);
f=-25.896-1.815*x(1)+0.765*x(2)-0.936*x(1)*x(2)+
0.707*x(1)^2+0.685*x(2)^2;
存为m文件,命名为fmin.m
然后在工作窗口运行
x0=[0;0];
[x,fval]=fmincon('fmin',x0,[],[],[],[],-1.68,1.68)
虽然出来了x =1.6686
0.5816
fval = -27.1878
但是还是有Warning: Large-scale (trust region) method does not currently solve this type of problem,
using medium-scale (line search) instead.
> In fmincon at 317
Optimization terminated: magnitude of directional derivative in search
direction less than 2*options.TolFun and maximum constraint violation
is less than options.TolCon.
No active inequalities.
请问我算出来的那个x,fval是正确的结果吗?
那个warning又是什么意思?是说让我换种搜索方法吗? 展开
function f=myfun(x);
f=-25.896-1.815*x(1)+0.765*x(2)-0.936*x(1)*x(2)+
0.707*x(1)^2+0.685*x(2)^2;
存为m文件,命名为fmin.m
然后在工作窗口运行
x0=[0;0];
[x,fval]=fmincon('fmin',x0,[],[],[],[],-1.68,1.68)
虽然出来了x =1.6686
0.5816
fval = -27.1878
但是还是有Warning: Large-scale (trust region) method does not currently solve this type of problem,
using medium-scale (line search) instead.
> In fmincon at 317
Optimization terminated: magnitude of directional derivative in search
direction less than 2*options.TolFun and maximum constraint violation
is less than options.TolCon.
No active inequalities.
请问我算出来的那个x,fval是正确的结果吗?
那个warning又是什么意思?是说让我换种搜索方法吗? 展开
2个回答
展开全部
>> [x,fval]=fmincon('fmin',x0,[],[],[],[],-1.68,1.68)
Optimization terminated: magnitude of directional derivative in search
direction less than 2*options.TolFun and maximum constraint violation
is less than options.TolCon.
No active inequalities.
x =
1.668593592364594 0.581614920319626
fval =
-27.187778596177679
结果正确着呢!
因为你这是非线性有约束的最优化问题,只能用这个函数了
Optimization terminated: magnitude of directional derivative in search
direction less than 2*options.TolFun and maximum constraint violation
is less than options.TolCon.
No active inequalities.
x =
1.668593592364594 0.581614920319626
fval =
-27.187778596177679
结果正确着呢!
因为你这是非线性有约束的最优化问题,只能用这个函数了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询