nifty8.minimization.descent_minimizers module#

class DescentMinimizer(controller, line_searcher=<nifty8.minimization.line_search.LineSearch object>)[source]#

Bases: Minimizer

A base class used by gradient methods to find a local minimum.

Descent minimization methods are used to find a local minimum of a scalar function by following a descent direction. This class implements the minimization procedure once a descent direction is known. The descent direction has to be implemented separately.

Parameters:
  • controller (IterationController) – Object that decides when to terminate the minimization.

  • line_searcher (callable optional) – Function which infers the step size in the descent direction (default : LineSearch()).

__call__(energy)[source]#

Performs the minimization of the provided Energy functional.

Parameters:

energy (Energy) – Energy object which provides value, gradient and metric at a specific position in parameter space.

Returns:

  • Energy – Latest energy of the minimization.

  • int – Can be controller.CONVERGED or controller.ERROR

Notes

The minimization is stopped if
  • the controller returns controller.CONVERGED or controller.ERROR,

  • a perfectly flat point is reached,

  • according to the line-search the minimum is found,

__init__(controller, line_searcher=<nifty8.minimization.line_search.LineSearch object>)[source]#
property controller#
get_descent_direction(energy, old_value=None)[source]#

Calculates the next descent direction.

Parameters:
  • energy (Energy) – An instance of the Energy class which shall be minimized. The position of energy is used as the starting point of minimization.

  • old_value (float) – if provided, this must be the value of the energy in the previous step.

Returns:

The descent direction.

Return type:

nifty8.field.Field or nifty8.multi_field.MultiField

reset()[source]#
class L_BFGS(controller, line_searcher=<nifty8.minimization.line_search.LineSearch object>, max_history_length=5)[source]#

Bases: DescentMinimizer

A base class used by gradient methods to find a local minimum.

Descent minimization methods are used to find a local minimum of a scalar function by following a descent direction. This class implements the minimization procedure once a descent direction is known. The descent direction has to be implemented separately.

Parameters:
  • controller (IterationController) – Object that decides when to terminate the minimization.

  • line_searcher (callable optional) – Function which infers the step size in the descent direction (default : LineSearch()).

__call__(energy)[source]#

Performs the minimization of the provided Energy functional.

Parameters:

energy (Energy) – Energy object which provides value, gradient and metric at a specific position in parameter space.

Returns:

  • Energy – Latest energy of the minimization.

  • int – Can be controller.CONVERGED or controller.ERROR

Notes

The minimization is stopped if
  • the controller returns controller.CONVERGED or controller.ERROR,

  • a perfectly flat point is reached,

  • according to the line-search the minimum is found,

__init__(controller, line_searcher=<nifty8.minimization.line_search.LineSearch object>, max_history_length=5)[source]#
get_descent_direction(energy, _=None)[source]#

Calculates the next descent direction.

Parameters:
  • energy (Energy) – An instance of the Energy class which shall be minimized. The position of energy is used as the starting point of minimization.

  • old_value (float) – if provided, this must be the value of the energy in the previous step.

Returns:

The descent direction.

Return type:

nifty8.field.Field or nifty8.multi_field.MultiField

reset()[source]#
class NewtonCG(controller, napprox=0, line_searcher=None, name=None, nreset=20, max_cg_iterations=200, energy_reduction_factor=0.1, enable_logging=False)[source]#

Bases: DescentMinimizer

Calculates the descent direction according to a Newton-CG scheme.

Algorithm derived from SciPy sources.

__init__(controller, napprox=0, line_searcher=None, name=None, nreset=20, max_cg_iterations=200, energy_reduction_factor=0.1, enable_logging=False)[source]#
get_descent_direction(energy, old_value=None)[source]#

Calculates the next descent direction.

Parameters:
  • energy (Energy) – An instance of the Energy class which shall be minimized. The position of energy is used as the starting point of minimization.

  • old_value (float) – if provided, this must be the value of the energy in the previous step.

Returns:

The descent direction.

Return type:

nifty8.field.Field or nifty8.multi_field.MultiField

property inversion_history#
class RelaxedNewton(controller, line_searcher=None)[source]#

Bases: DescentMinimizer

Calculates the descent direction according to a Newton scheme.

The descent direction is determined by weighting the gradient at the current parameter position with the inverse local metric.

__init__(controller, line_searcher=None)[source]#
get_descent_direction(energy, _=None)[source]#

Calculates the next descent direction.

Parameters:
  • energy (Energy) – An instance of the Energy class which shall be minimized. The position of energy is used as the starting point of minimization.

  • old_value (float) – if provided, this must be the value of the energy in the previous step.

Returns:

The descent direction.

Return type:

nifty8.field.Field or nifty8.multi_field.MultiField

class SteepestDescent(controller, line_searcher=<nifty8.minimization.line_search.LineSearch object>)[source]#

Bases: DescentMinimizer

Implementation of the steepest descent minimization scheme.

Also known as ‘gradient descent’. This algorithm simply follows the functional’s gradient for minimization.

get_descent_direction(energy, _=None)[source]#

Calculates the next descent direction.

Parameters:
  • energy (Energy) – An instance of the Energy class which shall be minimized. The position of energy is used as the starting point of minimization.

  • old_value (float) – if provided, this must be the value of the energy in the previous step.

Returns:

The descent direction.

Return type:

nifty8.field.Field or nifty8.multi_field.MultiField

class VL_BFGS(controller, line_searcher=<nifty8.minimization.line_search.LineSearch object>, max_history_length=5)[source]#

Bases: DescentMinimizer

Implementation of the Vector-free L-BFGS minimization scheme.

Find the descent direction by using the inverse Hessian. Instead of storing the whole matrix, it stores only the last few updates, which are used to do operations requiring the inverse Hessian product. The updates are represented in a new basis to optimize the algorithm.

References

W. Chen, Z. Wang, J. Zhou, “Large-scale L-BFGS using MapReduce”, 2014, Microsoft

__call__(energy)[source]#

Performs the minimization of the provided Energy functional.

Parameters:

energy (Energy) – Energy object which provides value, gradient and metric at a specific position in parameter space.

Returns:

  • Energy – Latest energy of the minimization.

  • int – Can be controller.CONVERGED or controller.ERROR

Notes

The minimization is stopped if
  • the controller returns controller.CONVERGED or controller.ERROR,

  • a perfectly flat point is reached,

  • according to the line-search the minimum is found,

__init__(controller, line_searcher=<nifty8.minimization.line_search.LineSearch object>, max_history_length=5)[source]#
get_descent_direction(energy, _=None)[source]#

Calculates the next descent direction.

Parameters:
  • energy (Energy) – An instance of the Energy class which shall be minimized. The position of energy is used as the starting point of minimization.

  • old_value (float) – if provided, this must be the value of the energy in the previous step.

Returns:

The descent direction.

Return type:

nifty8.field.Field or nifty8.multi_field.MultiField

reset()[source]#