pybop._optimisation#
Classes#
A class for conducting optimization using PyBOP or PINTS optimisers. |
Module Contents#
- class pybop._optimisation.Optimisation(cost, x0=None, optimiser=None, sigma0=None, verbose=False, physical_viability=True, allow_infeasible_solutions=True)[source]#
A class for conducting optimization using PyBOP or PINTS optimisers.
- Parameters:
cost (pybop.BaseCost or pints.ErrorMeasure) – An objective function to be optimized, which can be either a pybop.Cost or PINTS error measure
optimiser (pybop.Optimiser or subclass of pybop.BaseOptimiser, optional) – An optimiser from either the PINTS or PyBOP framework to perform the optimization (default: None).
sigma0 (float or sequence, optional) – Initial step size or standard deviation for the optimiser (default: None).
verbose (bool, optional) – If True, the optimization progress is printed (default: False).
physical_viability (bool, optional) – If True, the feasibility of the optimised parameters is checked (default: True).
allow_infeasible_solutions (bool, optional) – If True, infeasible parameter values will be allowed in the optimisation (default: True).
- x0#
Initial parameter values for the optimization.
- Type:
numpy.ndarray
- bounds#
Dictionary containing the parameter bounds with keys ‘lower’ and ‘upper’.
- Type:
dict
- _n_parameters#
Number of parameters in the optimization problem.
- Type:
int
- sigma0#
Initial step size or standard deviation for the optimiser.
- Type:
float or sequence
- log#
Log of the optimization process.
- Type:
list
- _run_pints()[source]#
Internal method to run the optimization using a PINTS optimiser.
- Returns:
x (numpy.ndarray) – The best parameter set found by the optimization.
final_cost (float) – The final cost associated with the best parameters.
See also
This
- _run_pybop()[source]#
Internal method to run the optimization using a PyBOP optimiser.
- Returns:
x (numpy.ndarray) – The best parameter set found by the optimization.
final_cost (float) – The final cost associated with the best parameters.
- 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
- run()[source]#
Run the optimization and return the optimized parameters and final cost.
- Returns:
x (numpy.ndarray) – The best parameter set found by the optimization.
final_cost (float) – The final cost associated with the best parameters.
- 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 optimization (default: None).
- set_max_iterations(iterations=1000)[source]#
Set the maximum number of iterations as a stopping criterion. Credit: PINTS
- Parameters:
iterations (int, optional) – The maximum number of iterations to run (default is 1000). Set to None to remove this stopping criterion.
- set_max_unchanged_iterations(iterations=15, threshold=1e-05)[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 is 15). Set to None to remove this stopping criterion.
threshold (float, optional) – The minimum significant change in the objective function value that resets the unchanged iteration counter (default is 1e-5).
- 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 is 100). Set to None to remove this stopping criterion.