I would like to create an optimization solution for black-box software calculations. Currently, I am using the Levenberg-Marquardt algorithm to update a vector of parameters, $\beta$, with residuals, $r$, determined by outputting the black-box calculation and model parameters to a readable table.
$(J^TJ+\lambda diag(J^TJ))\delta=J^Tr(\beta)$
$\beta_{n}=\beta_{n-1} + \alpha \delta$
$r(\beta) = y_{data} - f_{model}(\beta)$
The Jacobian is estimated using Broyden's method where $\Delta f_n$ and $\Delta x_n$ are the difference in the residual vector and parameter vector between iterations respectively. Since Broyden's method is for root finding, then $\Delta f_n = r_n -r_{n-1} \rightarrow 0 $ should fit the system.
I have little experience in programming, but I think I'm close to having a solution by iterating on the following loop:
deltaf_n = np.reshape(r_n - r_old, (len(r_n), 1))
deltabeta_n = np.reshape(beta_n - beta_old, (len(beta_n), 1))
broyden_n = broyden_old + np.matmul((deltaf_n - np.matmul(broyden_old,\
deltabeta_n))/np.sum(deltabeta_n**2), deltabeta_n.T)
jTj = np.matmul(broyden_n.T, broyden_n)
delta = np.linalg.solve(jTj + lam*jTj*np.eye(3), -np.matmul(broyden_n.T, r_n))
beta_old = np.copy(beta_n)
r_old = np.copy(r_n)
broyden_old = np.copy(broyden_n)
beta_n = beta_n + alpha*delta
r_n = residuals(y_data, beta_n)
Unfortunately I'm not getting a solution because the parameters aren't updating as expected:
Does anyone have any idea why my parameters aren't getting updated properly? You can see that the quadratic parameter is getting updated, but for some reason the constant parameter is hardly moving.