pybop.optimisers.base_pints_optimiser#

Classes#

BasePintsOptimiser

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

PintsOptions

A class to hold PINTS options for the optimisation process.

Module Contents#

class pybop.optimisers.base_pints_optimiser.BasePintsOptimiser(problem: pybop.problems.problem.Problem, pints_optimiser: pints.Optimiser, options: PintsOptions | None = None)[source]#

Bases: pybop.optimisers.base_optimiser.BaseOptimiser

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

Parameters:
  • problem (pybop.Problem) – The problem to minimise.

  • pints_optimiser (pints.Optimiser) – The PINTS optimiser class to be used.

  • options (PintsOptions, optional) – Options for the PINTS optimiser. If None, default options are used.

_run() pybop.OptimisationResult[source]#

Internal method to run the optimisation using a PINTS optimiser.

Returns:

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

Return type:

pybop.OptimisationResult

See also

This

_set_up_optimiser()[source]#

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

static default_options() PintsOptions[source]#

Returns the default options for 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

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: str | int | None = '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_population_size(population_size=None)[source]#

Set the population size for population-based optimisers, if specified.

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

_pints_optimiser[source]#
property iteration[source]#
property max_iterations[source]#

Returns the maximum number of iterations for the optimisation.

property name[source]#

Returns the name of the PINTS optimisation strategy.

property optimiser: pints.Optimiser[source]#
class pybop.optimisers.base_pints_optimiser.PintsOptions[source]#

Bases: pybop.optimisers.base_optimiser.OptimiserOptions

A class to hold PINTS options for the optimisation process.

default_max_iterations[source]#

Default maximum number of iterations (default: 1000).

Type:

int

max_iterations[source]#

Maximum number of iterations for the optimisation (default: None).

Type:

int

min_iterations[source]#

Minimum number of iterations required (default: 2).

Type:

int

max_unchanged_iterations[source]#

Maximum iterations without improvement before stopping (default: 15).

Type:

int

use_f_guessed[source]#

Whether to use guessed function values (default: False).

Type:

bool

absolute_tolerance[source]#

Absolute tolerance for convergence (default: 1e-5).

Type:

float

relative_tolerance[source]#

Relative tolerance for convergence (default: 1e-2).

Type:

float

max_evaluations[source]#

Maximum number of function evaluations (default: None).

Type:

int | None

threshold[source]#

Threshold value for optimisation stopping criteria (default: None).

Type:

float | None

validate()[source]#

Validate the options.

Raises:

ValueError – If the options are invalid.

absolute_tolerance: float = 1e-05[source]#
default_max_iterations = 1000[source]#
max_evaluations: int | None = None[source]#
max_iterations: int = 1000[source]#
max_unchanged_iterations: int = 15[source]#
min_iterations: int = 2[source]#
relative_tolerance: float = 0.01[source]#
threshold: float | None = None[source]#
use_f_guessed: bool = False[source]#