Open bhclowers opened 5 years ago
Hi,
first things first: LBFGSB does not support constraints (but you specified you want that minimizer, so we assume you know better). From the top of my head you can pick from SLSQP
, COBYLA
and TrustConstr
. IIRC, by default Fit will take SLSQP. The resulting theta's being 1 means they haven't changed from their initial guesses. You can try with a better initial guess, or try one of the other algorithms.
Next, it's (much) easier to specify theta >= 0 by setting theta1.min = theta2.min = 0
rather than using the constraint. Bounds are much easier from a minimization point of view that constraints.
HTH!
One more thing: would it not be possible to do the fit unconstrained, and sort the theta's by size afterwards?
Thanks for the direction. I think the fact that the values weren't changing while returning 1 was throwing me off. Even when reasonable first guesses were provided I "expected" some sore of refinement but didn't get it. I went through a range of minimizers and found that some worked better than others for this particular problem. I hope that my struggles will help others. In short, it is not obvious that the constraints are not accepted by certain minimizers as an error doesn't seem to be thrown and this combined with the odd behavior of the default minimizer was compounding my issues in understanding the results.
I renamed the issue. To close this we would need to make Fit warn when constraints are given, and a minimizer was selected that does not support them. Same for bounds.
This feature could be added easily after merging #289, because it adds a helper function to collect subclasses eg. of ConstrainedMinimizer
. Maybe this module should be moved with a PR of this issue :)
Using symfit 0.5.1 I'm running in to what I imagine are similar issues. Essentially, I cannot get the constraints to be accepted and met. In short, I have two parameters that I'm trying to fit (theta1 and theta2) and I need the first theta to be larger than the second and have them both be greater than 0. However, running the following code I get these values for the fitted thetas:
Fitted Theta-1: 5286.70 Fitted Theta-2: -27.42
So the first issue appears to be that the constraints are being ignored and secondly, if you don't specify a minimizer when passing the constraints, the thetas are driving both to 1 (which is also incorrect). I looked at a few other threads but didn't find one that matched this particlar problem. Any thoughts/ideas would be appreciated.