![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
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
结果正确着呢!
因为你这是非线性有约束的最优化问题,只能用这个函数了
![](https://ecmc.bdimg.com/public03/b4cb859ca634443212c22993b0c87088.png)
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询