pybop.optimisers.scipy_optimisers#
Classes#
A base class for defining optimisation methods from the SciPy library. |
|
Adapts SciPy's differential_evolution function for global optimization. |
|
Adapts SciPy's minimize function for use as an optimization strategy. |
Module Contents#
- class pybop.optimisers.scipy_optimisers.BaseSciPyOptimiser(cost, **optimiser_kwargs)[source]#
Bases:
pybop.BaseOptimiserA base class for defining optimisation methods from the SciPy library.
- Parameters:
x0 (array_like) – Initial position from which optimisation will start.
bounds (dict, sequence or scipy.optimize.Bounds, optional) – Bounds for variables as supported by the selected method.
**optimiser_kwargs (optional) – Valid SciPy option keys and their values.
- class pybop.optimisers.scipy_optimisers.SciPyDifferentialEvolution(cost, **optimiser_kwargs)[source]#
Bases:
BaseSciPyOptimiserAdapts SciPy’s differential_evolution function for global optimization.
This class provides a global optimization strategy based on differential evolution, useful for problems involving continuous parameters and potentially multiple local minima.
- Parameters:
bounds (dict, sequence or scipy.optimize.Bounds) – Bounds for variables. Must be provided as it is essential for differential evolution.
**optimiser_kwargs (optional) –
Valid SciPy option keys and their values, for example: strategy : str
The differential evolution strategy to use.
- maxiterint
Maximum number of iterations to perform.
- popsizeint
The number of individuals in the population.
See also
scipy.optimize.differential_evolutionThe SciPy method this class is based on.
- _run_optimiser()[source]#
Executes the optimization process using SciPy’s differential_evolution function.
- Returns:
result – The result of the optimisation including the optimised parameter values and cost.
- Return type:
scipy.optimize.OptimizeResult
- class pybop.optimisers.scipy_optimisers.SciPyMinimize(cost, **optimiser_kwargs)[source]#
Bases:
BaseSciPyOptimiserAdapts SciPy’s minimize function for use as an optimization strategy.
This class provides an interface to various scalar minimization algorithms implemented in SciPy, allowing fine-tuning of the optimization process through method selection and option configuration.
- Parameters:
**optimiser_kwargs (optional) –
Valid SciPy Minimize option keys and their values, For example: x0 : array_like
Initial position from which optimisation will start.
- boundsdict, sequence or scipy.optimize.Bounds
Bounds for variables as supported by the selected method.
- methodstr
The optimisation method, options include: ‘Nelder-Mead’, ‘Powell’, ‘CG’, ‘BFGS’, ‘Newton-CG’, ‘L-BFGS-B’, ‘TNC’, ‘COBYLA’, ‘SLSQP’, ‘trust-constr’, ‘dogleg’, ‘trust-ncg’, ‘trust-exact’, ‘trust-krylov’.
See also
scipy.optimize.minimizeThe SciPy method this class is based on.
- _run_optimiser()[source]#
Executes the optimisation process using SciPy’s minimize function.
- Returns:
result – The result of the optimisation including the optimised parameter values and cost.
- Return type:
scipy.optimize.OptimizeResult
- cost_wrapper(x)[source]#
Scale the cost function, preserving the sign convention, and eliminate nan values