IterativeAlgorithmsInterface.jl
is a Julia package to provide a common interface to run iterative tasks. Algorithm here refers to an iterative sequence of commands, that are run until a certain stopping criterion is met.
A first approach to algorithms is a simple for-loop for a maximum number of iterations. Using an interface instead allows to both specify different criteria to stop easily, even in their combination. Furthermore a generic interface allows to both “hook into” an algorithm easily as well as combining them.
A common interface for algorithms allows to reuse common code – especially stopping criteria, but especially also logging, debug, recording, and caching capabilities. Finally, a common interface also allows to easily combine existing algorithms, hence enhancing interoperability, for example using one algorithm as a sub routine of another one.
We consider solving Tasks, which consist of
- An
AbstractProblem
to solve, which contains all information that is static to the problem and usually does not change during the iterations, this might for example be a cost function and its gradient in an optimisation problem. - An
AbstractAlgorithmState
that both specifies which algorithm to use to solve the problem, but also stores all parameters that an algorithm needs as well as everything the algorithm needs to store between two iterations.
This generic data structures are accompanied by the methods
step!(problem::Problem, state::AlgorithmState, k)
to perform thek
th iteration of the algorithm.solve!(problem::Problem, state::AlgorithmState)
to solve a problem with a given algorithm, which is identified by theAlgorithmState
.stop(problem::Problem, state::AlgorithmState)
to check whether the algorithm should stop.
where the first is the main one to implement for a new algorithm.
- generic stopping criteria
<:AbstractStoppingCriterion
StopAfterIteration(i)
for example
- a factory that turns certain keywords like
maxiter=
into stopping criteria - still support the
stopping_criterion=
ideas fromManopt.jl
- by default
stop()
from above would check such a stopping criterion - generic debug and record functionality – together with hooks even
- to
LineSearches.jl