Guessing initial parameters for global optimization

144 Views Asked by At

I am trying to perform a global optimization fit routine, using dual annealing algorithm. After testing the code over synthetic data (which it works), I am now trying to analyze experimental ones. Unfortunately the fit return quite a linear behavior which does not capture the real trend of the data. I am assuming that the problem here is the initial values I am giving to my parameters. I honestly have no idea which value should I assign to them. Can someone give me a small hint? Is there any additional evaluation I can do to assign values or check the correctness of the fit? Below the code.

def fit_msd3(params,t,data):
    A = params['A']
    B = params['B']
    a = params['a']
    C = params['C']
    b = params['b']
    

    model = A*t + B * (1 - np.exp(-a*t))+ C * (1 - np.exp(-b*t)) 
    return np.log(model) - np.log(data)
# create a set of Parameters
params = Parameters()

params.add('B',  value = 0, min=0, max = 1000000)
params.add('A',  min=0.0001, max = 1000000)
params.add('a', value=0.25, min=0.0001, max = 1000000)
params.add('C', min=0, max = 1000000)
params.add('b',  value = 0.16, min=0.0001, max = 1000000)
x =[ 4.,  6.,   8.,  10.,  14.,  18.,  22.,  28., 36.,  44.,  54.,  66.,  82., 102.,126., 154., 190., 234., 286., 350., 428., 524., 642., 786.]
y = [1.15665197,   2.54089084,  4.39305993,  6.65139545,  12.16321355, 18.71986828,  26.05988679, 38.11383458,  55.45630159,  73.4806873, 95.87748006, 122.00380449, 155.64913134, 195.18638036, 236.78299798, 275.1298213, 315.73083698, 363.20054857, 410.54976453, 449.63215925, 476.15782442, 513.45335548, 589.47002132, 609.59510735]

plt.plot(np.log(x),np.log(y))
opt_args = {'initial_temp': 1050000, 'accept': -2.}
minner = Minimizer(fit_msd3, params, fcn_args=(x, y), max_nfev = 20000000)
result = minner.minimize(method="dual_annealing", **opt_args)

# show results
report_fit(result)
fig, ax = plt.subplots(figsize = (15,15))
ax.grid()
ax.set_ylabel('$\Delta_{msd}$(t) [$\mu$m]', fontsize=18)
ax.set_xlabel('Time Lag $\Delta t$ [s]', fontsize=18)
ax.plot(np.log(x), np.log(y), 'ko', lw=2)
ax.plot(np.log(x), np.log(y)+result.residual, 'r-', lw=2)

plt.legend(['data', 'dual anneal'], loc='upper left')

1

There are 1 best solutions below

7
JJacquelin On

In the code the coefficients B and C are supposed to be both positive because Bmin=0 and Cmin=0 are stated. This might be a cause of bad optimization.

Another software gives the result below :

enter image description here