2013-03-07 228 views
1

我想在MATLAB中使用fmincon函數來獲取4個變量的值。我得到一個警告:約束fmincon MATLAB

Local minimum possible. Constraints satisfied. 

fmincon stopped because the size of the current search direction is less than 
twice the default value of the step size tolerance and constraints are 
satisfied to within the selected value of the constraint tolerance. 

<stopping criteria details> 

Optimization stopped because the norm of the current search direction, 6.854643e-07, 
is less than 2*options.TolX = 1.000000e-06, and the maximum constraint 
violation, -3.940985e-05, is less than options.TolCon = 1.000000e-15. 

Optimization Metric            Options 
norm(search direction) = 6.85e-07      TolX = 1e-06 (default) 
max(constraint violation) = -3.94e-05     TolCon = 1e-15 (selected) 

我試圖從1E-6的周圍改變TolFun和TolCon到1E-10,但我仍然得到了同樣的信息。是否有任何其他方式可以使其趨於一致

My code: 
A = [1, 1, 0, 0]; 
b = 1; 
lb = [0; 0; 0; 0]; 
ub = [1; 1; 1; 1]; 
Aeq = []; 
beq = []; 
noncoln = []; 
init_guess = [.03;.93; long_term_sigma; initial_sigma]; 
%option = optimset('FunValCheck', 1000); 
options = optimset('fmincon'); 
options = optimset(options, 'MaxFunEvals', 1000, 'MaxIter', 1000, 'Algorithm', 'active-set', 'TolCon', 1e-15, 'TolFun', 1e-15); 
func = @(theta)Log_likeli(theta, ret_1000); 
%[x, maxim] = fminsearch(@(theta)Log_likeli(theta, ret_1000), init_guess, options); 
[x, maxim] = fmincon(func, init_guess, A, b, Aeq, beq, lb, ub, noncoln, options); 
+1

警告並不意味着錯誤。你檢查過結果嗎?他們預期是什麼?嘗試使用建議值來評估您的函數,然後通過「eps」更改其中一個輸入,以查看新結果是否更大。另外,如果在<停止標準詳細信息>˙之後有任何內容,它會很有用,如果您發佈它。 – 2013-03-07 19:42:11

+0

我已經添加了停止標準的細節,不知道我還能改變什麼。我從函數中得到的結果並不是最優的,我嘗試輸入實際結果,但值被改爲不同的結果 – Josh 2013-03-07 19:50:08

+0

我肯定會建議將'TolX'調整爲像1e-15這樣的東西。這會導致更好的搜索,並讓你接近最低限度。 Matlab還說它在約束內部是'3.940985e-05',所以這不是停止的原因。更小的'TolFun'和'TolX'會讓你更接近最小值(如果它收斂的話)。 'TolCon'只是放大你的搜索領域。另外,你能告訴我這個國旗是什麼嗎?嘗試'[x,maxim,exitflag] = fmincon(func,init_guess,A,b,Aeq,beq,lb,ub,noncoln,options);' – 2013-03-07 20:37:28

回答

2

您的問題有九個約束。也許你的問題可以被強制簡化爲五個約束,如果你使theta_i = exp(x_i)並用所有地方的這個新變量代替theta_i。因此,您已經消除了積極性約束,並且新問題取決於x_i(x_i是您的新變量)。好的....你找到x_i的最優值並計算theta_i = exp(x_i)。當您處理差異或波動的情況時,這在計量經濟學中是非常普遍的替代。使y = exp(x)/(1 + exp(x))[邏輯運算(logistic)功能]。現在你的問題要容易得多,因爲它只有一個約束(由A和b給出),並遵循上面的相同過程。