0

fminconMATLABで関数を実装しようとしています。関数を評価するためのアルゴリズムの変更に関する警告が表示されます (投稿の最後に警告が表示されます)。を使用したかったfminsearchのですが、従わなければならない制約が 2 つあります。制約が非常に単純であるため、関数を評価するために MATLAB がアルゴリズムを変更しても意味がありません。制約とコードを提供しました:

制約:
theta(0) + theta(1) < 1

theta(0), theta(1), theta(2), theta(3) > 0

% Solve MLE using fmincon
ret_1000 = returns(1:1000);
A = [1 1 0 0];
b = [.99999];
lb = [0; 0; 0; 0];
ub = [1; 1; 1; 1];
Aeq = [];
beq = [];
noncoln = [];
init_guess = [.2;.5; long_term_sigma; initial_sigma];
%option = optimset('FunValCheck', 1000);
options = optimset('fmincon');
options = optimset(options, 'MaxFunEvals', 10000);
[x, maxim] = fmincon(@(theta)Log_likeli(theta, ret_1000), init_guess, A, b, Aeq, beq, lb, ub, noncoln, options);

警告:

Warning: The default trust-region-reflective algorithm does not solve problems with the constraints you
have specified. FMINCON will use the active-set algorithm instead. For information on applicable
algorithms, see Choosing the Algorithm in the documentation. 
> In fmincon at 486
  In GARCH_loglikeli at 30 

Local minimum possible. Constraints satisfied.

fmincon stopped because the predicted change in the objective function
is less than the selected value of the function tolerance and constraints 
are satisfied to within the selected value of the constraint tolerance.

<stopping criteria details>

No active inequalities.
4

1 に答える 1

0

すべての matlab 変数は私のデフォルトの 2 倍です。を使用して double を強制することがdouble(variableName),できます。変数の型を取得するには、すべての変数で をclass(variableName). 使用してclass、それらが期待どおりであることを確認します。はありませんがfmincon、あなたのコードの変形を試してみたところfminsearch、魅力的に機能しました:

op = optimset('fminsearch');
op = optimset(op,'MaxFunEvals',1000,'MaxIter',1000);
a = sqrt(2);
banana = @(x)100*(x(2)-x(1)^2)^2+(a-x(1))^2;
[x,fval] = fminsearch(banana, [-1.2, 1],op)

matlab のドキュメントを見ると、入力変数が正しくないと思います。

x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)

私はあなたが必要だと思います:

% Let's be ultra specific to solve this syntax issue

fun = @(theta) Log_likeli(theta, ret_1000);
x0 = init_guess;
% A is defined as A
% b is defined as b
Aeq = [];
beq = [];
% lb is defined as lb
% ub is not defined, not sure if that's going to be an issue
% with the solver having lower, but not upper bounds probably isn't
% but thought it was worth a mention
ub = [];
nonlcon = [];
% options is defined as options
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)
于 2013-03-07T14:57:50.410 に答える