2013-08-26 29 views
0

所以我的使用下面的代碼優化我的一個功能:在MATLAB運行fmincon一個問題

function [fval, z, Z, x] = fCarterFunction 

%Searches parameter space for the best values given the model and LSE 

A = []; 
b = []; 
Aeq = []; 
beq =[]; 
options = optimset('Display','iter', 'Algorithm', 'interior-point'); 
options.MaxFunEvals = 100000; 
options.MaxIter = 100000; 
[pOPT, fval] = fmincon(@(p)fRSS(p),[.01 .01 .01],A, b, Aeq, beq, 0, 1, [], options); 

z = pOPT(1); 
Z = pOPT(2); 
x = pOPT(3); 

end 

此問題是,當我在我的函數運行這個它返回下列信息:

Warning: Length of lower bounds is < length(x); filling in missing lower bounds with - Inf. 
> In checkbounds at 34 
In fmincon at 332 
In fCarterFunction at 12 
In RunRSSfunc at 1 
In run at 64 
Warning: Length of upper bounds is < length(x); filling in missing upper bounds with +Inf. 
> In checkbounds at 48 
In fmincon at 332 
In fCarterFunction at 12 
In RunRSSfunc at 1 
In run at 64 

我不明白的是,我跑了這個以前的數據集,我沒有任何問題。現在,matlab正在取代我的上下界。有誰知道如何解決這一問題?如果您需要查看實際遍歷數據的其他函數,然後通過最小二乘方法將仿真與實際進行比較,請讓我知道。謝謝!

+1

根據您試圖約束的值,您的界限應該是[0 -Inf -Inf],[1 Inf Inf]或[0 0 0],[1 1 1] 0 => 1 – grantnz

+0

有趣的是,在沒有看到警告的情況下查看更多信息(代碼) –

+0

代碼完全相同。我只是切換數據集。 – cwdaniels

回答

1

由於@grantnz指出嘗試:

[pOPT, fval] = fmincon(@(p)fRSS(p),[.01 .01 .01],A, b, Aeq, beq, [0 0 0], [1 1 1], [], options); 

fmincon預計/的上限值所有變量較低。

+0

工作。謝謝! – cwdaniels