简体   繁体   中英

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?

Your local minimization succeeded: Local minimum found that satisfies the constraints. . Check your values of a and f .

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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