Consider the following simple optimization problem.

from symfit import parameters, Eq, Ge, Fit, log
from symfit.core.minimizers import BasinHopping

n = 3
# xdata = np.sort(np.random.choice(range(1, 4*n), n))
xdata = [2, 8, 11]
p1, p2, p3 = parameters('p1, p2, p3')
model = p1*p2*p3
# model = log(p1)+log(p2)+log(p3)
constraints = [
    Eq(xdata[0]*p1+(xdata[1]-xdata[0])*p2+(xdata[2]-xdata[1])*p3, 1),
    Ge(p1, p2),
    Ge(p2, p3),
    Ge(p3, 0.00001)

fit2 = Fit(- model, constraints=constraints)
print(fit2.execute(options={"ftol": 1e-12}))
fit0 = Fit(- model, constraints=constraints, minimizer=BasinHopping)

This gives the optimum as:

Parameter Value        Standard Deviation
p1        1.666668e-01 nan
p2        7.407405e-02 nan
p3        7.407405e-02 nan

for both fit0 and fit2. The total run time for both is about 3 seconds. BasinHopping uses 567 iterations.

Now let's simply take logs of the objective function. So we have:

model = log(p1)+log(p2)+log(p3)

instead of the model = line above. This should give exactly the same result and indeed fit2 works and takes about 1 second. However, the following happens:

fit0 (that is BasinHopping) takes 110137 iterations and 7 minutes to compute the optimum.

What is going wrong here?

0 Answers