pybop.optimisers.base_pints_optimiser#

Classes#

BasePintsOptimiser

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

Module Contents#

class pybop.optimisers.base_pints_optimiser.BasePintsOptimiser(cost, pints_optimiser, **optimiser_kwargs)[source]#

Bases: pybop.BaseOptimiser

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

Parameters:

**optimiser_kwargs (optional) –

Valid PINTS option keys and their values, for example: x0 : array_like

Initial position from which optimization will start.

sigma0float

Initial step size or standard deviation depending on the optimiser.

boundsdict

A dictionary with ‘lower’ and ‘upper’ keys containing arrays for lower and upper bounds on the parameters.

_run()[source]#

Internal method to run the optimization using a PINTS optimiser.

Returns:

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

Return type:

pybop.Result

See also

This

_sanitise_inputs()[source]#

Check and remove any duplicate optimiser options.

_set_up_optimiser()[source]#

Parse optimiser options and create an instance of the PINTS optimiser.

f_guessed_tracking()[source]#

Check if f_guessed instead of f_best is being tracked. Credit: PINTS

Returns:

True if f_guessed is being tracked, False otherwise.

Return type:

bool

name()[source]#

Provides the name of the optimisation strategy.

Returns:

The name given by PINTS.

Return type:

str

set_f_guessed_tracking(use_f_guessed=False)[source]#

Set the method used to track the optimiser progress. Credit: PINTS

Parameters:

use_f_guessed (bool, optional) – If True, track f_guessed; otherwise, track f_best (default: False).

set_max_evaluations(evaluations=None)[source]#

Set a maximum number of evaluations stopping criterion. Credit: PINTS

Parameters:

evaluations (int, optional) – The maximum number of evaluations after which to stop the optimisation (default: None).

set_max_iterations(iterations='default')[source]#

Set the maximum number of iterations as a stopping criterion. Credit: PINTS

Parameters:

iterations (int, optional) – The maximum number of iterations to run. Set to None to remove this stopping criterion.

set_max_unchanged_iterations(iterations=15, absolute_tolerance=1e-05, relative_tolerance=0.01)[source]#

Set the maximum number of iterations without significant change as a stopping criterion. Credit: PINTS

Parameters:
  • iterations (int, optional) – The maximum number of unchanged iterations to run (default: 15). Set to None to remove this stopping criterion.

  • absolute_tolerance (float, optional) – The minimum significant change (absolute tolerance) in the objective function value that resets the unchanged iteration counter (default: 1e-5).

  • relative_tolerance (float, optional) – The minimum significant proportional change (relative tolerance) in the objective function value that resets the unchanged iteration counter (default: 1e-2).

set_min_iterations(iterations=2)[source]#

Set the minimum number of iterations as a stopping criterion.

Parameters:

iterations (int, optional) – The minimum number of iterations to run (default: 2). Set to None to remove this stopping criterion.

set_parallel(parallel=False)[source]#

Enable or disable parallel evaluation. Credit: PINTS

Parameters:

parallel (bool or int, optional) – If True, use as many worker processes as there are CPU cores. If an integer, use that many workers. If False or 0, disable parallelism (default: False).

set_threshold(threshold=None)[source]#

Adds a stopping criterion, allowing the routine to halt once the objective function goes below a set threshold.

This criterion is disabled by default, but can be enabled by calling this method with a valid threshold. To disable it, use set_threshold(None). Credit: PINTS

Parameters:

threshold (float, optional) – The threshold below which the objective function value is considered optimal (default: None).