summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdoardo Pasca <edo.paskino@gmail.com>2019-03-04 13:25:25 +0000
committerGitHub <noreply@github.com>2019-03-04 13:25:25 +0000
commitf3b4bae3e07d5b6808318d680429722cf7d92f48 (patch)
tree78d5cea366081dd670c976e645884f2fd16362fc
parent3765455f542b627450e36a76863922d955f52292 (diff)
downloadframework-f3b4bae3e07d5b6808318d680429722cf7d92f48.tar.gz
framework-f3b4bae3e07d5b6808318d680429722cf7d92f48.tar.bz2
framework-f3b4bae3e07d5b6808318d680429722cf7d92f48.tar.xz
framework-f3b4bae3e07d5b6808318d680429722cf7d92f48.zip
added info on Algorithm class
-rw-r--r--README.md26
1 files changed, 22 insertions, 4 deletions
diff --git a/README.md b/README.md
index bfbdbbd..a29eaf3 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,7 @@ In `ccpi.framework` we define a number of common classes normally used in tomogr
* `Operator`: A class specifying a (currently linear) operator
* `Function`: A class specifying mathematical functions such as a least squares data fidelity.
- * `Algorithm`: Implementation of an optimisation algorithm to solve a particular generic optimisation problem. These are currently python functions by may be changed to operators in another release.
+ * `Algorithm`: Implementation of an iterative optimisation algorithm to solve a particular generic optimisation problem. Algorithms are iterable Python object which can be run in a for loop. Can be stopped and warm restarted.
#### `Operator`
@@ -87,9 +87,27 @@ In `ccpi.framework` we define a number of common classes normally used in tomogr
#### `Algorithm`
- A number of generic algorithm implementations are provided including CGLS and FISTA. An algorithm
- is designed for a particular generic optimisation problem accepts and number of `function`s and/or
- `operator`s as input to define a specific instance of the generic optimisation problem to be solved.
+ A number of generic algorithm implementations are provided including Gradient Descent CGLS and FISTA. An algorithm
+ is designed for a particular generic optimisation problem accepts and number of `Function`s and/or
+ `Operator`s as input to define a specific instance of the generic optimisation problem to be solved.
+
+ They are iterable objects which can be run in a `for` loop. The user can provide a stopping cryterion different than the default max_iteration.
+
+ New algorithms can be easily created by extending the `Algorithm` class. The user is required to implement only 4 methods: `set_up`, `__init__`, `update` and `update_objective`.
+
+ #. `set_up` and `__init__` are used to configure the algorithm
+ #. `update` is the actual iteration updating the solution
+ #. `update_objective` defines how the objective is calculated.
+
+ For example, the implementation of the `update` of the Gradient Descent algorithm to minimise a `Function` will only be:
+ ```python
+ def update(self):
+ self.x += -self.rate * self.objective_function.gradient(self.x)
+ def update_objective(self):
+ self.loss.append(self.objective_function(self.x))
+ ```
+
+ The `Algorithm` provides the infrastructure to continue iteration, to access the values of the objective function in subsequent iterations, the time for each iteration.
#### Examples