简体   繁体   English

MATLAB:fmincon找不到最小值

[英]MATLAB: fmincon can't find a minimum value

run: 跑:

function test()

Aeq = ones(1,4); beq = 1;
a0 = [.2,.2,.2,.1];
[a,f] = fmincon(@ttest,a0,[],[],Aeq,beq);

Result: 结果:

Warning: Trust-region-reflective algorithm does not solve
this type of problem, using active-set algorithm. You
could also try the interior-point or sqp algorithms: set
the Algorithm option to 'interior-point' or 'sqp' and
rerun. For more help, see Choosing the Algorithm in the
documentation. 
> In fmincon at 472
  In test at 6

Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.

<stopping criteria details>

I have tested 'ttest', it works fine.....don't quite understand the warning~~ Why doesn't it work? 我已经测试过“ ttest”,它可以正常工作.....不太了解警告信息~~为什么不起作用?

Your local minimization succeeded: Local minimum found that satisfies the constraints. 您的本地最小化成功: Local minimum found that satisfies the constraints. . Check your values of a and f . 检查af值。

All the warning is telling you is that the default algorithm doesn't work for the problem you are working with, so it picks another one for you. 所有警告都告诉您,默认算法不适用于您正在处理的问题,因此它将为您选择另一种算法。 See the fmincon documentation near the bottom for the different algorithms it can use. 请参阅底部附近的fmincon文档,以了解它可以使用的不同算法。 You can get rid of this warning by telling it specifically which algorithm to use: 您可以通过明确告知要使用哪种算法来摆脱此警告:

Aeq = ones(1,4); beq = 1;
a0 = [.2,.2,.2,.1];
options = optimset('Display', 'iter', ...
                   'Algorithm', 'active-set');
[a,f] = fmincon(@ttest,a0,[],[],Aeq,beq,[],[],[],options);

I've also told it to display its iterations, something I always find useful in the debugging phase. 我还告诉它显示其迭代,这在调试阶段一直很有用。 See here for the various options available. 有关可用的各种选项,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM