[docs]classBaseProblem:"""
- Defines the PyBOP base problem, following the PINTS interface.
+ Base class for defining a problem within the PyBOP framework, compatible with PINTS.
+
+ Parameters
+ ----------
+ parameters : list
+ List of parameters for the problem.
+ model : object, optional
+ The model to be used for the problem (default: None).
+ check_model : bool, optional
+ Flag to indicate if the model should be checked (default: True).
+ init_soc : float, optional
+ Initial state of charge (default: None).
+ x0 : np.ndarray, optional
+ Initial parameter values (default: None). """def__init__(
@@ -421,6 +459,16 @@
Source code for pybop._problem
defevaluate(self,x):""" Evaluate the model with the given parameters and return the signal.
+
+ Parameters
+ ----------
+ x : np.ndarray
+ Parameter values to evaluate the model at.
+
+ Raises
+ ------
+ NotImplementedError
+ This method must be implemented by subclasses. """raiseNotImplementedError
@@ -429,8 +477,17 @@
Source code for pybop._problem
[docs]defevaluateS1(self,x):"""
- Evaluate the model with the given parameters and return the signal and
- its derivatives.
+ Evaluate the model with the given parameters and return the signal and its derivatives.
+
+ Parameters
+ ----------
+ x : np.ndarray
+ Parameter values to evaluate the model at.
+
+ Raises
+ ------
+ NotImplementedError
+ This method must be implemented by subclasses. """raiseNotImplementedError
@@ -441,7 +498,20 @@
Source code for pybop._problem
[docs]classFittingProblem(BaseProblem):"""
- Defines the problem class for a fitting (parameter estimation) problem.
+ Problem class for fitting (parameter estimation) problems.
+
+ Extends `BaseProblem` with specifics for fitting a model to a dataset.
+
+ Parameters
+ ----------
+ model : object
+ The model to fit.
+ parameters : list
+ List of parameters for the problem.
+ dataset : list
+ List of data objects to fit the model to.
+ signal : str, optional
+ The signal to fit (default: "Voltage [V]"). """def__init__(
@@ -492,6 +562,11 @@
Source code for pybop._problem
defevaluate(self,x):""" Evaluate the model with the given parameters and return the signal.
+
+ Parameters
+ ----------
+ x : np.ndarray
+ Parameter values to evaluate the model at. """y=np.asarray(self._model.simulate(inputs=x,t_eval=self._time_data))
@@ -503,8 +578,12 @@
Source code for pybop._problem
[docs]defevaluateS1(self,x):"""
- Evaluate the model with the given parameters and return the signal and
- its derivatives.
+ Evaluate the model with the given parameters and return the signal and its derivatives.
+
+ Parameters
+ ----------
+ x : np.ndarray
+ Parameter values to evaluate the model at. """y,dy=self._model.simulateS1(
@@ -519,7 +598,12 @@
Source code for pybop._problem
[docs]deftarget(self):"""
- Returns the target dataset.
+ Return the target dataset.
+
+ Returns
+ -------
+ np.ndarray
+ The target dataset array. """returnself._target
@@ -530,7 +614,18 @@
Source code for pybop._problem
[docs]classDesignProblem(BaseProblem):"""
- Defines the problem class for a design optimiation problem.
+ Problem class for design optimization problems.
+
+ Extends `BaseProblem` with specifics for applying a model to an experimental design.
+
+ Parameters
+ ----------
+ model : object
+ The model to apply the design to.
+ parameters : list
+ List of parameters for the problem.
+ experiment : object
+ The experimental setup to apply the model to. """def__init__(
@@ -566,6 +661,11 @@
Source code for pybop._problem
defevaluate(self,x):""" Evaluate the model with the given parameters and return the signal.
+
+ Parameters
+ ----------
+ x : np.ndarray
+ Parameter values to evaluate the model at. """y=np.asarray(self._model.simulate(inputs=x,t_eval=self._time_data))
@@ -577,8 +677,12 @@
Source code for pybop._problem
[docs]defevaluateS1(self,x):"""
- Evaluate the model with the given parameters and return the signal and
- its derivatives.
+ Evaluate the model with the given parameters and return the signal and its derivatives.
+
+ Parameters
+ ----------
+ x : np.ndarray
+ Parameter values to evaluate the model at. """y,dy=self._model.simulateS1(
@@ -593,7 +697,11 @@
Source code for pybop._problem
[docs]deftarget(self):"""
- Returns the target dataset.
+ Return the target dataset (not applicable for design problems).
+
+ Returns
+ -------
+ None """returnself._target
[docs]classOptimisation:"""
- Optimisation class for PyBOP.
- This class provides functionality for PyBOP optimisers and Pints optimisers.
- args:
- cost: PyBOP cost function
- optimiser: A PyBOP or Pints optimiser
- sigma0: initial step size
- verbose: print optimisation progress
-
+ A class for conducting optimization using PyBOP or PINTS optimizers.
+
+ Parameters
+ ----------
+ cost : pints.ErrorMeasure or pints.LogPDF
+ An objective function to be optimized, which can be either a PINTS error measure or log PDF.
+ optimiser : pints.Optimiser or subclass of pybop.BaseOptimizer, optional
+ An optimizer 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 optimizer (default: None).
+ verbose : bool, optional
+ If True, the optimization progress is printed (default: False).
+
+ Attributes
+ ----------
+ x0 : numpy.ndarray
+ Initial parameter values for the optimization.
+ bounds : dict
+ Dictionary containing the parameter bounds with keys 'lower' and 'upper'.
+ n_parameters : int
+ Number of parameters in the optimization problem.
+ sigma0 : float or sequence
+ Initial step size or standard deviation for the optimizer.
+ log : list
+ Log of the optimization process. """def__init__(
@@ -485,11 +527,14 @@
Source code for pybop.optimisation
[docs]defrun(self):"""
- Run the optimisation algorithm.
- Selects between PyBOP backend or Pints backend.
- returns:
- x: best parameters
- final_cost: final cost
+ 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. """ifself.pints:
@@ -508,10 +553,14 @@
Source code for pybop.optimisation
[docs]def_run_pybop(self):"""
- Run method for PyBOP based optimisers.
- returns:
- x: best parameters
- final_cost: final cost
+ Internal method to run the optimization using a PyBOP optimizer.
+
+ Returns
+ -------
+ x : numpy.ndarray
+ The best parameter set found by the optimization.
+ final_cost : float
+ The final cost associated with the best parameters. """x,final_cost=self.optimiser.optimise(cost_function=self.cost,
@@ -528,11 +577,18 @@
Source code for pybop.optimisation
[docs]def_run_pints(self):"""
- Run method for PINTS optimisers.
+ Internal method to run the optimization using a PINTS optimizer.
+
+ 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 method is heavily based on the run method in the PINTS.OptimisationController class.
- returns:
- x: best parameters
- final_cost: final cost """# Check stopping criteria
@@ -707,10 +763,13 @@
Source code for pybop.optimisation
[docs]deff_guessed_tracking(self):"""
- Returns ``True`` if f_guessed instead of f_best is being tracked,
- ``False`` otherwise. See also :meth:`set_f_guessed_tracking`.
-
+ Check if f_guessed instead of f_best is being tracked. Credit: PINTS
+
+ Returns
+ -------
+ bool
+ True if f_guessed is being tracked, False otherwise. """returnself._use_f_guessed
@@ -719,13 +778,13 @@
Source code for pybop.optimisation
[docs]defset_f_guessed_tracking(self,use_f_guessed=False):"""
- Sets the method used to track the optimiser progress to
- :meth:`pints.Optimiser.f_guessed()` or
- :meth:`pints.Optimiser.f_best()` (default).
-
- The tracked ``f`` value is used to evaluate stopping criteria.
-
+ Set the method used to track the optimizer progress. Credit: PINTS
+
+ Parameters
+ ----------
+ use_f_guessed : bool, optional
+ If True, track f_guessed; otherwise, track f_best (default: False). """self._use_f_guessed=bool(use_f_guessed)
@@ -734,13 +793,13 @@
Source code for pybop.optimisation
[docs]defset_max_evaluations(self,evaluations=None):"""
- Adds a stopping criterion, allowing the routine to halt after the
- given number of ``evaluations``.
-
- This criterion is disabled by default. To enable, pass in any positive
- integer. To disable again, use ``set_max_evaluations(None)``.
-
+ 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). """ifevaluationsisnotNone:evaluations=int(evaluations)
@@ -753,16 +812,14 @@
Source code for pybop.optimisation
[docs]defset_parallel(self,parallel=False):"""
- Enables/disables parallel evaluation.
-
- If ``parallel=True``, the method will run using a number of worker
- processes equal to the detected cpu core count. The number of workers
- can be set explicitly by setting ``parallel`` to an integer greater
- than 0.
- Parallelisation can be disabled by setting ``parallel`` to ``0`` or
- ``False``.
-
+ 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). """ifparallelisTrue:self._parallel=True
@@ -779,13 +836,14 @@
Source code for pybop.optimisation
[docs]defset_max_iterations(self,iterations=1000):"""
- Adds a stopping criterion, allowing the routine to halt after the
- given number of ``iterations``.
-
- This criterion is enabled by default. To disable it, use
- ``set_max_iterations(None)``.
-
+ 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. """ifiterationsisnotNone:iterations=int(iterations)
@@ -798,14 +856,16 @@
Source code for pybop.optimisation
[docs]defset_max_unchanged_iterations(self,iterations=25,threshold=1e-5):"""
- Adds a stopping criterion, allowing the routine to halt if the
- objective function doesn't change by more than ``threshold`` for the
- given number of ``iterations``.
-
- This criterion is enabled by default. To disable it, use
- ``set_max_unchanged_iterations(None)``.
-
+ 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 25).
+ 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). """ifiterationsisnotNone:iterations=int(iterations)
@@ -824,7 +884,14 @@
Source code for pybop.optimisation
[docs]defstore_optimised_parameters(self,x):"""
- Store the optimised parameters in the PyBOP parameter class.
+ Update the problem parameters with optimized values.
+
+ The optimized parameter values are stored within the associated PyBOP parameter class.
+
+ Parameters
+ ----------
+ x : array-like
+ Optimized parameter values. """fori,paraminenumerate(self.cost.problem.parameters):param.update(value=x[i])
[docs]defplot_cost2d(cost,bounds=None,optim=None,steps=10):"""
- Query the cost landscape for a given parameter space and plot it using Plotly.
-
- This function creates a 2D plot that visualizes the cost landscape over a grid
- of points within specified parameter bounds. If no bounds are provided, it determines
- them from the bounds on the parameter class.
-
- :param cost: A callable representing the cost function to be queried. It should
- take a list of parameters and return a cost value.
- :type cost: callable
- :param bounds: The bounds for the parameter space as a 2x2 array, with each
- sub-array representing the min and max bounds for a parameter.
- If None, bounds will be determined by `get_param_bounds`.
- :type bounds: numpy.ndarray, optional
- :param optim: An optional optimizer instance. If provided, it will be used to
- overlay optimizer-specific information on the plot.
- :type optim: object, optional
- :param steps: The number of steps to divide the parameter space grid. More steps
- result in finer resolution but increase computational cost.
- :type steps: int, optional
- :return: A Plotly figure object representing the cost landscape plot.
- :rtype: plotly.graph_objs.Figure
-
- :raises ValueError: If the cost function does not behave as expected.
+ Plot a 2D visualization of a cost landscape using Plotly.
+
+ This function generates a contour plot representing the cost landscape for a provided
+ callable cost function over a grid of parameter values within the specified bounds.
+
+ Parameters
+ ----------
+ cost : callable
+ The cost function to be evaluated. Must accept a list of parameters and return a cost value.
+ bounds : numpy.ndarray, optional
+ A 2x2 array specifying the [min, max] bounds for each parameter. If None, uses `get_param_bounds`.
+ optim : object, optional
+ An optimizer instance which, if provided, overlays its specific trace on the plot.
+ steps : int, optional
+ The number of intervals to divide the parameter space into along each dimension (default is 10).
+
+ Returns
+ -------
+ plotly.graph_objs.Figure
+ The Plotly figure object containing the cost landscape plot.
+
+ Raises
+ ------
+ ValueError
+ If the cost function does not return a valid cost when called with a parameter list. """ifboundsisNone:
@@ -437,7 +464,17 @@
Source code for pybop.plotting.plot_cost2d
[docs]defget_param_bounds(cost):"""
- Use parameters bounds for range of cost landscape
+ Retrieve parameter bounds from a cost function's associated problem parameters.
+
+ Parameters
+ ----------
+ cost : callable
+ The cost function with an associated 'problem' attribute containing 'parameters'.
+
+ Returns
+ -------
+ numpy.ndarray
+ An array of shape (n_parameters, 2) containing the bounds for each parameter. """bounds=np.empty((len(cost.problem.parameters),2))fori,paraminenumerate(cost.problem.parameters):
@@ -449,6 +486,30 @@
Source code for pybop.plotting.plot_cost2d
[docs]defcreate_figure(x,y,z,bounds,params,optim):
+"""
+ Create a Plotly figure with a 2D contour plot of the cost landscape.
+
+ Parameters
+ ----------
+ x : numpy.ndarray
+ 1D array of x-coordinates for the meshgrid.
+ y : numpy.ndarray
+ 1D array of y-coordinates for the meshgrid.
+ z : numpy.ndarray
+ 2D array of cost function values corresponding to the meshgrid.
+ bounds : numpy.ndarray
+ A 2x2 array specifying the [min, max] bounds for each parameter.
+ params : iterable
+ An iterable of parameter objects with 'name' attributes for axis labeling.
+ optim : object
+ An optimizer instance with 'log' and 'x0' attributes for plotting traces.
+
+ Returns
+ -------
+ plotly.graph_objs.Figure
+ The Plotly figure object with the contour plot and optimization traces.
+ """
+
# Import plotly only when neededimportplotly.graph_objectsasgo
diff --git a/_modules/pybop/plotting/plot_parameters.html b/_modules/pybop/plotting/plot_parameters.html
index 06ad6ee7..59808270 100644
--- a/_modules/pybop/plotting/plot_parameters.html
+++ b/_modules/pybop/plotting/plot_parameters.html
@@ -44,6 +44,7 @@
+
@@ -205,6 +206,18 @@
+
+ PyPI
+
+
optim,xaxis_titles="Iteration",yaxis_titles=None,title="Convergence"):"""
- Plot the evolution of the parameters during the optimisation process.
-
- Parameters:
- ------------
- optim : optimisation object
- An object representing the optimisation process, which should contain
- information about the cost function, optimiser, and the history of the
- parameter values throughout the iterations.
- xaxis_title : str, optional
- Title for the x-axis, representing the iteration number or a similar
- discrete time step in the optimisation process (default is "Iteration").
- yaxis_title : str, optional
- Title for the y-axis, which typically represents the metric being
- optimised, such as cost or loss (default is "Cost").
- title : str, optional
- Title of the plot, which provides an overall description of what the
- plot represents (default is "Convergence").
+ Plot the evolution of parameters during the optimization process using Plotly.
- Returns:
+ Parameters ----------
- fig : plotly.graph_objs.Figure
- The Plotly figure object for the plot depicting how the parameters of
- the optimisation algorithm evolve over its course. This can be useful
- for diagnosing the behaviour of the optimisation algorithm.
+ optim : object
+ The optimization object containing the history of parameter values and associated cost.
+ xaxis_titles : str, optional
+ Title for the x-axis, defaulting to "Iteration".
+ yaxis_titles : list of str, optional
+ Titles for the y-axes, one for each parameter. If None, parameter names are used.
+ title : str, optional
+ Title of the plot, defaulting to "Convergence".
- Notes:
- ----------
- The function assumes that the 'optim' object has a 'cost.problem.parameters'
- attribute containing the parameters of the optimisation algorithm and a 'log'
- attribute containing a history of the iterations.
+ Returns
+ -------
+ plotly.graph_objs.Figure
+ A Plotly figure object showing the parameter evolution over iterations. """# Extract parameters from the optimisation object
@@ -440,26 +452,21 @@
Source code for pybop.plotting.plot_parameters
[docs]
defcreate_traces(params,trace_data,x_values=None):"""
- Generate a list of Plotly Scatter trace objects from provided trace data.
-
- This function assumes that each column in the ``trace_data`` represents a separate trace to be plotted,
- and that the ``params`` list contains objects with a ``name`` attribute used for trace names.
- Text wrapping for trace names is performed by ``pybop.StandardPlot.wrap_text``.
-
- Parameters:
- - params (list): A list of objects, where each object has a ``name`` attribute used as the trace name.
- The list should have the same length as the number of traces in ``trace_data``.
- - trace_data (list of lists): A 2D list where each inner list represents y-values for a trace.
- - x_values (list, optional): A list of x-values to be used for all traces. If not provided, a
- range of integers starting from 0 will be used.
-
- Returns:
- - list: A list of Plotly ``go.Scatter`` objects, each representing a trace to be plotted.
-
- Notes:
- - The function depends on ``pybop.StandardPlot.wrap_text`` for text wrapping, which needs to be available
- in the execution context.
- - The function assumes that ``go`` from ``plotly.graph_objs`` is already imported as ``go``.
+ Create traces for plotting parameter evolution.
+
+ Parameters
+ ----------
+ params : list
+ List of parameter objects, each having a 'name' attribute used for labeling the trace.
+ trace_data : list of numpy.ndarray
+ A list of arrays representing the historical values of each parameter.
+ x_values : list or numpy.ndarray, optional
+ The x-axis values for plotting. If None, defaults to sequential integers.
+
+ Returns
+ -------
+ list of plotly.graph_objs.Scatter
+ A list of Scatter trace objects, one for each parameter. """# Attempt to import plotly when an instance is created
@@ -504,14 +511,25 @@
Source code for pybop.plotting.plot_parameters
**layout_kwargs,):"""
- Creates a subplot figure with the given traces.
-
- :param traces: List of plotly.graph_objs traces that will be added to the subplots.
- :param plot_size: Tuple (width, height) representing the desired size of the plot.
- :param title: The main title of the subplot figure.
- :param axis_titles: List of tuples for axis titles in the form [(x_title, y_title), ...] for each subplot.
- :param layout_kwargs: Additional keyword arguments to be passed to fig.update_layout for custom layout.
- :return: A plotly figure object with the subplots.
+ Create a subplot with individual traces for each parameter.
+
+ Parameters
+ ----------
+ traces : list of plotly.graph_objs.Scatter
+ Traces to be plotted, one trace per subplot.
+ plot_size : tuple of int, optional
+ The size of the plot as (width, height), defaulting to (1024, 576).
+ title : str, optional
+ The title of the plot, defaulting to "Parameter Convergence".
+ axis_titles : list of tuple of str, optional
+ A list of (x_title, y_title) pairs for each subplot. If None, titles are omitted.
+ **layout_kwargs : dict
+ Additional keyword arguments to customize the layout.
+
+ Returns
+ -------
+ plotly.graph_objs.Figure
+ A Plotly figure object with subplots for each trace. """# Attempt to import plotly when an instance is created
diff --git a/_modules/pybop/plotting/plotly_manager.html b/_modules/pybop/plotting/plotly_manager.html
index 92c90344..73f751b2 100644
--- a/_modules/pybop/plotting/plotly_manager.html
+++ b/_modules/pybop/plotting/plotly_manager.html
@@ -44,6 +44,7 @@
+
@@ -205,6 +206,18 @@
+
+ PyPI
+
+
[docs]
classPlotlyManager:"""
- Manages the installation and configuration of Plotly for generating visualisations.
-
- This class checks if Plotly is installed and, if not, prompts the user to install it.
- It also ensures that the Plotly renderer and browser settings are properly configured
- to display plots.
-
- Methods:
- ``ensure_plotly_installed``: Verifies if Plotly is installed and installs it if necessary.
- ``prompt_for_plotly_installation``: Prompts the user for permission to install Plotly.
- ``install_plotly_package``: Installs the Plotly package using pip.
- ``post_install_setup``: Sets up Plotly default renderer after installation.
- ``check_renderer_settings``: Verifies that the Plotly renderer is correctly set.
- ``check_browser_availability``: Checks if a web browser is available for rendering plots.
-
- Usage:
- Instantiate the PlotlyManager class to automatically ensure Plotly is installed
- and configured correctly when creating an instance.
- Example:
- plotly_manager = PlotlyManager()
+ Manages the installation and configuration of Plotly for generating visualizations.
+
+ This class ensures that Plotly is installed and properly configured to display
+ plots in a web browser.
+
+ Upon instantiation, it checks for Plotly's presence, installs it if missing,
+ and configures the default renderer and browser settings.
+
+ Attributes
+ ----------
+ go : module
+ The Plotly graph_objects module for creating figures.
+ pio : module
+ The Plotly input/output module for configuring the renderer.
+ make_subplots : function
+ The function from Plotly for creating subplot figures.
+
+ Methods
+ -------
+ ensure_plotly_installed()
+ Verifies if Plotly is installed, importing necessary modules and prompting for installation if missing.
+ prompt_for_plotly_installation()
+ Prompts the user for permission to install Plotly and proceeds with installation if consented.
+ install_plotly()
+ Installs the Plotly package using pip.
+ post_install_setup()
+ Sets up Plotly default renderer after installation.
+ check_renderer_settings()
+ Verifies that the Plotly renderer is correctly set.
+ check_browser_availability()
+ Checks if a web browser is available for rendering plots.
+
+ Examples
+ --------
+ >>> plotly_manager = PlotlyManager() """def__init__(self):
+"""
+ Initialize the PlotlyManager, ensuring Plotly is installed and configured.
+ """self.go=Noneself.pio=Noneself.make_subplots=None
@@ -414,7 +458,9 @@
Source code for pybop.plotting.plotly_manager
[docs]defensure_plotly_installed(self):
-"""Verifies if Plotly is installed, importing necessary modules and prompting for installation if missing."""
+"""
+ Check if Plotly is installed and import necessary modules; prompt for installation if missing.
+ """try:importplotly.graph_objsasgoimportplotly.ioaspio
@@ -430,7 +476,9 @@
Source code for pybop.plotting.plotly_manager
[docs]defprompt_for_plotly_installation(self):
-"""Prompts the user for permission to install Plotly and proceeds with installation if consented."""
+"""
+ Prompt the user for Plotly installation and install it upon agreement.
+ """user_input=(input("Plotly is not installed. To proceed, we need to install plotly. (Y/n)? "
@@ -449,7 +497,9 @@
Source code for pybop.plotting.plotly_manager
[docs]definstall_plotly(self):
-"""Attempts to install the Plotly package using pip and exits if installation fails."""
+"""
+ Install the Plotly package using pip. Exit if installation fails.
+ """try:subprocess.check_call([sys.executable,"-m","pip","install","plotly"])exceptsubprocess.CalledProcessErrorase:
@@ -460,7 +510,9 @@
Source code for pybop.plotting.plotly_manager
[docs]defpost_install_setup(self):
-"""After successful installation, imports Plotly and sets the default renderer if necessary."""
+"""
+ Import Plotly modules and set the default renderer after installation.
+ """importplotly.graph_objsasgoimportplotly.ioaspiofromplotly.subplotsimportmake_subplots
@@ -478,7 +530,9 @@
Source code for pybop.plotting.plotly_manager
[docs]defcheck_renderer_settings(self):
-"""Checks if the Plotly renderer is set and provides information on how to set it if empty."""
+"""
+ Check and provide information on setting the Plotly renderer if it's not already set.
+ """ifself.pioandself.pio.renderers.default=="":print("The Plotly renderer is an empty string. To set the renderer, use:\n"
@@ -491,7 +545,9 @@
Source code for pybop.plotting.plotly_manager
[docs]defcheck_browser_availability(self):
-"""Ensures a web browser is available for rendering plots with the 'browser' renderer and provides guidance if not."""
+"""
+ Confirm a web browser is available for Plotly's 'browser' renderer; provide guidance if not.
+ """ifself.pioandself.pio.renderers.default=="browser":try:webbrowser.get()
diff --git a/_modules/pybop/plotting/quick_plot.html b/_modules/pybop/plotting/quick_plot.html
index c3663e2f..c7127b02 100644
--- a/_modules/pybop/plotting/quick_plot.html
+++ b/_modules/pybop/plotting/quick_plot.html
@@ -44,6 +44,7 @@
+
@@ -205,6 +206,18 @@
+
+ PyPI
+
+
[docs]classStandardPlot:"""
- A class for creating and displaying a plotly figure that compares a target dataset against a simulated model output.
+ A class for creating and displaying Plotly figures for model output comparison.
- This class provides an interface for generating interactive plots using Plotly, with the ability to include an
- optional secondary dataset and visualize uncertainty if provided.
+ Generates interactive plots comparing simulated model output with an optional target dataset and visualizes uncertainty.
- Attributes:
- -----------
- x : list
- The x-axis data points.
+ Parameters
+ ----------
+ x : list or np.ndarray
+ X-axis data points. y : list or np.ndarray
- The primary y-axis data points representing the simulated model output.
- y2 : list or np.ndarray, optional
- An optional secondary y-axis data points representing the target dataset against which the model output is compared.
+ Primary Y-axis data points for simulated model output. cost : float
- The cost associated with the model output.
+ Cost associated with the model output.
+ y2 : list or np.ndarray, optional
+ Secondary Y-axis data points for the target dataset (default: None). title : str, optional
- The title of the plot.
+ Title of the plot (default: None). xaxis_title : str, optional
- The title for the x-axis.
+ Title for the x-axis (default: None). yaxis_title : str, optional
- The title for the y-axis.
+ Title for the y-axis (default: None). trace_name : str, optional
- The name of the primary trace representing the model output. Defaults to "Simulated".
+ Name for the primary trace (default: "Simulated"). width : int, optional
- The width of the figure in pixels. Defaults to 720.
+ Width of the figure in pixels (default: 1024). height : int, optional
- The height of the figure in pixels. Defaults to 540.
-
- Example:
- ----------
- >>> x_data = [1, 2, 3, 4]
- >>> y_simulated = [10, 15, 13, 17]
- >>> y_target = [11, 14, 12, 16]
- >>> plot = pybop.StandardPlot(x_data, y_simulated, cost=0.05, y2=y_target,
- title="Model vs. Target", xaxis_title="X Axis", yaxis_title="Y Axis")
- >>> fig = plot() # Generate the figure
- >>> fig.show() # Display the figure in a browser
+ Height of the figure in pixels (default: 576). """def__init__(
@@ -434,6 +448,32 @@
Source code for pybop.plotting.quick_plot
width=1024,height=576,):
+"""
+ Initialize the StandardPlot object with simulation and optional target data.
+
+ Parameters
+ ----------
+ x : list or np.ndarray
+ X-axis data points.
+ y : list or np.ndarray
+ Primary Y-axis data points for simulated model output.
+ cost : float
+ Cost associated with the model output.
+ y2 : list or np.ndarray, optional
+ Secondary Y-axis data points for target dataset (default: None).
+ title : str, optional
+ Plot title (default: None).
+ xaxis_title : str, optional
+ X-axis title (default: None).
+ yaxis_title : str, optional
+ Y-axis title (default: None).
+ trace_name : str, optional
+ Name for the primary trace (default: "Simulated").
+ width : int, optional
+ Figure width in pixels (default: 1024).
+ height : int, optional
+ Figure height in pixels (default: 576).
+ """self.x=xifisinstance(x,list)elsex.tolist()self.y=yself.y2=y2
@@ -458,19 +498,19 @@
Source code for pybop.plotting.quick_plot
[docs]defwrap_text(text,width):"""
- Wrap text to a specified width.
-
- Parameters:
- -----------
- text: str
- Text to be wrapped.
- width: int
- Width to wrap text to.
+ Wrap text to a specified width with HTML line breaks.
- Returns:
+ Parameters ----------
+ text : str
+ The text to wrap.
+ width : int
+ The width to wrap the text to.
+
+ Returns
+ ------- str
- Wrapped text with HTML line breaks.
+ The wrapped text. """wrapped_text=textwrap.fill(text,width=width,break_long_words=False)returnwrapped_text.replace("\n","<br>")
@@ -480,7 +520,12 @@
Source code for pybop.plotting.quick_plot
[docs]defcreate_layout(self):"""
- Create the layout for the plot.
+ Create the layout for the Plotly figure.
+
+ Returns
+ -------
+ plotly.graph_objs.Layout
+ The layout for the Plotly figure. """returnself.go.Layout(title=self.title,
@@ -500,7 +545,12 @@
Source code for pybop.plotting.quick_plot
[docs]defcreate_traces(self):"""
- Create the traces for the plot.
+ Create traces for the Plotly figure.
+
+ Returns
+ -------
+ list
+ A list of plotly.graph_objs.Scatter objects to be used as traces. """traces=[]
@@ -537,7 +587,12 @@
Source code for pybop.plotting.quick_plot
[docs]def__call__(self):"""
- Generate the plotly figure.
+ Generate the Plotly figure.
+
+ Returns
+ -------
+ plotly.graph_objs.Figure
+ The generated Plotly figure. """layout=self.create_layout()traces=self.create_traces()
@@ -551,24 +606,24 @@
Source code for pybop.plotting.quick_plot
[docs]defquick_plot(params,cost,title="Scatter Plot",width=1024,height=576):"""
- Plot the target dataset against the minimised model output.
+ Quickly plot the target dataset against minimized model output.
- Parameters:
- -----------
+ Parameters
+ ---------- params : array-like
- Optimised parameters.
- cost : cost object
- Cost object containing the problem, dataset, and signal.
+ Optimized parameters.
+ cost : object
+ Cost object with problem, dataset, and signal attributes. title : str, optional
- Title of the plot (default is "Scatter Plot").
+ Title of the plot (default: "Scatter Plot"). width : int, optional
- Width of the figure in pixels (default is 720).
+ Width of the figure in pixels (default: 1024). height : int, optional
- Height of the figure in pixels (default is 540).
+ Height of the figure in pixels (default: 576).
- Returns:
- ----------
- fig : plotly.graph_objs.Figure
+ Returns
+ -------
+ plotly.graph_objs.Figure The Plotly figure object for the scatter plot. """
diff --git a/_modules/pybop/version.html b/_modules/pybop/version.html
index e97e75cb..fd0ab4fa 100644
--- a/_modules/pybop/version.html
+++ b/_modules/pybop/version.html
@@ -44,6 +44,7 @@
+
@@ -205,6 +206,18 @@
+
+ PyPI
+
+
diff --git a/_sources/api/pybop/_problem/index.rst.txt b/_sources/api/pybop/_problem/index.rst.txt
index a08285e3..c36de4d6 100644
--- a/_sources/api/pybop/_problem/index.rst.txt
+++ b/_sources/api/pybop/_problem/index.rst.txt
@@ -22,19 +22,39 @@ Classes
.. py:class:: BaseProblem(parameters, model=None, check_model=True, init_soc=None, x0=None)
- Defines the PyBOP base problem, following the PINTS interface.
+ Base class for defining a problem within the PyBOP framework, compatible with PINTS.
+
+ :param parameters: List of parameters for the problem.
+ :type parameters: list
+ :param model: The model to be used for the problem (default: None).
+ :type model: object, optional
+ :param check_model: Flag to indicate if the model should be checked (default: True).
+ :type check_model: bool, optional
+ :param init_soc: Initial state of charge (default: None).
+ :type init_soc: float, optional
+ :param x0: Initial parameter values (default: None).
+ :type x0: np.ndarray, optional
.. py:method:: evaluate(x)
:abstractmethod:
Evaluate the model with the given parameters and return the signal.
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
+
+ :raises NotImplementedError: This method must be implemented by subclasses.
+
.. py:method:: evaluateS1(x)
:abstractmethod:
- Evaluate the model with the given parameters and return the signal and
- its derivatives.
+ Evaluate the model with the given parameters and return the signal and its derivatives.
+
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
+
+ :raises NotImplementedError: This method must be implemented by subclasses.
@@ -43,22 +63,38 @@ Classes
Bases: :py:obj:`BaseProblem`
- Defines the problem class for a design optimiation problem.
+ Problem class for design optimization problems.
+
+ Extends `BaseProblem` with specifics for applying a model to an experimental design.
+
+ :param model: The model to apply the design to.
+ :type model: object
+ :param parameters: List of parameters for the problem.
+ :type parameters: list
+ :param experiment: The experimental setup to apply the model to.
+ :type experiment: object
.. py:method:: evaluate(x)
Evaluate the model with the given parameters and return the signal.
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
+
.. py:method:: evaluateS1(x)
- Evaluate the model with the given parameters and return the signal and
- its derivatives.
+ Evaluate the model with the given parameters and return the signal and its derivatives.
+
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
.. py:method:: target()
- Returns the target dataset.
+ Return the target dataset (not applicable for design problems).
+
+ :rtype: None
@@ -67,22 +103,41 @@ Classes
Bases: :py:obj:`BaseProblem`
- Defines the problem class for a fitting (parameter estimation) problem.
+ Problem class for fitting (parameter estimation) problems.
+
+ Extends `BaseProblem` with specifics for fitting a model to a dataset.
+
+ :param model: The model to fit.
+ :type model: object
+ :param parameters: List of parameters for the problem.
+ :type parameters: list
+ :param dataset: List of data objects to fit the model to.
+ :type dataset: list
+ :param signal: The signal to fit (default: "Voltage [V]").
+ :type signal: str, optional
.. py:method:: evaluate(x)
Evaluate the model with the given parameters and return the signal.
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
+
.. py:method:: evaluateS1(x)
- Evaluate the model with the given parameters and return the signal and
- its derivatives.
+ Evaluate the model with the given parameters and return the signal and its derivatives.
+
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
.. py:method:: target()
- Returns the target dataset.
+ Return the target dataset.
+
+ :returns: The target dataset array.
+ :rtype: np.ndarray
diff --git a/_sources/api/pybop/index.rst.txt b/_sources/api/pybop/index.rst.txt
index b0fb627f..7df4544a 100644
--- a/_sources/api/pybop/index.rst.txt
+++ b/_sources/api/pybop/index.rst.txt
@@ -446,22 +446,38 @@ Attributes
Bases: :py:obj:`BaseProblem`
- Defines the problem class for a design optimiation problem.
+ Problem class for design optimization problems.
+
+ Extends `BaseProblem` with specifics for applying a model to an experimental design.
+
+ :param model: The model to apply the design to.
+ :type model: object
+ :param parameters: List of parameters for the problem.
+ :type parameters: list
+ :param experiment: The experimental setup to apply the model to.
+ :type experiment: object
.. py:method:: evaluate(x)
Evaluate the model with the given parameters and return the signal.
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
+
.. py:method:: evaluateS1(x)
- Evaluate the model with the given parameters and return the signal and
- its derivatives.
+ Evaluate the model with the given parameters and return the signal and its derivatives.
+
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
.. py:method:: target()
- Returns the target dataset.
+ Return the target dataset (not applicable for design problems).
+
+ :rtype: None
@@ -522,22 +538,41 @@ Attributes
Bases: :py:obj:`BaseProblem`
- Defines the problem class for a fitting (parameter estimation) problem.
+ Problem class for fitting (parameter estimation) problems.
+
+ Extends `BaseProblem` with specifics for fitting a model to a dataset.
+
+ :param model: The model to fit.
+ :type model: object
+ :param parameters: List of parameters for the problem.
+ :type parameters: list
+ :param dataset: List of data objects to fit the model to.
+ :type dataset: list
+ :param signal: The signal to fit (default: "Voltage [V]").
+ :type signal: str, optional
.. py:method:: evaluate(x)
Evaluate the model with the given parameters and return the signal.
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
+
.. py:method:: evaluateS1(x)
- Evaluate the model with the given parameters and return the signal and
- its derivatives.
+ Evaluate the model with the given parameters and return the signal and its derivatives.
+
+ :param x: Parameter values to evaluate the model at.
+ :type x: np.ndarray
.. py:method:: target()
- Returns the target dataset.
+ Return the target dataset.
+
+ :returns: The target dataset array.
+ :rtype: np.ndarray
@@ -711,109 +746,140 @@ Attributes
.. py:class:: Optimisation(cost, optimiser=None, sigma0=None, verbose=False)
- Optimisation class for PyBOP.
- This class provides functionality for PyBOP optimisers and Pints optimisers.
- :param cost: PyBOP cost function
- :param optimiser: A PyBOP or Pints optimiser
- :param sigma0: initial step size
- :param verbose: print optimisation progress
+ A class for conducting optimization using PyBOP or PINTS optimizers.
- .. py:method:: _run_pints()
+ :param cost: An objective function to be optimized, which can be either a PINTS error measure or log PDF.
+ :type cost: pints.ErrorMeasure or pints.LogPDF
+ :param optimiser: An optimizer from either the PINTS or PyBOP framework to perform the optimization (default: None).
+ :type optimiser: pints.Optimiser or subclass of pybop.BaseOptimizer, optional
+ :param sigma0: Initial step size or standard deviation for the optimizer (default: None).
+ :type sigma0: float or sequence, optional
+ :param verbose: If True, the optimization progress is printed (default: False).
+ :type verbose: bool, optional
- Run method for PINTS optimisers.
- This method is heavily based on the run method in the PINTS.OptimisationController class.
- :returns: best parameters
- final_cost: final cost
- :rtype: x
+ .. attribute:: x0
+ Initial parameter values for the optimization.
- .. py:method:: _run_pybop()
+ :type: numpy.ndarray
- Run method for PyBOP based optimisers.
- :returns: best parameters
- final_cost: final cost
- :rtype: x
+ .. attribute:: bounds
+ Dictionary containing the parameter bounds with keys 'lower' and 'upper'.
- .. py:method:: f_guessed_tracking()
+ :type: dict
- Returns ``True`` if f_guessed instead of f_best is being tracked,
- ``False`` otherwise. See also :meth:`set_f_guessed_tracking`.
+ .. attribute:: n_parameters
- Credit: PINTS
+ Number of parameters in the optimization problem.
+ :type: int
- .. py:method:: run()
+ .. attribute:: sigma0
- Run the optimisation algorithm.
- Selects between PyBOP backend or Pints backend.
- :returns: best parameters
- final_cost: final cost
- :rtype: x
+ Initial step size or standard deviation for the optimizer.
+ :type: float or sequence
- .. py:method:: set_f_guessed_tracking(use_f_guessed=False)
+ .. attribute:: log
- Sets the method used to track the optimiser progress to
- :meth:`pints.Optimiser.f_guessed()` or
- :meth:`pints.Optimiser.f_best()` (default).
+ Log of the optimization process.
- The tracked ``f`` value is used to evaluate stopping criteria.
+ :type: list
- Credit: PINTS
+ .. py:method:: _run_pints()
+ Internal method to run the optimization using a PINTS optimizer.
- .. py:method:: set_max_evaluations(evaluations=None)
+ :returns: * **x** (*numpy.ndarray*) -- The best parameter set found by the optimization.
+ * **final_cost** (*float*) -- The final cost associated with the best parameters.
+
+ .. seealso:: :obj:`This`
- Adds a stopping criterion, allowing the routine to halt after the
- given number of ``evaluations``.
- This criterion is disabled by default. To enable, pass in any positive
- integer. To disable again, use ``set_max_evaluations(None)``.
+ .. py:method:: _run_pybop()
+ Internal method to run the optimization using a PyBOP optimizer.
+
+ :returns: * **x** (*numpy.ndarray*) -- The best parameter set found by the optimization.
+ * **final_cost** (*float*) -- The final cost associated with the best parameters.
+
+
+ .. py:method:: f_guessed_tracking()
+
+ Check if f_guessed instead of f_best is being tracked.
Credit: PINTS
+ :returns: True if f_guessed is being tracked, False otherwise.
+ :rtype: bool
- .. py:method:: set_max_iterations(iterations=1000)
- Adds a stopping criterion, allowing the routine to halt after the
- given number of ``iterations``.
+ .. py:method:: run()
+
+ 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.
- This criterion is enabled by default. To disable it, use
- ``set_max_iterations(None)``.
+ .. py:method:: set_f_guessed_tracking(use_f_guessed=False)
+
+ Set the method used to track the optimizer progress.
Credit: PINTS
+ :param use_f_guessed: If True, track f_guessed; otherwise, track f_best (default: False).
+ :type use_f_guessed: bool, optional
- .. py:method:: set_max_unchanged_iterations(iterations=25, threshold=1e-05)
- Adds a stopping criterion, allowing the routine to halt if the
- objective function doesn't change by more than ``threshold`` for the
- given number of ``iterations``.
+ .. py:method:: set_max_evaluations(evaluations=None)
+
+ Set a maximum number of evaluations stopping criterion.
+ Credit: PINTS
- This criterion is enabled by default. To disable it, use
- ``set_max_unchanged_iterations(None)``.
+ :param evaluations: The maximum number of evaluations after which to stop the optimization (default: None).
+ :type evaluations: int, optional
+
+
+ .. py:method:: set_max_iterations(iterations=1000)
+ Set the maximum number of iterations as a stopping criterion.
Credit: PINTS
+ :param iterations: The maximum number of iterations to run (default is 1000).
+ Set to `None` to remove this stopping criterion.
+ :type iterations: int, optional
- .. py:method:: set_parallel(parallel=False)
- Enables/disables parallel evaluation.
+ .. py:method:: set_max_unchanged_iterations(iterations=25, threshold=1e-05)
+
+ Set the maximum number of iterations without significant change as a stopping criterion.
+ Credit: PINTS
- If ``parallel=True``, the method will run using a number of worker
- processes equal to the detected cpu core count. The number of workers
- can be set explicitly by setting ``parallel`` to an integer greater
- than 0.
- Parallelisation can be disabled by setting ``parallel`` to ``0`` or
- ``False``.
+ :param iterations: The maximum number of unchanged iterations to run (default is 25).
+ Set to `None` to remove this stopping criterion.
+ :type iterations: int, optional
+ :param threshold: The minimum significant change in the objective function value that resets the unchanged iteration counter (default is 1e-5).
+ :type threshold: float, optional
+
+
+ .. py:method:: set_parallel(parallel=False)
+ Enable or disable parallel evaluation.
Credit: PINTS
+ :param parallel: 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).
+ :type parallel: bool or int, optional
+
.. py:method:: store_optimised_parameters(x)
- Store the optimised parameters in the PyBOP parameter class.
+ Update the problem parameters with optimized values.
+
+ The optimized parameter values are stored within the associated PyBOP parameter class.
+
+ :param x: Optimized parameter values.
+ :type x: array-like
@@ -1002,54 +1068,89 @@ Attributes
.. py:class:: PlotlyManager
- Manages the installation and configuration of Plotly for generating visualisations.
+ Manages the installation and configuration of Plotly for generating visualizations.
+
+ This class ensures that Plotly is installed and properly configured to display
+ plots in a web browser.
+
+ Upon instantiation, it checks for Plotly's presence, installs it if missing,
+ and configures the default renderer and browser settings.
- This class checks if Plotly is installed and, if not, prompts the user to install it.
- It also ensures that the Plotly renderer and browser settings are properly configured
- to display plots.
+ .. attribute:: go
- Methods:
- ``ensure_plotly_installed``: Verifies if Plotly is installed and installs it if necessary.
- ``prompt_for_plotly_installation``: Prompts the user for permission to install Plotly.
- ``install_plotly_package``: Installs the Plotly package using pip.
- ``post_install_setup``: Sets up Plotly default renderer after installation.
- ``check_renderer_settings``: Verifies that the Plotly renderer is correctly set.
- ``check_browser_availability``: Checks if a web browser is available for rendering plots.
+ The Plotly graph_objects module for creating figures.
- Usage:
- Instantiate the PlotlyManager class to automatically ensure Plotly is installed
- and configured correctly when creating an instance.
- Example:
- plotly_manager = PlotlyManager()
+ :type: module
+
+ .. attribute:: pio
+
+ The Plotly input/output module for configuring the renderer.
+
+ :type: module
+
+ .. attribute:: make_subplots
+
+ The function from Plotly for creating subplot figures.
+
+ :type: function
+
+ .. method:: ensure_plotly_installed()
+
+ Verifies if Plotly is installed, importing necessary modules and prompting for installation if missing.
+
+ .. method:: prompt_for_plotly_installation()
+
+ Prompts the user for permission to install Plotly and proceeds with installation if consented.
+
+ .. method:: install_plotly()
+
+ Installs the Plotly package using pip.
+
+ .. method:: post_install_setup()
+
+ Sets up Plotly default renderer after installation.
+
+ .. method:: check_renderer_settings()
+
+ Verifies that the Plotly renderer is correctly set.
+
+ .. method:: check_browser_availability()
+
+ Checks if a web browser is available for rendering plots.
+
+
+ .. rubric:: Examples
+
+ >>> plotly_manager = PlotlyManager()
.. py:method:: check_browser_availability()
- Ensures a web browser is available for rendering plots with the 'browser' renderer and provides guidance if not.
+ Confirm a web browser is available for Plotly's 'browser' renderer; provide guidance if not.
.. py:method:: check_renderer_settings()
- Checks if the Plotly renderer is set and provides information on how to set it if empty.
+ Check and provide information on setting the Plotly renderer if it's not already set.
.. py:method:: ensure_plotly_installed()
- Verifies if Plotly is installed, importing necessary modules and prompting for installation if missing.
+ Check if Plotly is installed and import necessary modules; prompt for installation if missing.
.. py:method:: install_plotly()
- Attempts to install the Plotly package using pip and exits if installation fails.
+ Install the Plotly package using pip. Exit if installation fails.
.. py:method:: post_install_setup()
- After successful installation, imports Plotly and sets the default renderer if necessary.
+ Import Plotly modules and set the default renderer after installation.
.. py:method:: prompt_for_plotly_installation()
- Prompts the user for permission to install Plotly and proceeds with installation if consented.
+ Prompt the user for Plotly installation and install it upon agreement.
@@ -1209,75 +1310,67 @@ Attributes
.. py:class:: StandardPlot(x, y, cost, y2=None, title=None, xaxis_title=None, yaxis_title=None, trace_name=None, width=1024, height=576)
- A class for creating and displaying a plotly figure that compares a target dataset against a simulated model output.
-
- This class provides an interface for generating interactive plots using Plotly, with the ability to include an
- optional secondary dataset and visualize uncertainty if provided.
-
- Attributes:
- -----------
- x : list
- The x-axis data points.
- y : list or np.ndarray
- The primary y-axis data points representing the simulated model output.
- y2 : list or np.ndarray, optional
- An optional secondary y-axis data points representing the target dataset against which the model output is compared.
- cost : float
- The cost associated with the model output.
- title : str, optional
- The title of the plot.
- xaxis_title : str, optional
- The title for the x-axis.
- yaxis_title : str, optional
- The title for the y-axis.
- trace_name : str, optional
- The name of the primary trace representing the model output. Defaults to "Simulated".
- width : int, optional
- The width of the figure in pixels. Defaults to 720.
- height : int, optional
- The height of the figure in pixels. Defaults to 540.
-
- Example:
- ----------
- >>> x_data = [1, 2, 3, 4]
- >>> y_simulated = [10, 15, 13, 17]
- >>> y_target = [11, 14, 12, 16]
- >>> plot = pybop.StandardPlot(x_data, y_simulated, cost=0.05, y2=y_target,
- title="Model vs. Target", xaxis_title="X Axis", yaxis_title="Y Axis")
- >>> fig = plot() # Generate the figure
- >>> fig.show() # Display the figure in a browser
+ A class for creating and displaying Plotly figures for model output comparison.
+
+ Generates interactive plots comparing simulated model output with an optional target dataset and visualizes uncertainty.
+
+ :param x: X-axis data points.
+ :type x: list or np.ndarray
+ :param y: Primary Y-axis data points for simulated model output.
+ :type y: list or np.ndarray
+ :param cost: Cost associated with the model output.
+ :type cost: float
+ :param y2: Secondary Y-axis data points for the target dataset (default: None).
+ :type y2: list or np.ndarray, optional
+ :param title: Title of the plot (default: None).
+ :type title: str, optional
+ :param xaxis_title: Title for the x-axis (default: None).
+ :type xaxis_title: str, optional
+ :param yaxis_title: Title for the y-axis (default: None).
+ :type yaxis_title: str, optional
+ :param trace_name: Name for the primary trace (default: "Simulated").
+ :type trace_name: str, optional
+ :param width: Width of the figure in pixels (default: 1024).
+ :type width: int, optional
+ :param height: Height of the figure in pixels (default: 576).
+ :type height: int, optional
.. py:method:: __call__()
- Generate the plotly figure.
+ Generate the Plotly figure.
+
+ :returns: The generated Plotly figure.
+ :rtype: plotly.graph_objs.Figure
.. py:method:: create_layout()
- Create the layout for the plot.
+ Create the layout for the Plotly figure.
+
+ :returns: The layout for the Plotly figure.
+ :rtype: plotly.graph_objs.Layout
.. py:method:: create_traces()
- Create the traces for the plot.
+ Create traces for the Plotly figure.
+
+ :returns: A list of plotly.graph_objs.Scatter objects to be used as traces.
+ :rtype: list
.. py:method:: wrap_text(text, width)
:staticmethod:
- Wrap text to a specified width.
+ Wrap text to a specified width with HTML line breaks.
- Parameters:
- -----------
- text: str
- Text to be wrapped.
- width: int
- Width to wrap text to.
+ :param text: The text to wrap.
+ :type text: str
+ :param width: The width to wrap the text to.
+ :type width: int
- Returns:
- ----------
- str
- Wrapped text with HTML line breaks.
+ :returns: The wrapped text.
+ :rtype: str
@@ -1442,86 +1535,60 @@ Attributes
.. py:function:: plot_cost2d(cost, bounds=None, optim=None, steps=10)
- Query the cost landscape for a given parameter space and plot it using Plotly.
+ Plot a 2D visualization of a cost landscape using Plotly.
- This function creates a 2D plot that visualizes the cost landscape over a grid
- of points within specified parameter bounds. If no bounds are provided, it determines
- them from the bounds on the parameter class.
+ This function generates a contour plot representing the cost landscape for a provided
+ callable cost function over a grid of parameter values within the specified bounds.
- :param cost: A callable representing the cost function to be queried. It should
- take a list of parameters and return a cost value.
+ :param cost: The cost function to be evaluated. Must accept a list of parameters and return a cost value.
:type cost: callable
- :param bounds: The bounds for the parameter space as a 2x2 array, with each
- sub-array representing the min and max bounds for a parameter.
- If None, bounds will be determined by `get_param_bounds`.
+ :param bounds: A 2x2 array specifying the [min, max] bounds for each parameter. If None, uses `get_param_bounds`.
:type bounds: numpy.ndarray, optional
- :param optim: An optional optimizer instance. If provided, it will be used to
- overlay optimizer-specific information on the plot.
+ :param optim: An optimizer instance which, if provided, overlays its specific trace on the plot.
:type optim: object, optional
- :param steps: The number of steps to divide the parameter space grid. More steps
- result in finer resolution but increase computational cost.
+ :param steps: The number of intervals to divide the parameter space into along each dimension (default is 10).
:type steps: int, optional
- :return: A Plotly figure object representing the cost landscape plot.
+
+ :returns: The Plotly figure object containing the cost landscape plot.
:rtype: plotly.graph_objs.Figure
- :raises ValueError: If the cost function does not behave as expected.
+ :raises ValueError: If the cost function does not return a valid cost when called with a parameter list.
.. py:function:: plot_parameters(optim, xaxis_titles='Iteration', yaxis_titles=None, title='Convergence')
- Plot the evolution of the parameters during the optimisation process.
-
- Parameters:
- ------------
- optim : optimisation object
- An object representing the optimisation process, which should contain
- information about the cost function, optimiser, and the history of the
- parameter values throughout the iterations.
- xaxis_title : str, optional
- Title for the x-axis, representing the iteration number or a similar
- discrete time step in the optimisation process (default is "Iteration").
- yaxis_title : str, optional
- Title for the y-axis, which typically represents the metric being
- optimised, such as cost or loss (default is "Cost").
- title : str, optional
- Title of the plot, which provides an overall description of what the
- plot represents (default is "Convergence").
+ Plot the evolution of parameters during the optimization process using Plotly.
- Returns:
- ----------
- fig : plotly.graph_objs.Figure
- The Plotly figure object for the plot depicting how the parameters of
- the optimisation algorithm evolve over its course. This can be useful
- for diagnosing the behaviour of the optimisation algorithm.
+ :param optim: The optimization object containing the history of parameter values and associated cost.
+ :type optim: object
+ :param xaxis_titles: Title for the x-axis, defaulting to "Iteration".
+ :type xaxis_titles: str, optional
+ :param yaxis_titles: Titles for the y-axes, one for each parameter. If None, parameter names are used.
+ :type yaxis_titles: list of str, optional
+ :param title: Title of the plot, defaulting to "Convergence".
+ :type title: str, optional
- Notes:
- ----------
- The function assumes that the 'optim' object has a 'cost.problem.parameters'
- attribute containing the parameters of the optimisation algorithm and a 'log'
- attribute containing a history of the iterations.
+ :returns: A Plotly figure object showing the parameter evolution over iterations.
+ :rtype: plotly.graph_objs.Figure
.. py:function:: quick_plot(params, cost, title='Scatter Plot', width=1024, height=576)
- Plot the target dataset against the minimised model output.
+ Quickly plot the target dataset against minimized model output.
- Parameters:
- -----------
- params : array-like
- Optimised parameters.
- cost : cost object
- Cost object containing the problem, dataset, and signal.
- title : str, optional
- Title of the plot (default is "Scatter Plot").
- width : int, optional
- Width of the figure in pixels (default is 720).
- height : int, optional
- Height of the figure in pixels (default is 540).
+ :param params: Optimized parameters.
+ :type params: array-like
+ :param cost: Cost object with problem, dataset, and signal attributes.
+ :type cost: object
+ :param title: Title of the plot (default: "Scatter Plot").
+ :type title: str, optional
+ :param width: Width of the figure in pixels (default: 1024).
+ :type width: int, optional
+ :param height: Height of the figure in pixels (default: 576).
+ :type height: int, optional
- Returns:
- ----------
- fig : plotly.graph_objs.Figure
- The Plotly figure object for the scatter plot.
+ :returns: The Plotly figure object for the scatter plot.
+ :rtype: plotly.graph_objs.Figure
.. py:data:: FLOAT_FORMAT
diff --git a/_sources/api/pybop/optimisation/index.rst.txt b/_sources/api/pybop/optimisation/index.rst.txt
index bd42ca31..25cd20a7 100644
--- a/_sources/api/pybop/optimisation/index.rst.txt
+++ b/_sources/api/pybop/optimisation/index.rst.txt
@@ -20,109 +20,140 @@ Classes
.. py:class:: Optimisation(cost, optimiser=None, sigma0=None, verbose=False)
- Optimisation class for PyBOP.
- This class provides functionality for PyBOP optimisers and Pints optimisers.
- :param cost: PyBOP cost function
- :param optimiser: A PyBOP or Pints optimiser
- :param sigma0: initial step size
- :param verbose: print optimisation progress
+ A class for conducting optimization using PyBOP or PINTS optimizers.
- .. py:method:: _run_pints()
+ :param cost: An objective function to be optimized, which can be either a PINTS error measure or log PDF.
+ :type cost: pints.ErrorMeasure or pints.LogPDF
+ :param optimiser: An optimizer from either the PINTS or PyBOP framework to perform the optimization (default: None).
+ :type optimiser: pints.Optimiser or subclass of pybop.BaseOptimizer, optional
+ :param sigma0: Initial step size or standard deviation for the optimizer (default: None).
+ :type sigma0: float or sequence, optional
+ :param verbose: If True, the optimization progress is printed (default: False).
+ :type verbose: bool, optional
- Run method for PINTS optimisers.
- This method is heavily based on the run method in the PINTS.OptimisationController class.
- :returns: best parameters
- final_cost: final cost
- :rtype: x
+ .. attribute:: x0
+ Initial parameter values for the optimization.
- .. py:method:: _run_pybop()
+ :type: numpy.ndarray
- Run method for PyBOP based optimisers.
- :returns: best parameters
- final_cost: final cost
- :rtype: x
+ .. attribute:: bounds
+ Dictionary containing the parameter bounds with keys 'lower' and 'upper'.
- .. py:method:: f_guessed_tracking()
+ :type: dict
- Returns ``True`` if f_guessed instead of f_best is being tracked,
- ``False`` otherwise. See also :meth:`set_f_guessed_tracking`.
+ .. attribute:: n_parameters
- Credit: PINTS
+ Number of parameters in the optimization problem.
+ :type: int
- .. py:method:: run()
+ .. attribute:: sigma0
- Run the optimisation algorithm.
- Selects between PyBOP backend or Pints backend.
- :returns: best parameters
- final_cost: final cost
- :rtype: x
+ Initial step size or standard deviation for the optimizer.
+ :type: float or sequence
- .. py:method:: set_f_guessed_tracking(use_f_guessed=False)
+ .. attribute:: log
- Sets the method used to track the optimiser progress to
- :meth:`pints.Optimiser.f_guessed()` or
- :meth:`pints.Optimiser.f_best()` (default).
+ Log of the optimization process.
- The tracked ``f`` value is used to evaluate stopping criteria.
+ :type: list
- Credit: PINTS
+ .. py:method:: _run_pints()
+ Internal method to run the optimization using a PINTS optimizer.
- .. py:method:: set_max_evaluations(evaluations=None)
+ :returns: * **x** (*numpy.ndarray*) -- The best parameter set found by the optimization.
+ * **final_cost** (*float*) -- The final cost associated with the best parameters.
+
+ .. seealso:: :obj:`This`
- Adds a stopping criterion, allowing the routine to halt after the
- given number of ``evaluations``.
- This criterion is disabled by default. To enable, pass in any positive
- integer. To disable again, use ``set_max_evaluations(None)``.
+ .. py:method:: _run_pybop()
+
+ Internal method to run the optimization using a PyBOP optimizer.
+
+ :returns: * **x** (*numpy.ndarray*) -- The best parameter set found by the optimization.
+ * **final_cost** (*float*) -- The final cost associated with the best parameters.
+
+
+ .. py:method:: f_guessed_tracking()
+ Check if f_guessed instead of f_best is being tracked.
Credit: PINTS
+ :returns: True if f_guessed is being tracked, False otherwise.
+ :rtype: bool
- .. py:method:: set_max_iterations(iterations=1000)
- Adds a stopping criterion, allowing the routine to halt after the
- given number of ``iterations``.
+ .. py:method:: run()
+
+ 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.
- This criterion is enabled by default. To disable it, use
- ``set_max_iterations(None)``.
+ .. py:method:: set_f_guessed_tracking(use_f_guessed=False)
+
+ Set the method used to track the optimizer progress.
Credit: PINTS
+ :param use_f_guessed: If True, track f_guessed; otherwise, track f_best (default: False).
+ :type use_f_guessed: bool, optional
- .. py:method:: set_max_unchanged_iterations(iterations=25, threshold=1e-05)
- Adds a stopping criterion, allowing the routine to halt if the
- objective function doesn't change by more than ``threshold`` for the
- given number of ``iterations``.
+ .. py:method:: set_max_evaluations(evaluations=None)
+
+ Set a maximum number of evaluations stopping criterion.
+ Credit: PINTS
+
+ :param evaluations: The maximum number of evaluations after which to stop the optimization (default: None).
+ :type evaluations: int, optional
- This criterion is enabled by default. To disable it, use
- ``set_max_unchanged_iterations(None)``.
+ .. py:method:: set_max_iterations(iterations=1000)
+
+ Set the maximum number of iterations as a stopping criterion.
Credit: PINTS
+ :param iterations: The maximum number of iterations to run (default is 1000).
+ Set to `None` to remove this stopping criterion.
+ :type iterations: int, optional
- .. py:method:: set_parallel(parallel=False)
- Enables/disables parallel evaluation.
+ .. py:method:: set_max_unchanged_iterations(iterations=25, threshold=1e-05)
+
+ Set the maximum number of iterations without significant change as a stopping criterion.
+ Credit: PINTS
- If ``parallel=True``, the method will run using a number of worker
- processes equal to the detected cpu core count. The number of workers
- can be set explicitly by setting ``parallel`` to an integer greater
- than 0.
- Parallelisation can be disabled by setting ``parallel`` to ``0`` or
- ``False``.
+ :param iterations: The maximum number of unchanged iterations to run (default is 25).
+ Set to `None` to remove this stopping criterion.
+ :type iterations: int, optional
+ :param threshold: The minimum significant change in the objective function value that resets the unchanged iteration counter (default is 1e-5).
+ :type threshold: float, optional
+
+ .. py:method:: set_parallel(parallel=False)
+
+ Enable or disable parallel evaluation.
Credit: PINTS
+ :param parallel: 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).
+ :type parallel: bool or int, optional
+
.. py:method:: store_optimised_parameters(x)
- Store the optimised parameters in the PyBOP parameter class.
+ Update the problem parameters with optimized values.
+
+ The optimized parameter values are stored within the associated PyBOP parameter class.
+
+ :param x: Optimized parameter values.
+ :type x: array-like
diff --git a/_sources/api/pybop/plotting/plot_cost2d/index.rst.txt b/_sources/api/pybop/plotting/plot_cost2d/index.rst.txt
index df4528a6..aec28587 100644
--- a/_sources/api/pybop/plotting/plot_cost2d/index.rst.txt
+++ b/_sources/api/pybop/plotting/plot_cost2d/index.rst.txt
@@ -21,36 +21,55 @@ Functions
.. py:function:: create_figure(x, y, z, bounds, params, optim)
+ Create a Plotly figure with a 2D contour plot of the cost landscape.
+
+ :param x: 1D array of x-coordinates for the meshgrid.
+ :type x: numpy.ndarray
+ :param y: 1D array of y-coordinates for the meshgrid.
+ :type y: numpy.ndarray
+ :param z: 2D array of cost function values corresponding to the meshgrid.
+ :type z: numpy.ndarray
+ :param bounds: A 2x2 array specifying the [min, max] bounds for each parameter.
+ :type bounds: numpy.ndarray
+ :param params: An iterable of parameter objects with 'name' attributes for axis labeling.
+ :type params: iterable
+ :param optim: An optimizer instance with 'log' and 'x0' attributes for plotting traces.
+ :type optim: object
+
+ :returns: The Plotly figure object with the contour plot and optimization traces.
+ :rtype: plotly.graph_objs.Figure
+
.. py:function:: get_param_bounds(cost)
- Use parameters bounds for range of cost landscape
+ Retrieve parameter bounds from a cost function's associated problem parameters.
+
+ :param cost: The cost function with an associated 'problem' attribute containing 'parameters'.
+ :type cost: callable
+
+ :returns: An array of shape (n_parameters, 2) containing the bounds for each parameter.
+ :rtype: numpy.ndarray
.. py:function:: plot_cost2d(cost, bounds=None, optim=None, steps=10)
- Query the cost landscape for a given parameter space and plot it using Plotly.
+ Plot a 2D visualization of a cost landscape using Plotly.
- This function creates a 2D plot that visualizes the cost landscape over a grid
- of points within specified parameter bounds. If no bounds are provided, it determines
- them from the bounds on the parameter class.
+ This function generates a contour plot representing the cost landscape for a provided
+ callable cost function over a grid of parameter values within the specified bounds.
- :param cost: A callable representing the cost function to be queried. It should
- take a list of parameters and return a cost value.
+ :param cost: The cost function to be evaluated. Must accept a list of parameters and return a cost value.
:type cost: callable
- :param bounds: The bounds for the parameter space as a 2x2 array, with each
- sub-array representing the min and max bounds for a parameter.
- If None, bounds will be determined by `get_param_bounds`.
+ :param bounds: A 2x2 array specifying the [min, max] bounds for each parameter. If None, uses `get_param_bounds`.
:type bounds: numpy.ndarray, optional
- :param optim: An optional optimizer instance. If provided, it will be used to
- overlay optimizer-specific information on the plot.
+ :param optim: An optimizer instance which, if provided, overlays its specific trace on the plot.
:type optim: object, optional
- :param steps: The number of steps to divide the parameter space grid. More steps
- result in finer resolution but increase computational cost.
+ :param steps: The number of intervals to divide the parameter space into along each dimension (default is 10).
:type steps: int, optional
- :return: A Plotly figure object representing the cost landscape plot.
+
+ :returns: The Plotly figure object containing the cost landscape plot.
:rtype: plotly.graph_objs.Figure
- :raises ValueError: If the cost function does not behave as expected.
+ :raises ValueError: If the cost function does not return a valid cost when called with a parameter list.
diff --git a/_sources/api/pybop/plotting/plot_parameters/index.rst.txt b/_sources/api/pybop/plotting/plot_parameters/index.rst.txt
index b5079d29..2e377a04 100644
--- a/_sources/api/pybop/plotting/plot_parameters/index.rst.txt
+++ b/_sources/api/pybop/plotting/plot_parameters/index.rst.txt
@@ -21,71 +21,52 @@ Functions
.. py:function:: create_subplots_with_traces(traces, plot_size=(1024, 576), title='Parameter Convergence', axis_titles=None, **layout_kwargs)
- Creates a subplot figure with the given traces.
+ Create a subplot with individual traces for each parameter.
- :param traces: List of plotly.graph_objs traces that will be added to the subplots.
- :param plot_size: Tuple (width, height) representing the desired size of the plot.
- :param title: The main title of the subplot figure.
- :param axis_titles: List of tuples for axis titles in the form [(x_title, y_title), ...] for each subplot.
- :param layout_kwargs: Additional keyword arguments to be passed to fig.update_layout for custom layout.
- :return: A plotly figure object with the subplots.
+ :param traces: Traces to be plotted, one trace per subplot.
+ :type traces: list of plotly.graph_objs.Scatter
+ :param plot_size: The size of the plot as (width, height), defaulting to (1024, 576).
+ :type plot_size: tuple of int, optional
+ :param title: The title of the plot, defaulting to "Parameter Convergence".
+ :type title: str, optional
+ :param axis_titles: A list of (x_title, y_title) pairs for each subplot. If None, titles are omitted.
+ :type axis_titles: list of tuple of str, optional
+ :param \*\*layout_kwargs: Additional keyword arguments to customize the layout.
+ :type \*\*layout_kwargs: dict
+
+ :returns: A Plotly figure object with subplots for each trace.
+ :rtype: plotly.graph_objs.Figure
.. py:function:: create_traces(params, trace_data, x_values=None)
- Generate a list of Plotly Scatter trace objects from provided trace data.
+ Create traces for plotting parameter evolution.
- This function assumes that each column in the ``trace_data`` represents a separate trace to be plotted,
- and that the ``params`` list contains objects with a ``name`` attribute used for trace names.
- Text wrapping for trace names is performed by ``pybop.StandardPlot.wrap_text``.
+ :param params: List of parameter objects, each having a 'name' attribute used for labeling the trace.
+ :type params: list
+ :param trace_data: A list of arrays representing the historical values of each parameter.
+ :type trace_data: list of numpy.ndarray
+ :param x_values: The x-axis values for plotting. If None, defaults to sequential integers.
+ :type x_values: list or numpy.ndarray, optional
- Parameters:
- - params (list): A list of objects, where each object has a ``name`` attribute used as the trace name.
- The list should have the same length as the number of traces in ``trace_data``.
- - trace_data (list of lists): A 2D list where each inner list represents y-values for a trace.
- - x_values (list, optional): A list of x-values to be used for all traces. If not provided, a
- range of integers starting from 0 will be used.
+ :returns: A list of Scatter trace objects, one for each parameter.
+ :rtype: list of plotly.graph_objs.Scatter
- Returns:
- - list: A list of Plotly ``go.Scatter`` objects, each representing a trace to be plotted.
- Notes:
- - The function depends on ``pybop.StandardPlot.wrap_text`` for text wrapping, which needs to be available
- in the execution context.
- - The function assumes that ``go`` from ``plotly.graph_objs`` is already imported as ``go``.
+.. py:function:: plot_parameters(optim, xaxis_titles='Iteration', yaxis_titles=None, title='Convergence')
+ Plot the evolution of parameters during the optimization process using Plotly.
-.. py:function:: plot_parameters(optim, xaxis_titles='Iteration', yaxis_titles=None, title='Convergence')
+ :param optim: The optimization object containing the history of parameter values and associated cost.
+ :type optim: object
+ :param xaxis_titles: Title for the x-axis, defaulting to "Iteration".
+ :type xaxis_titles: str, optional
+ :param yaxis_titles: Titles for the y-axes, one for each parameter. If None, parameter names are used.
+ :type yaxis_titles: list of str, optional
+ :param title: Title of the plot, defaulting to "Convergence".
+ :type title: str, optional
- Plot the evolution of the parameters during the optimisation process.
-
- Parameters:
- ------------
- optim : optimisation object
- An object representing the optimisation process, which should contain
- information about the cost function, optimiser, and the history of the
- parameter values throughout the iterations.
- xaxis_title : str, optional
- Title for the x-axis, representing the iteration number or a similar
- discrete time step in the optimisation process (default is "Iteration").
- yaxis_title : str, optional
- Title for the y-axis, which typically represents the metric being
- optimised, such as cost or loss (default is "Cost").
- title : str, optional
- Title of the plot, which provides an overall description of what the
- plot represents (default is "Convergence").
-
- Returns:
- ----------
- fig : plotly.graph_objs.Figure
- The Plotly figure object for the plot depicting how the parameters of
- the optimisation algorithm evolve over its course. This can be useful
- for diagnosing the behaviour of the optimisation algorithm.
-
- Notes:
- ----------
- The function assumes that the 'optim' object has a 'cost.problem.parameters'
- attribute containing the parameters of the optimisation algorithm and a 'log'
- attribute containing a history of the iterations.
+ :returns: A Plotly figure object showing the parameter evolution over iterations.
+ :rtype: plotly.graph_objs.Figure
diff --git a/_sources/api/pybop/plotting/plotly_manager/index.rst.txt b/_sources/api/pybop/plotting/plotly_manager/index.rst.txt
index f5cf0dc2..83918034 100644
--- a/_sources/api/pybop/plotting/plotly_manager/index.rst.txt
+++ b/_sources/api/pybop/plotting/plotly_manager/index.rst.txt
@@ -20,54 +20,89 @@ Classes
.. py:class:: PlotlyManager
- Manages the installation and configuration of Plotly for generating visualisations.
-
- This class checks if Plotly is installed and, if not, prompts the user to install it.
- It also ensures that the Plotly renderer and browser settings are properly configured
- to display plots.
-
- Methods:
- ``ensure_plotly_installed``: Verifies if Plotly is installed and installs it if necessary.
- ``prompt_for_plotly_installation``: Prompts the user for permission to install Plotly.
- ``install_plotly_package``: Installs the Plotly package using pip.
- ``post_install_setup``: Sets up Plotly default renderer after installation.
- ``check_renderer_settings``: Verifies that the Plotly renderer is correctly set.
- ``check_browser_availability``: Checks if a web browser is available for rendering plots.
-
- Usage:
- Instantiate the PlotlyManager class to automatically ensure Plotly is installed
- and configured correctly when creating an instance.
- Example:
- plotly_manager = PlotlyManager()
+ Manages the installation and configuration of Plotly for generating visualizations.
+
+ This class ensures that Plotly is installed and properly configured to display
+ plots in a web browser.
+
+ Upon instantiation, it checks for Plotly's presence, installs it if missing,
+ and configures the default renderer and browser settings.
+
+ .. attribute:: go
+
+ The Plotly graph_objects module for creating figures.
+
+ :type: module
+
+ .. attribute:: pio
+
+ The Plotly input/output module for configuring the renderer.
+
+ :type: module
+
+ .. attribute:: make_subplots
+
+ The function from Plotly for creating subplot figures.
+
+ :type: function
+
+ .. method:: ensure_plotly_installed()
+
+ Verifies if Plotly is installed, importing necessary modules and prompting for installation if missing.
+
+ .. method:: prompt_for_plotly_installation()
+
+ Prompts the user for permission to install Plotly and proceeds with installation if consented.
+
+ .. method:: install_plotly()
+
+ Installs the Plotly package using pip.
+
+ .. method:: post_install_setup()
+
+ Sets up Plotly default renderer after installation.
+
+ .. method:: check_renderer_settings()
+
+ Verifies that the Plotly renderer is correctly set.
+
+ .. method:: check_browser_availability()
+
+ Checks if a web browser is available for rendering plots.
+
+
+ .. rubric:: Examples
+
+ >>> plotly_manager = PlotlyManager()
.. py:method:: check_browser_availability()
- Ensures a web browser is available for rendering plots with the 'browser' renderer and provides guidance if not.
+ Confirm a web browser is available for Plotly's 'browser' renderer; provide guidance if not.
.. py:method:: check_renderer_settings()
- Checks if the Plotly renderer is set and provides information on how to set it if empty.
+ Check and provide information on setting the Plotly renderer if it's not already set.
.. py:method:: ensure_plotly_installed()
- Verifies if Plotly is installed, importing necessary modules and prompting for installation if missing.
+ Check if Plotly is installed and import necessary modules; prompt for installation if missing.
.. py:method:: install_plotly()
- Attempts to install the Plotly package using pip and exits if installation fails.
+ Install the Plotly package using pip. Exit if installation fails.
.. py:method:: post_install_setup()
- After successful installation, imports Plotly and sets the default renderer if necessary.
+ Import Plotly modules and set the default renderer after installation.
.. py:method:: prompt_for_plotly_installation()
- Prompts the user for permission to install Plotly and proceeds with installation if consented.
+ Prompt the user for Plotly installation and install it upon agreement.
diff --git a/_sources/api/pybop/plotting/quick_plot/index.rst.txt b/_sources/api/pybop/plotting/quick_plot/index.rst.txt
index 2d78cee7..b3403862 100644
--- a/_sources/api/pybop/plotting/quick_plot/index.rst.txt
+++ b/_sources/api/pybop/plotting/quick_plot/index.rst.txt
@@ -28,98 +28,86 @@ Functions
.. py:class:: StandardPlot(x, y, cost, y2=None, title=None, xaxis_title=None, yaxis_title=None, trace_name=None, width=1024, height=576)
- A class for creating and displaying a plotly figure that compares a target dataset against a simulated model output.
-
- This class provides an interface for generating interactive plots using Plotly, with the ability to include an
- optional secondary dataset and visualize uncertainty if provided.
-
- Attributes:
- -----------
- x : list
- The x-axis data points.
- y : list or np.ndarray
- The primary y-axis data points representing the simulated model output.
- y2 : list or np.ndarray, optional
- An optional secondary y-axis data points representing the target dataset against which the model output is compared.
- cost : float
- The cost associated with the model output.
- title : str, optional
- The title of the plot.
- xaxis_title : str, optional
- The title for the x-axis.
- yaxis_title : str, optional
- The title for the y-axis.
- trace_name : str, optional
- The name of the primary trace representing the model output. Defaults to "Simulated".
- width : int, optional
- The width of the figure in pixels. Defaults to 720.
- height : int, optional
- The height of the figure in pixels. Defaults to 540.
-
- Example:
- ----------
- >>> x_data = [1, 2, 3, 4]
- >>> y_simulated = [10, 15, 13, 17]
- >>> y_target = [11, 14, 12, 16]
- >>> plot = pybop.StandardPlot(x_data, y_simulated, cost=0.05, y2=y_target,
- title="Model vs. Target", xaxis_title="X Axis", yaxis_title="Y Axis")
- >>> fig = plot() # Generate the figure
- >>> fig.show() # Display the figure in a browser
+ A class for creating and displaying Plotly figures for model output comparison.
+
+ Generates interactive plots comparing simulated model output with an optional target dataset and visualizes uncertainty.
+
+ :param x: X-axis data points.
+ :type x: list or np.ndarray
+ :param y: Primary Y-axis data points for simulated model output.
+ :type y: list or np.ndarray
+ :param cost: Cost associated with the model output.
+ :type cost: float
+ :param y2: Secondary Y-axis data points for the target dataset (default: None).
+ :type y2: list or np.ndarray, optional
+ :param title: Title of the plot (default: None).
+ :type title: str, optional
+ :param xaxis_title: Title for the x-axis (default: None).
+ :type xaxis_title: str, optional
+ :param yaxis_title: Title for the y-axis (default: None).
+ :type yaxis_title: str, optional
+ :param trace_name: Name for the primary trace (default: "Simulated").
+ :type trace_name: str, optional
+ :param width: Width of the figure in pixels (default: 1024).
+ :type width: int, optional
+ :param height: Height of the figure in pixels (default: 576).
+ :type height: int, optional
.. py:method:: __call__()
- Generate the plotly figure.
+ Generate the Plotly figure.
+
+ :returns: The generated Plotly figure.
+ :rtype: plotly.graph_objs.Figure
.. py:method:: create_layout()
- Create the layout for the plot.
+ Create the layout for the Plotly figure.
+
+ :returns: The layout for the Plotly figure.
+ :rtype: plotly.graph_objs.Layout
.. py:method:: create_traces()
- Create the traces for the plot.
+ Create traces for the Plotly figure.
+
+ :returns: A list of plotly.graph_objs.Scatter objects to be used as traces.
+ :rtype: list
.. py:method:: wrap_text(text, width)
:staticmethod:
- Wrap text to a specified width.
+ Wrap text to a specified width with HTML line breaks.
- Parameters:
- -----------
- text: str
- Text to be wrapped.
- width: int
- Width to wrap text to.
+ :param text: The text to wrap.
+ :type text: str
+ :param width: The width to wrap the text to.
+ :type width: int
- Returns:
- ----------
- str
- Wrapped text with HTML line breaks.
+ :returns: The wrapped text.
+ :rtype: str
.. py:function:: quick_plot(params, cost, title='Scatter Plot', width=1024, height=576)
- Plot the target dataset against the minimised model output.
-
- Parameters:
- -----------
- params : array-like
- Optimised parameters.
- cost : cost object
- Cost object containing the problem, dataset, and signal.
- title : str, optional
- Title of the plot (default is "Scatter Plot").
- width : int, optional
- Width of the figure in pixels (default is 720).
- height : int, optional
- Height of the figure in pixels (default is 540).
-
- Returns:
- ----------
- fig : plotly.graph_objs.Figure
- The Plotly figure object for the scatter plot.
+ Quickly plot the target dataset against minimized model output.
+
+ :param params: Optimized parameters.
+ :type params: array-like
+ :param cost: Cost object with problem, dataset, and signal attributes.
+ :type cost: object
+ :param title: Title of the plot (default: "Scatter Plot").
+ :type title: str, optional
+ :param width: Width of the figure in pixels (default: 1024).
+ :type width: int, optional
+ :param height: Height of the figure in pixels (default: 576).
+ :type height: int, optional
+
+ :returns: The Plotly figure object for the scatter plot.
+ :rtype: plotly.graph_objs.Figure
diff --git a/_sources/index.md.txt b/_sources/index.md.txt
index 94d276fe..622dd79d 100644
--- a/_sources/index.md.txt
+++ b/_sources/index.md.txt
@@ -6,7 +6,7 @@ myst:
html_theme.sidebar_secondary.remove: true
---
-
Parameterise and Optimise Battery Models with PyBOP
+# PyBOP: Optimise and Parameterise Battery Models
Welcome to PyBOP, a Python package dedicated to the optimization and parameterization of battery models. PyBOP is designed to streamline your workflow, whether you are conducting academic research, working in industry, or simply interested in battery technology and modelling.
diff --git a/_sources/user_guide/installation.rst.txt b/_sources/user_guide/installation.rst.txt
index 1482edc4..1204d725 100644
--- a/_sources/user_guide/installation.rst.txt
+++ b/_sources/user_guide/installation.rst.txt
@@ -50,7 +50,7 @@ For Developers
If you are installing PyBOP for development purposes, such as contributing to the project, please ensure that you follow the guidelines outlined in the contributing guide. It includes additional steps that might be necessary for setting up a development environment, including the installation of dependencies and setup of pre-commit hooks.
-`Contributing Guide `_
+`Contributing Guide <../contributing.html>`_
Further Assistance
------------------
@@ -62,6 +62,5 @@ Next Steps
After installing PyBOP, you might want to:
-* Explore the `Quick Start Guide `_ to begin using PyBOP.
-* Read through the `User Manual `_ for in-depth documentation on PyBOP's features.
+* Explore the `Quick Start Guide `_ to begin using PyBOP.
* Check out the `API Reference <../api/index.html>`_ for detailed information on PyBOP's programming interface.
diff --git a/_static/custom-icon.js b/_static/custom-icon.js
new file mode 100644
index 00000000..ac9c6c91
--- /dev/null
+++ b/_static/custom-icon.js
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Set a custom icon for pypi as it's not available in the fa built-in brands
+ * Taken from: https://github.com/pydata/pydata-sphinx-theme/blob/main/docs/_static/custom-icon.js
+ */
+FontAwesome.library.add(
+ (faListOldStyle = {
+ prefix: "fa-custom",
+ iconName: "pypi",
+ icon: [
+ 17.313, // viewBox width
+ 19.807, // viewBox height
+ [], // ligature
+ "e001", // unicode codepoint - private use area
+ "m10.383 0.2-3.239 1.1769 3.1883 1.1614 3.239-1.1798zm-3.4152 1.2411-3.2362 1.1769 3.1855 1.1614 3.2369-1.1769zm6.7177 0.00281-3.2947 1.2009v3.8254l3.2947-1.1988zm-3.4145 1.2439-3.2926 1.1981v3.8254l0.17548-0.064132 3.1171-1.1347zm-6.6564 0.018325v3.8247l3.244 1.1805v-3.8254zm10.191 0.20931v2.3137l3.1777-1.1558zm3.2947 1.2425-3.2947 1.1988v3.8254l3.2947-1.1988zm-8.7058 0.45739c0.00929-1.931e-4 0.018327-2.977e-4 0.027485 0 0.25633 0.00851 0.4263 0.20713 0.42638 0.49826 1.953e-4 0.38532-0.29327 0.80469-0.65542 0.93662-0.36226 0.13215-0.65608-0.073306-0.65613-0.4588-6.28e-5 -0.38556 0.2938-0.80504 0.65613-0.93662 0.068422-0.024919 0.13655-0.038114 0.20156-0.039466zm5.2913 0.78369-3.2947 1.1988v3.8247l3.2947-1.1981zm-10.132 1.239-3.2362 1.1769 3.1883 1.1614 3.2362-1.1769zm6.7177 0.00213-3.2926 1.2016v3.8247l3.2926-1.2009zm-3.4124 1.2439-3.2947 1.1988v3.8254l3.2947-1.1988zm-6.6585 0.016195v3.8275l3.244 1.1805v-3.8254zm16.9 0.21143-3.2947 1.1988v3.8247l3.2947-1.1981zm-3.4145 1.2411-3.2926 1.2016v3.8247l3.2926-1.2009zm-3.4145 1.2411-3.2926 1.2016v3.8247l3.2926-1.2009zm-3.4124 1.2432-3.2947 1.1988v3.8254l3.2947-1.1988zm-6.6585 0.019027v3.8247l3.244 1.1805v-3.8254zm13.485 1.4497-3.2947 1.1988v3.8247l3.2947-1.1981zm-3.4145 1.2411-3.2926 1.2016v3.8247l3.2926-1.2009zm2.4018 0.38127c0.0093-1.83e-4 0.01833-3.16e-4 0.02749 0 0.25633 0.0085 0.4263 0.20713 0.42638 0.49826 1.97e-4 0.38532-0.29327 0.80469-0.65542 0.93662-0.36188 0.1316-0.65525-0.07375-0.65542-0.4588-1.95e-4 -0.38532 0.29328-0.80469 0.65542-0.93662 0.06842-0.02494 0.13655-0.03819 0.20156-0.03947zm-5.8142 0.86403-3.244 1.1805v1.4201l3.244 1.1805z", // svg path (https://simpleicons.org/icons/pypi.svg)
+ ],
+ })
+);
diff --git a/api/index.html b/api/index.html
index cfb3ff3a..812c86ff 100644
--- a/api/index.html
+++ b/api/index.html
@@ -45,6 +45,7 @@
+
@@ -208,6 +209,18 @@
+
+ PyPI
+
+
Optimisation class for PyBOP.
-This class provides functionality for PyBOP optimisers and Pints optimisers.
-:param cost: PyBOP cost function
-:param optimiser: A PyBOP or Pints optimiser
-:param sigma0: initial step size
-:param verbose: print optimisation progress
+
A class for conducting optimization using PyBOP or PINTS optimizers.
+
+
Parameters:
+
+
cost (pints.ErrorMeasure or pints.LogPDF) – An objective function to be optimized, which can be either a PINTS error measure or log PDF.
+
optimiser (pints.Optimiser or subclass of pybop.BaseOptimizer, optional) – An optimizer 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 optimizer (default: None).
+
verbose (bool, optional) – If True, the optimization progress is printed (default: False).
Adds a stopping criterion, allowing the routine to halt if the
-objective function doesn’t change by more than threshold for the
-given number of iterations.
-
This criterion is enabled by default. To disable it, use
-set_max_unchanged_iterations(None).
-
Credit: PINTS
+
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 25).
+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).
If parallel=True, the method will run using a number of worker
-processes equal to the detected cpu core count. The number of workers
-can be set explicitly by setting parallel to an integer greater
-than 0.
-Parallelisation can be disabled by setting parallel to 0 or
-False.
-
Credit: PINTS
+
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).
Manages the installation and configuration of Plotly for generating visualisations.
-
This class checks if Plotly is installed and, if not, prompts the user to install it.
-It also ensures that the Plotly renderer and browser settings are properly configured
-to display plots.
-
Methods:
-ensure_plotly_installed: Verifies if Plotly is installed and installs it if necessary.
-prompt_for_plotly_installation: Prompts the user for permission to install Plotly.
-install_plotly_package: Installs the Plotly package using pip.
-post_install_setup: Sets up Plotly default renderer after installation.
-check_renderer_settings: Verifies that the Plotly renderer is correctly set.
-check_browser_availability: Checks if a web browser is available for rendering plots.
-
Usage:
-Instantiate the PlotlyManager class to automatically ensure Plotly is installed
-and configured correctly when creating an instance.
-Example:
-plotly_manager = PlotlyManager()
A class for creating and displaying a plotly figure that compares a target dataset against a simulated model output.
-
This class provides an interface for generating interactive plots using Plotly, with the ability to include an
-optional secondary dataset and visualize uncertainty if provided.
Query the cost landscape for a given parameter space and plot it using Plotly.
-
This function creates a 2D plot that visualizes the cost landscape over a grid
-of points within specified parameter bounds. If no bounds are provided, it determines
-them from the bounds on the parameter class.
+
Plot a 2D visualization of a cost landscape using Plotly.
+
This function generates a contour plot representing the cost landscape for a provided
+callable cost function over a grid of parameter values within the specified bounds.
Parameters:
-
cost (callable) – A callable representing the cost function to be queried. It should
-take a list of parameters and return a cost value.
-
bounds (numpy.ndarray, optional) – The bounds for the parameter space as a 2x2 array, with each
-sub-array representing the min and max bounds for a parameter.
-If None, bounds will be determined by get_param_bounds.
-
optim (object, optional) – An optional optimizer instance. If provided, it will be used to
-overlay optimizer-specific information on the plot.
-
steps (int, optional) – The number of steps to divide the parameter space grid. More steps
-result in finer resolution but increase computational cost.
+
cost (callable) – The cost function to be evaluated. Must accept a list of parameters and return a cost value.
+
bounds (numpy.ndarray, optional) – A 2x2 array specifying the [min, max] bounds for each parameter. If None, uses get_param_bounds.
+
optim (object, optional) – An optimizer instance which, if provided, overlays its specific trace on the plot.
+
steps (int, optional) – The number of intervals to divide the parameter space into along each dimension (default is 10).
Returns:
-
A Plotly figure object representing the cost landscape plot.
+
The Plotly figure object containing the cost landscape plot.
Return type:
plotly.graph_objs.Figure
Raises:
-
ValueError – If the cost function does not behave as expected.
+
ValueError – If the cost function does not return a valid cost when called with a parameter list.
An object representing the optimisation process, which should contain
-information about the cost function, optimiser, and the history of the
-parameter values throughout the iterations.
-
-
xaxis_titlestr, optional
Title for the x-axis, representing the iteration number or a similar
-discrete time step in the optimisation process (default is “Iteration”).
-
-
yaxis_titlestr, optional
Title for the y-axis, which typically represents the metric being
-optimised, such as cost or loss (default is “Cost”).
+
Plot the evolution of parameters during the optimization process using Plotly.
+
+
Parameters:
+
+
optim (object) – The optimization object containing the history of parameter values and associated cost.
+
xaxis_titles (str, optional) – Title for the x-axis, defaulting to “Iteration”.
+
yaxis_titles (list of str, optional) – Titles for the y-axes, one for each parameter. If None, parameter names are used.
+
title (str, optional) – Title of the plot, defaulting to “Convergence”.
+
-
titlestr, optional
Title of the plot, which provides an overall description of what the
-plot represents (default is “Convergence”).
+
Returns:
+
A Plotly figure object showing the parameter evolution over iterations.
The Plotly figure object for the plot depicting how the parameters of
-the optimisation algorithm evolve over its course. This can be useful
-for diagnosing the behaviour of the optimisation algorithm.
The function assumes that the ‘optim’ object has a ‘cost.problem.parameters’
-attribute containing the parameters of the optimisation algorithm and a ‘log’
-attribute containing a history of the iterations.
Optimisation class for PyBOP.
-This class provides functionality for PyBOP optimisers and Pints optimisers.
-:param cost: PyBOP cost function
-:param optimiser: A PyBOP or Pints optimiser
-:param sigma0: initial step size
-:param verbose: print optimisation progress
+
A class for conducting optimization using PyBOP or PINTS optimizers.
+
+
Parameters:
+
+
cost (pints.ErrorMeasure or pints.LogPDF) – An objective function to be optimized, which can be either a PINTS error measure or log PDF.
+
optimiser (pints.Optimiser or subclass of pybop.BaseOptimizer, optional) – An optimizer 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 optimizer (default: None).
+
verbose (bool, optional) – If True, the optimization progress is printed (default: False).
Adds a stopping criterion, allowing the routine to halt if the
-objective function doesn’t change by more than threshold for the
-given number of iterations.
-
This criterion is enabled by default. To disable it, use
-set_max_unchanged_iterations(None).
-
Credit: PINTS
+
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 25).
+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).
If parallel=True, the method will run using a number of worker
-processes equal to the detected cpu core count. The number of workers
-can be set explicitly by setting parallel to an integer greater
-than 0.
-Parallelisation can be disabled by setting parallel to 0 or
-False.
-
Credit: PINTS
+
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).
Query the cost landscape for a given parameter space and plot it using Plotly.
-
This function creates a 2D plot that visualizes the cost landscape over a grid
-of points within specified parameter bounds. If no bounds are provided, it determines
-them from the bounds on the parameter class.
+
Plot a 2D visualization of a cost landscape using Plotly.
+
This function generates a contour plot representing the cost landscape for a provided
+callable cost function over a grid of parameter values within the specified bounds.
Parameters:
-
cost (callable) – A callable representing the cost function to be queried. It should
-take a list of parameters and return a cost value.
-
bounds (numpy.ndarray, optional) – The bounds for the parameter space as a 2x2 array, with each
-sub-array representing the min and max bounds for a parameter.
-If None, bounds will be determined by get_param_bounds.
-
optim (object, optional) – An optional optimizer instance. If provided, it will be used to
-overlay optimizer-specific information on the plot.
-
steps (int, optional) – The number of steps to divide the parameter space grid. More steps
-result in finer resolution but increase computational cost.
+
cost (callable) – The cost function to be evaluated. Must accept a list of parameters and return a cost value.
+
bounds (numpy.ndarray, optional) – A 2x2 array specifying the [min, max] bounds for each parameter. If None, uses get_param_bounds.
+
optim (object, optional) – An optimizer instance which, if provided, overlays its specific trace on the plot.
+
steps (int, optional) – The number of intervals to divide the parameter space into along each dimension (default is 10).
Returns:
-
A Plotly figure object representing the cost landscape plot.
+
The Plotly figure object containing the cost landscape plot.
Return type:
plotly.graph_objs.Figure
Raises:
-
ValueError – If the cost function does not behave as expected.
+
ValueError – If the cost function does not return a valid cost when called with a parameter list.
Generate a list of Plotly Scatter trace objects from provided trace data.
-
This function assumes that each column in the trace_data represents a separate trace to be plotted,
-and that the params list contains objects with a name attribute used for trace names.
-Text wrapping for trace names is performed by pybop.StandardPlot.wrap_text.
-
Parameters:
-- params (list): A list of objects, where each object has a name attribute used as the trace name.
-
-
The list should have the same length as the number of traces in trace_data.
-
-
-
trace_data (list of lists): A 2D list where each inner list represents y-values for a trace.
-
-
x_values (list, optional): A list of x-values to be used for all traces. If not provided, a
range of integers starting from 0 will be used.
+
Create traces for plotting parameter evolution.
+
+
Parameters:
+
+
params (list) – List of parameter objects, each having a ‘name’ attribute used for labeling the trace.
+
trace_data (list of numpy.ndarray) – A list of arrays representing the historical values of each parameter.
+
x_values (list or numpy.ndarray, optional) – The x-axis values for plotting. If None, defaults to sequential integers.
+
+
+
Returns:
+
A list of Scatter trace objects, one for each parameter.
+
+
Return type:
+
list of plotly.graph_objs.Scatter
-
-
-
Returns:
-- list: A list of Plotly go.Scatter objects, each representing a trace to be plotted.
-
Notes:
-- The function depends on pybop.StandardPlot.wrap_text for text wrapping, which needs to be available
-
-
in the execution context.
-
-
-
The function assumes that go from plotly.graph_objs is already imported as go.
An object representing the optimisation process, which should contain
-information about the cost function, optimiser, and the history of the
-parameter values throughout the iterations.
-
-
xaxis_titlestr, optional
Title for the x-axis, representing the iteration number or a similar
-discrete time step in the optimisation process (default is “Iteration”).
-
-
yaxis_titlestr, optional
Title for the y-axis, which typically represents the metric being
-optimised, such as cost or loss (default is “Cost”).
+
Plot the evolution of parameters during the optimization process using Plotly.
+
+
Parameters:
+
+
optim (object) – The optimization object containing the history of parameter values and associated cost.
+
xaxis_titles (str, optional) – Title for the x-axis, defaulting to “Iteration”.
+
yaxis_titles (list of str, optional) – Titles for the y-axes, one for each parameter. If None, parameter names are used.
+
title (str, optional) – Title of the plot, defaulting to “Convergence”.
+
-
titlestr, optional
Title of the plot, which provides an overall description of what the
-plot represents (default is “Convergence”).
+
Returns:
+
A Plotly figure object showing the parameter evolution over iterations.
The Plotly figure object for the plot depicting how the parameters of
-the optimisation algorithm evolve over its course. This can be useful
-for diagnosing the behaviour of the optimisation algorithm.
The function assumes that the ‘optim’ object has a ‘cost.problem.parameters’
-attribute containing the parameters of the optimisation algorithm and a ‘log’
-attribute containing a history of the iterations.
Manages the installation and configuration of Plotly for generating visualisations.
-
This class checks if Plotly is installed and, if not, prompts the user to install it.
-It also ensures that the Plotly renderer and browser settings are properly configured
-to display plots.
-
Methods:
-ensure_plotly_installed: Verifies if Plotly is installed and installs it if necessary.
-prompt_for_plotly_installation: Prompts the user for permission to install Plotly.
-install_plotly_package: Installs the Plotly package using pip.
-post_install_setup: Sets up Plotly default renderer after installation.
-check_renderer_settings: Verifies that the Plotly renderer is correctly set.
-check_browser_availability: Checks if a web browser is available for rendering plots.
-
Usage:
-Instantiate the PlotlyManager class to automatically ensure Plotly is installed
-and configured correctly when creating an instance.
-Example:
-plotly_manager = PlotlyManager()
Plot the target dataset against the minimised model output.
+
Quickly plot the target dataset against minimized model output.
classpybop.plotting.quick_plot.StandardPlot(x, y, cost, y2=None, title=None, xaxis_title=None, yaxis_title=None, trace_name=None, width=1024, height=576)[source]#
-
A class for creating and displaying a plotly figure that compares a target dataset against a simulated model output.
-
This class provides an interface for generating interactive plots using Plotly, with the ability to include an
-optional secondary dataset and visualize uncertainty if provided.
Welcome to PyBOP, a Python package dedicated to the optimization and parameterization of battery models. PyBOP is designed to streamline your workflow, whether you are conducting academic research, working in industry, or simply interested in battery technology and modelling.
Version: v23.11
@@ -392,6 +418,7 @@
Parameterise and Optimise Battery Models with PyBOP
If you are installing PyBOP for development purposes, such as contributing to the project, please ensure that you follow the guidelines outlined in the contributing guide. It includes additional steps that might be necessary for setting up a development environment, including the installation of dependencies and setup of pre-commit hooks.