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, max_iterations: int = None, min_iterations: int = 2, max_unchanged_iterations: int = 15, multistart: int = 1, parallel: bool = False, **optimiser_kwargs)[source]#

Bases: pybop.BaseOptimiser

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

Parameters:
  • cost (callable) – The cost function to be minimized.

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

  • max_iterations (int, optional) – Maximum number of iterations for the optimisation.

  • min_iterations (int, optional (default=2)) – Minimum number of iterations before termination.

  • max_unchanged_iterations (int, optional (default=15)) – Maximum number of iterations without improvement before termination.

  • parallel (bool, optional (default=False)) – Whether to run the optimisation in parallel.

  • **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.

    use_f_guessedbool

    Whether to track guessed function values.

    absolute_tolerancefloat

    Absolute tolerance for convergence checking.

    relative_tolerancefloat

    Relative tolerance for convergence checking.

    max_evaluationsint

    Maximum number of function evaluations.

    thresholdfloat

    Threshold value for early termination.

_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]#

Returns the name of the PINTS optimisation strategy.

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

_absolute_tolerance = 1e-05[source]#
_boundaries = None[source]#
_callback = None[source]#
_evaluations = None[source]#
_iterations = None[source]#
_max_evaluations = None[source]#
_n_workers = 1[source]#
_needs_sensitivities = None[source]#
_pints_optimiser[source]#
_relative_tolerance = 0.01[source]#
_threshold = None[source]#
_unchanged_max_iterations = 15[source]#
_use_f_guessed = None[source]#
option_methods[source]#