Commit a10d47fd authored by Reimar Heinrich Leike's avatar Reimar Heinrich Leike

Now nonlinear CG does more exactly what is described in the cited reference....

Now nonlinear CG does more exactly what is described in the cited reference. Still does not do what we want though
parent e110e7d5
Pipeline #25478 passed with stage
in 5 minutes and 35 seconds
......@@ -40,7 +40,10 @@ class NonlinearCG(Minimizer):
2006, Springer-Verlag New York
"""
def __init__(self, controller, line_searcher=LineSearchStrongWolfe()):
def __init__(self, controller, line_searcher=LineSearchStrongWolfe(c2=0.1), beta_heuristics = 'Polak-Ribiere'):
if (beta_heuristics != 'Polak-Ribiere') and (beta_heuristics != 'Polak-Ribiere'):
raise ValueError("beta heuristics must be either 'Polak-Ribiere' or 'Hestenes-Stiefel'")
self._beta_heuristic = beta_heuristics
self._controller = controller
self._line_searcher = line_searcher
......@@ -63,6 +66,8 @@ class NonlinearCG(Minimizer):
if status != controller.CONTINUE:
return energy, status
grad_new = energy.gradient
gnnew = energy.gradient_norm
beta = gnnew*gnnew/(grad_new-grad_old).vdot(p).real
if self._beta_heuristic == 'Hestenes-Stiefel':
beta = grad_new.vdot(grad_new-grad_old)/(grad_new-grad_old).vdot(p).real
else:
beta = grad_new.vdot(grad_new-grad_old)/(grad_old.vdot(grad_old)).real
p = beta*p - grad_new
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment