Algorithms

Module: pycsou.core.solver

This module provides the base class for iterative algorithms.

GenericIterativeAlgorithm(…[, max_iter, …])

Base class for iterative algorithms.

class GenericIterativeAlgorithm(objective_functional: pycsou.core.map.Map, init_iterand: Any, max_iter: int = 500, min_iter: int = 10, accuracy_threshold: float = 0.001, verbose: Optional[int] = None)[source]

Bases: abc.ABC

Base class for iterative algorithms.

Any instance/subclass of this class must at least implement the abstract methods update_iterand, print_diagnostics update_diagnostics and stopping_metric.

__init__(objective_functional: pycsou.core.map.Map, init_iterand: Any, max_iter: int = 500, min_iter: int = 10, accuracy_threshold: float = 0.001, verbose: Optional[int] = None)[source]
Parameters
  • objective_functional (Map) – Objective functional to minimise.

  • init_iterand (Any) – Initial guess for warm start.

  • max_iter (int) – Maximum number of iterations.

  • min_iter (int) – Minimum number of iterations.

  • accuracy_threshold (float) – Accuracy threshold for stopping criterion.

  • verbose (int) – Print diagnostics every verbose iterations. If None does not print anything.

iterate() → Any[source]

Run the algorithm.

Returns

Algorithm outcome.

Return type

Any

reset()[source]

Reset the algorithm.

iterates(n: int) → Tuple[source]

Generator allowing to loop through the n first iterates.

Useful for debugging/plotting purposes.

Parameters

n (int) – Max number of iterates to loop through.

abstract update_iterand() → Any[source]

Update the iterand.

Returns

Result of the update.

Return type

Any

abstract print_diagnostics()[source]

Print diagnostics.

abstract stopping_metric()[source]

Stopping metric.

abstract update_diagnostics()[source]

Update the diagnostics.