0

我正在尝试fmincon在 MATLAB 中实现该函数。我收到了一个关于算法更改的警告,以评估我的功能(警告显示在帖子末尾)。我想使用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 变量都是我默认值的两倍。您可以强制使用双重使用,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 回答