所以我使用以下代码优化了我的函数:
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正在取代我的上限和下限。有谁知道如何解决这一问题?如果您需要查看实际迭代数据的其他函数,然后通过最小二乘法将模拟与实际比较,请告诉我。谢谢!
答案 0 :(得分:1)
正如@grantnz指出的那样尝试:
[pOPT, fval] = fmincon(@(p)fRSS(p),[.01 .01 .01],A, b, Aeq, beq, [0 0 0], [1 1 1], [], options);
fmincon
期望所有变量的值均为上限/下限。