2012-02-21 61 views
0

運行:MATLAB:fmincon找不到最小值

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> 

我已經測試了 't檢驗',它工作正常.....不太瞭解警告~~爲什麼它不起作用?

+0

你的'ttest'函數是什麼樣的? – macduff 2012-02-21 17:10:41

回答

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