pybop.optimisers.scipy_optimisers#

Classes#

BaseSciPyOptimiser

A base class for defining optimisation methods from the SciPy library.

SciPyDifferentialEvolution

Adapts SciPy's differential_evolution function for global optimization.

SciPyMinimize

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.BaseOptimiser

A 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.

_run()[source]#

Internal method to run the optimization using a PyBOP optimiser.

Returns:

result – The result of the optimisation including the optimised parameter values and cost.

Return type:

pybop.Result

_sanitise_inputs()[source]#

Check and remove any duplicate optimiser options.

class pybop.optimisers.scipy_optimisers.SciPyDifferentialEvolution(cost, **optimiser_kwargs)[source]#

Bases: BaseSciPyOptimiser

Adapts 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_evolution

The 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

_set_up_optimiser()[source]#

Parse optimiser options.

name()[source]#

Provides the name of the optimization strategy.

Returns:

The name ‘SciPyDifferentialEvolution’.

Return type:

str

class pybop.optimisers.scipy_optimisers.SciPyMinimize(cost, **optimiser_kwargs)[source]#

Bases: BaseSciPyOptimiser

Adapts 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.minimize

The 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

_set_up_optimiser()[source]#

Parse optimiser options.

name()[source]#

Provides the name of the optimization strategy.

Returns:

The name ‘SciPyMinimize’.

Return type:

str