You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
Remove code which has been deprecated since v24.3 or earlier (#2309)
* Remove deprecated code
* fix test failures
* handle max iterations
* Fix progress test
* Fix some GD issues
* Fix callbacks fail
* Fix issue with CGLS iterating after fully converged on exact solution
* Add to Change log
* Margaret's first pass, fixing failing test and deprecating a couple more things
* White space changes
* Added rosen with fixed stepsize test back
* Update documentation
---------
Signed-off-by: Laura Murgatroyd <60604372+lauramurgatroyd@users.noreply.github.com>
Co-authored-by: Margaret Duff <margaret.duff@stfc.ac.uk>
Co-authored-by: Gemma Fardell <47746591+gfardell@users.noreply.github.com>
Co-authored-by: gfardell <gemma.fardell@stfc.ac.uk>
Copy file name to clipboardExpand all lines: Wrappers/Python/cil/optimisation/algorithms/APGD.py
+11-10Lines changed: 11 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,9 @@ class ScalarMomentumCoefficient(ABC):
34
34
The call method of the ScalarMomentumCoefficient returns a scalar value. Given access to the algorithm object, the momentum coefficient can be a function of the algorithm state.
35
35
36
36
The `apply_momentum_in_APGD` function, updates the solution in the APGD algorithm as
37
-
37
+
38
38
.. math:: y_{k+1}=x_{k+1}+M(x_{k+1}-x_{k}),
39
-
39
+
40
40
where :math:`M` is the calculated scalar momentum value.
The momentum coefficient is then returned as :math:`\dfrac{t_{k}-1}{t_{k}}`.
103
103
'''
104
104
@@ -126,7 +126,7 @@ class APGD(Algorithm):
126
126
where :math:`\alpha` is the :code:`step_size`.
127
127
128
128
Then, :math:`y_{k+1}`, is then calculated from :math:`x_{k+1}`, based on a momentum rule. Note that :math:`y_0=x_0`. Users have flexibility to do this however they wish by passing to `momentum` a class that has an `apply_montemum_in_APGD` function which takes an intialised algorithm and returns the next iterate.
129
-
129
+
130
130
131
131
Currently, we have implemented options for a scalar momentum coefficient (see :class:`cil.optimisation.algorithms.APGD.ScalarMomentumCoefficient` class.). In this case, the momentum term is added as follows:
132
132
@@ -233,9 +233,9 @@ def update(self):
233
233
r"""Performs a single iteration of APGD. For :math:`k\geq 1`:
where :math:`\alpha` is the step size. From :math:`x_{k+1}` (and any other information available in the algorithm class) the momentum function then calculates :math:`y_{k+1}`.
241
241
"""
@@ -293,14 +293,15 @@ def step_size(self):
293
293
'''
294
294
Returns the most recently used step size. Note, if the step-size is set by a non-constant step size rule, you must use the algorithm run or update method before this getter will return the most recently used step size.
raiseNotImplementedError("Note the step-size is set by a step-size rule and could change with each iteration. Call the algorithm run or update method first and then this function will give the most recently used step size.")
303
+
raiseNotImplementedError(
304
+
"Note the step-size is set by a step-size rule and could change with each iteration. Call the algorithm run or update method first and then this function will give the most recently used step size.")
r"""Base class providing minimal infrastructure for iterative algorithms.
30
30
31
31
An iterative algorithm is designed to solve an optimization problem by repeatedly refining a solution. In CIL, we use iterative algorithms to minimize an objective function, often referred to as a loss. The process begins with an initial guess, and with each iteration, the algorithm updates the current solution based on the results of previous iterations (previous iterates). Iterative algorithms typically continue until a stopping criterion is met, indicating that an optimal or sufficiently good solution has been found. In CIL, stopping criteria can be implemented using a callback function (`cil.optimisation.utilities.callbacks`).
32
-
32
+
33
33
The user is required to implement the :code:`set_up`, :code:`__init__`, :code:`update` and :code:`update_objective` methods.
34
34
35
35
The method :code:`run` is available to run :code:`n` iterations. The method accepts :code:`callbacks`: a list of callables, each of which receive the current Algorithm object (which in turn contains the iteration number and the actual objective value) and can be used to trigger print to screens and other user interactions. The :code:`run` method will stop when the stopping criterion is met or `StopIteration` is raised.
The objective (or loss) is calculated and saved every `update_objective_interval`. 1 means every iteration, 2 every 2 iterations and so forth. This is by default 1 and should be increased when evaluating the objective is computationally expensive.
r""" Checks if the algorithm set-up (e.g. chosen step-sizes or other parameters) meets a mathematical convergence criterion.
141
-
118
+
142
119
Returns
143
120
-------
144
121
bool: Outcome of the convergence check
145
122
"""
146
-
raiseNotImplementedError(" Convergence criterion is not implemented for this algorithm. ")
123
+
raiseNotImplementedError(
124
+
" Convergence criterion is not implemented for this algorithm. ")
147
125
148
126
defis_provably_convergent(self):
149
127
r""" Check if the algorithm is convergent based on the provable convergence criterion.
150
-
128
+
151
129
Returns
152
130
-------
153
131
Boolean
154
132
Outcome of the convergence check
155
-
133
+
156
134
"""
157
135
returnself._provable_convergence_condition()
158
136
@@ -163,17 +141,17 @@ def solution(self):
163
141
164
142
defget_last_loss(self, return_all=False):
165
143
r'''Returns the last stored value of the loss function. "Loss" is an alias for "objective value". If `update_objective_interval` is 1 it is the value of the objective at the current iteration. If update_objective_interval > 1 it is the last stored value.
0 commit comments