In trying to keep the question simple, I'm using MATLAB and trying to create an upper bound for lsqcurvefit to use where the sum of my upper boundaries on the parameters cannot exceed 100.
Something like
lb = [0, 0, 0]; ub = [a, b, c];
where a+b+c < 100
Is there a simple elegant way to pass that type of information into the lsqcurvefit command?
I've tried setting limiters in the ode45 portion with if statements, I've tried 100s in each of the upper bound spots to see if the lsq came out naturally following that limitation. What I'm expecting is that the parameters I'm getting out of lsqcurvefit should sum to something less than or equal to 100.
The
lsqcurvefitfunction doesn't have inputs for constraints between optimisation parameters as far as I can tell, so you'll likely need to use a more generic optimisation function likefmincon.Here is a comparison, where I take a quadratic function, which accepts a 3-element array of coefficients
abcand axis pointsx:We can evaluate the true values at these points:
And set up some constraints for out optimisation:
Using
lsqcurvefit, you can only ensure that each element ofabcis within the bounds, using something likeHowever, we can construct an additional inequality constraint for
fminconand use that instead:We can do some plotting to confirm the result - I've added the output coefficient arrays to the legend