cwdaniels
cwdaniels

Reputation: 71

An issue running fmincon in matlab

So I an optimizing a function of mine using the following code:

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

This issue is that when I run this on my function it returns the following:

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 

What I don't understand is that I ran this for a previous dataset and I had no problems. Now, matlab is replacing my upper and lower bounds. Does anyone know how to fix this? If you need to see the other function that actually iterates through the data and then compares the simulation to the actual via the least squares technique please let me know. Thanks!

Upvotes: 0

Views: 1142

Answers (1)

Buck Thorn
Buck Thorn

Reputation: 5074

As @grantnz points out try:

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

fmincon expects values of upper/lower for all variables.

Upvotes: 1

Related Questions