Scipy curve_fit gets stuck at bounds?

Viewed 105

(This is less a technical how-to question than trying to understand what's going on under the hood and whether what I'm encountering is a common issue. Please don't flag me!)

I've been running some nonlinear regressions with scipy.optimize.curve_fit and have been noticing that the optimization seems to get stuck at parameter bounds pretty often. For context, I've done a fair bit of nonlinear optimization with other software though I'm not expert at what goes into the algorithms; this is my first time using scipy for it, and it's just... getting stuck a lot more than I would expect.

A example of a function I'm feeding into curve_fit - here t and dn are various data series, length ~100-150:

def dynamic(exogs, alpha_0, delta, theta, beta):
    t, dn = exogs
    alpha_f = alpha_0 * delta
    return np.log(beta) - (alpha_0 + (1 - np.exp(-t/theta)) * (alpha_f - alpha_0)) * dn

non_bds = ([1e-02, 0.1, 5, 0], 
           [1e02, 10, 1e03, 10])

fit_non = curve_fit(dynamic, [df['t'], df['dn']], Y, bounds=non_bds, loss='huber', max_nfev=1e06)

In this case, delta is getting stuck at bounds (0.1 or 10) about 90% of the time, and theta at bounds about 50% of the time, neither of which I expect.

I've found this answer where it seems curve_fit does sometimes behave weirdly, so am wondering - is it common for the optimizer for curve_fit to get stuck at bounds? Is this a known issue, and are there any good ways to address it either by tweaking any of the settings or with other workarounds?

0 Answers
Related