optimatic.optimisers package¶
Submodules¶
optimatic.optimisers.differential_evolution module¶
Implements Differential Evolution to find the minimum of a function \(f:\mathbb{R}^n \rightarrow \mathbb{R}\). See https://en.wikipedia.org/wiki/Differential_evolution
-
class
optimatic.optimisers.differential_evolution.
Agent
(dims, search, parent)[source]¶ Bases:
object
-
class
optimatic.optimisers.differential_evolution.
Optimiser
(f, search, cr, F, NP, precision=1e-07, steps=10000)[source]¶ Bases:
optimatic.optimisers.optimiser_base.Optimiser
Parameters: - f – The function being optimised
- search – The min/max value in each dimension to search in. This
should be provided as a nummpy array of the format
[[x_min, x_max], [y_min, y_max], ..]
, where \([x_{min}, x_{max}]\) is the search space in the \(x\) dimension, etc. This should be of length \(n\). - cr – Crossover probability
- F – Differential weight
- NP – Number of agents to use
- precision – Algorithm will stop when \(||\mathbf{x}_n - \mathbf{x}_{n-1}|| < \text{precision}\), where \(\mathbf{x}_n\) and \(\mathbf{x}_{n-1}\) are the positions of the two agents closest to the minimum.
- steps – Max number of iterations to perform
optimatic.optimisers.grad_desc module¶
Gradient descent optimisation
Implements gradient descent to optimise a function \(f:\mathbb{R}^n \rightarrow \mathbb{R}\).
Uses the reccurence relation:
\[\mathbf{x}_n = \mathbf{x}_{n-1} - \gamma_n \nabla f(\mathbf{x}_{n-1})\]
Where
\[\gamma_n = \frac{(\mathbf{x}_n - \mathbf{x}_{n-1}) \cdot (\mathbf{\nabla}f(\mathbf{x}_n) - \mathbf{\nabla} f(\mathbf{x}_{n-1}))}{||\mathbf{\nabla}f(\mathbf{x}_n) - \mathbf{\nabla}f(\mathbf{x}_{n-1})||^2}\]
-
class
optimatic.optimisers.grad_desc.
Optimiser
(f, x0, df=None, gamma=0.1, precision=1e-07, steps=10000)[source]¶ Bases:
optimatic.optimisers.optimiser_base.Optimiser
Parameters: - f – The function to optimise
- x0 – The starting position for the algorithm
- df – The derivative of the function to optimise. If this isn’t
provided, it will be estimated from \(f\) using
central_diff()
- precision – The precision to calculate the minimum to
- gamma – The starting value for \(\gamma\)
- steps – The max number of iterations of the algorithm to run
optimatic.optimisers.optimiser_base module¶
Optimiser base class
All optimiser classes should inherit from this class
-
class
optimatic.optimisers.optimiser_base.
Optimiser
(f, x0, precision=1e-07, steps=10000)[source]¶ Bases:
object
Parameters: - f – The function to optimise
- x0 – The starting position for the algorithm
- precision – The precision to calculate the minimum to
- steps – The max number of iterations of the algorithm to run