Commit 784f49a3 authored by Reimar Heinrich Leike's avatar Reimar Heinrich Leike

removed print statement and added the option to set the new constants of NewtonCG in init

parent bbd2040f
Pipeline #61064 passed with stages
in 9 minutes and 21 seconds
......@@ -166,7 +166,7 @@ class NewtonCG(DescentMinimizer):
"""
def __init__(self, controller, napprox=0, line_searcher=None, name=None,
nreset=20):
nreset=20, max_cg_iterations=200, energy_reduction_factor=0.1):
if line_searcher is None:
line_searcher = LineSearch(preferred_initial_step_size=1.)
super(NewtonCG, self).__init__(controller=controller,
......@@ -174,15 +174,16 @@ class NewtonCG(DescentMinimizer):
self._napprox = napprox
self._name = name
self._nreset = nreset
self._max_cg_iterations = max_cg_iterations
self._alpha = energy_reduction_factor
def get_descent_direction(self, energy, old_value=None):
if old_value is None:
ic = GradientNormController(iteration_limit=5)
else:
alpha = 0.1
ediff = alpha*(old_value-energy.value)
ediff = self._alpha*(old_value-energy.value)
ic = AbsDeltaEnergyController(
ediff, iteration_limit=200, name=self._name)
ediff, iteration_limit=self._max_cg_iterations, name=self._name)
e = QuadraticEnergy(0*energy.position, energy.metric, energy.gradient)
p = None
if self._napprox > 1:
......
......@@ -138,7 +138,6 @@ def probe_diagonal(op, nprobes, random_type="pm1"):
def approximation2endo(op, nsamples):
print('Calculate preconditioner')
sc = StatCalculator()
for _ in range(nsamples):
sc.add(op.draw_sample())
......
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