pybop.optimisers.base_optimiser#

Classes#

BaseOptimiser

A base class for defining optimisation methods.

OptimisationResult

Stores the result of the optimisation.

OptimiserOptions

A base class for optimiser options.

Module Contents#

class pybop.optimisers.base_optimiser.BaseOptimiser(problem: pybop.problems.problem.Problem, options: OptimiserOptions | None = None)[source]#

A base class for defining optimisation methods.

This class serves as a base class for creating optimisers. It provides a basic structure for an optimisation algorithm, including the initial setup and a method stub for performing the optimisation process. Child classes should override _set_up_optimiser and the _run method with a specific algorithm.

Parameters:
abstractmethod _run() OptimisationResult[source]#

Contains the logic for the optimisation algorithm.

This method should be implemented by child classes to perform the actual optimisation.

Raises:

NotImplementedError – If the method has not been implemented by the subclass.

abstractmethod _set_up_optimiser()[source]#

Parse optimiser options and prepare the optimiser.

This method should be implemented by child classes.

Raises:

NotImplementedError – If the method has not been implemented by the subclass.

static default_options() OptimiserOptions[source]#

Returns the default options for the optimiser.

abstractmethod name() str[source]#

Returns the name of the optimiser, to be overwritten by child classes.

Returns:

The name of the optimiser

Return type:

str

run() OptimisationResult[source]#

Run the optimisation and return the optimised parameters and final cost.

Returns:

result – The pybop optimisation result class.

Return type:

OptimisationResult

_logger = None#
_multistart = 1#
_needs_sensitivities = None#
_options#
_problem#
default_max_iterations = 1000#
property logger: pybop._logging.Logger | None#
property options: OptimiserOptions#

Returns the options for the optimiser.

property problem: pybop.problems.problem.Problem#

Returns the optimisation problem object.

verbose = False#
verbose_print_rate = 50#
class pybop.optimisers.base_optimiser.OptimisationResult(optim: BaseOptimiser, time: float, method_name: str | None = None, message: str | None = None, scipy_result=None)[source]#

Bases: pybop._result.Result

Stores the result of the optimisation.

optim#

The optimisation object used to generate the results.

Type:

pybop.BaseOptimiser

time#

The time taken.

Type:

float

method_name#

The name of the optimiser.

Type:

str

message#

The reason for stopping given by the optimiser.

Type:

str

scipy_result#

The result obtained from a SciPy optimiser.

Type:

scipy.optimize.OptimizeResult, optional

class pybop.optimisers.base_optimiser.OptimiserOptions[source]#

A base class for optimiser options.

multistart#

Number of times to multistart the optimiser.

Type:

int

verbose#

The verbosity level.

Type:

bool

verbose_print_rate#

The distance between iterations to print verbose output.

Type:

int

validate()[source]#

Validate the options.

Raises:

ValueError – If the options are invalid.

multistart: int = 1#
verbose: bool = False#
verbose_print_rate: int = 50#