nifty8.minimization.iteration_controllers module#

class AbsDeltaEnergyController(deltaE, convergence_level=1, iteration_limit=None, name=None)[source]#

Bases: IterationController

An iteration controller checking (mainly) the energy change from one iteration to the next.

Parameters:
  • deltaE (float) – If the difference between the last and current energies is below this value, the convergence counter will be increased in this iteration.

  • convergence_level (int, default=1) – The number which the convergence counter must reach before the iteration is considered to be converged

  • iteration_limit (int, optional) – The maximum number of iterations that will be carried out.

  • name (str, optional) – if supplied, this string and some diagnostic information will be printed after every iteration

__init__(deltaE, convergence_level=1, iteration_limit=None, name=None)[source]#
check(energy)[source]#

Checks the state of the iteration. Called after every step.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

start(energy)[source]#

Starts the iteration.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

class DeltaEnergyController(tol_rel_deltaE, convergence_level=1, iteration_limit=None, name=None)[source]#

Bases: IterationController

An iteration controller checking (mainly) the relative energy change from one iteration to the next.

Parameters:
  • tol_rel_deltaE (float) – If the difference between the last and current energies divided by the current energy is below this value, the convergence counter will be increased in this iteration.

  • convergence_level (int, default=1) – The number which the convergence counter must reach before the iteration is considered to be converged

  • iteration_limit (int, optional) – The maximum number of iterations that will be carried out.

  • name (str, optional) – if supplied, this string and some diagnostic information will be printed after every iteration

__init__(tol_rel_deltaE, convergence_level=1, iteration_limit=None, name=None)[source]#
check(energy)[source]#

Checks the state of the iteration. Called after every step.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

start(energy)[source]#

Starts the iteration.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

class EnergyHistory[source]#

Bases: object

__init__()[source]#
append(x)[source]#
property energy_values#
reset()[source]#
property time_stamps#
class GradInfNormController(tol, convergence_level=1, iteration_limit=None, name=None)[source]#

Bases: IterationController

An iteration controller checking (mainly) the L_infinity gradient norm.

Parameters:
  • tol (float) – If the L_infinity norm of the energy gradient is below this value, the convergence counter will be increased in this iteration.

  • convergence_level (int, default=1) – The number which the convergence counter must reach before the iteration is considered to be converged

  • iteration_limit (int, optional) – The maximum number of iterations that will be carried out.

  • name (str, optional) – if supplied, this string and some diagnostic information will be printed after every iteration

__init__(tol, convergence_level=1, iteration_limit=None, name=None)[source]#
check(energy)[source]#

Checks the state of the iteration. Called after every step.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

start(energy)[source]#

Starts the iteration.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

class GradientNormController(tol_abs_gradnorm=None, tol_rel_gradnorm=None, convergence_level=1, iteration_limit=None, name=None)[source]#

Bases: IterationController

An iteration controller checking (mainly) the L2 gradient norm.

Parameters:
  • tol_abs_gradnorm (float, optional) – If the L2 norm of the energy gradient is below this value, the convergence counter will be increased in this iteration.

  • tol_rel_gradnorm (float, optional) – If the L2 norm of the energy gradient divided by its initial L2 norm is below this value, the convergence counter will be increased in this iteration.

  • convergence_level (int, default=1) – The number which the convergence counter must reach before the iteration is considered to be converged

  • iteration_limit (int, optional) – The maximum number of iterations that will be carried out.

  • name (str, optional) – if supplied, this string and some diagnostic information will be printed after every iteration

__init__(tol_abs_gradnorm=None, tol_rel_gradnorm=None, convergence_level=1, iteration_limit=None, name=None)[source]#
check(energy)[source]#

Checks the state of the iteration. Called after every step.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

start(energy)[source]#

Starts the iteration.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

class IterationController[source]#

Bases: object

The abstract base class for all iteration controllers. An iteration controller is an object that monitors the progress of a minimization iteration. At the begin of the minimization, its start() method is called with the energy object at the initial position. Afterwards, its check() method is called during every iteration step with the energy object describing the current position. Based on that information, the iteration controller has to decide whether iteration needs to progress further (in this case it returns CONTINUE), or if sufficient convergence has been reached (in this case it returns CONVERGED), or if some error has been detected (then it returns ERROR).

The concrete convergence criteria can be chosen by inheriting from this class; the implementer has full flexibility to use whichever criteria are appropriate for a particular problem - as long as they can be computed from the information passed to the controller during the iteration process.

For analyzing minimization procedures IterationControllers can log energy values together with the respective time stamps. In order to activate this feature enable_logging() needs to be called.

CONTINUE = 1#
CONVERGED = 0#
ERROR = 2#
__init__()[source]#
check(energy)[source]#

Checks the state of the iteration. Called after every step.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

disable_logging()[source]#

Disables the logging functionality. If the log has been populated before, it is dropped.

enable_logging()[source]#

Enables the logging functionality. If the log has been populated before, it stays as it is.

property history#
start(energy)[source]#

Starts the iteration.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

class StochasticAbsDeltaEnergyController(deltaE, convergence_level=1, iteration_limit=None, name=None, memory_length=10)[source]#

Bases: IterationController

Check the standard deviation over a period of iterations.

Convergence is reported once this quantity falls below the given threshold.

Parameters:
  • deltaE (float) – If the standard deviation of the last energies is below this value, the convergence counter will be increased in this iteration.

  • convergence_level (int, optional) – The number which the convergence counter must reach before the iteration is considered to be converged. Defaults to 1.

  • iteration_limit (int, optional) – The maximum number of iterations that will be carried out.

  • name (str, optional) – If supplied, this string and some diagnostic information will be printed after every iteration.

  • memory_length (int, optional) – The number of last energies considered for determining convergence, defaults to 10.

__init__(deltaE, convergence_level=1, iteration_limit=None, name=None, memory_length=10)[source]#
check(energy)[source]#

Checks the state of the iteration. Called after every step.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

start(energy)[source]#

Starts the iteration.

Parameters:

energy (Energy object) – Energy object at the start of the iteration

Returns:

status

Return type:

integer status, can be CONVERGED, CONTINUE or ERROR

append_history(func)[source]#