MATLAB:fmincon找不到最小值

时间:2012-02-21 17:01:35

标签: matlab

运行:

function test()

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

结果:

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>

我测试'ttest',它工作得很好.....不太明白警告~~为什么不工作?

1 个答案:

答案 0 :(得分:1)

您的本地最小化成功:Local minimum found that satisfies the constraints. 。检查af

的值

所有警告都告诉您,默认算法不适用于您正在使用的问题,因此它会为您选择另一个算法。请参阅底部附近的fmincon文档,了解它可以使用的不同算法。您可以通过具体告诉使用哪种算法来消除此警告:

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);

我还告诉它显示它的迭代,我总是觉得在调试阶段很有用。有关各种可用选项,请参阅here