Hessian update in BFGS method

Asked

Viewed 54 times

1

I’m developing the nonlinear optimization method BFGS (Broyden-Fletcher-Goldfarb-Shanno) and I’m having a hard time updating the value of Hessian to minimize function. The input variables for updating H (Hessian) are arrays, where in the update I perform product operations and etc. Below follows the code of the function and its respective return.

    def BFGS(f,g,x0,eps,maxiter=10, alfa=0.1):
x = x0
iteracao = 0
H = np.eye(len(x0))

while ln.norm(g(x),2) >= eps and iteracao < maxiter:
    p = -np.linalg.solve(H,g(x))
    s = alpha * p 
    print('Valor gradiente :', s)
    y = g(x+alpha*s) - g(x)
    x = x + s
    H = H + np.outer(y,y)/np.inner(y,s) - ([email protected](s,s)@H.T)/(s.T@H@s)
    print('Atualiza Hessiana: ', H)
    iteracao += 1
return x, iteracao

def f(x):
    return x[0]**2 + 2*x[1]**2 + (-2*x[0]*x[1] - 2*x[1])

Function output

inserir a descrição da imagem aqui

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.