pybop.problems.problem#

Classes#

Problem

Base class for defining a problem within the PyBOP framework, compatible with PINTS.

Module Contents#

class pybop.problems.problem.Problem(simulator: pybop.simulators.base_simulator.BaseSimulator = None, cost: pybop.costs.base_cost.BaseCost = None)[source]#

Base class for defining a problem within the PyBOP framework, compatible with PINTS.

Parameters:
  • simulator (pybop.BaseSimulator) – The model, protocol and optional dataset combined into a simulator object.

  • parameters (list[pybop.Parameter] or pybop.Parameters) – An object or list of the parameters for the problem.

  • cost (pybop.BaseCost, optional) – An cost e.g. an error measure, a log-likelihood or a design cost.

target_data[source]#

An array containing the target data to fit.

Type:

array-like

n_outputs[source]#

The number of outputs in the model.

Type:

int

minimising[source]#

If False, tells the optimiser to switch the sign of the cost and gradient to maximise by default rather than minimise (default: True).

Type:

bool, optional

__call__(inputs: pybop.parameters.parameter.Inputs | list | numpy.ndarray, calculate_grad: bool = False) float | tuple[float, numpy.ndarray] | list[float] | list[tuple[float, numpy.ndarray]][source]#

Compute cost and optional gradient for given input parameters.

Parameters:
  • inputs (Inputs | list[Inputs] | list[float] | np.adarray) – Input parameters for cost computation. Supports list-like evaluation of multiple input values, shaped [N,M] where N is the number of input positions to evaluate and M is the number of inputs for the underlying model (i.e. parameters).

  • calculate_grad (bool) – If True, the gradient will be computed as well as the cost (default: False).

Returns:

  • Single input, no gradient: float

  • Multiple inputs, no gradient: list[float]

  • Single input with gradient: tuple[float, np.ndarray]

  • Multiple inputs with gradient: list[tuple[float, np.ndarray]]

Return type:

Union[float, list, tuple[float, np.ndarray], list[tuple[float, np.ndarray]]]

batch_call(inputs_list: list[pybop.parameters.parameter.Inputs], calculate_grad: bool) list[float] | list[tuple[float, numpy.ndarray]][source]#

Evaluate the cost and (optionally) the gradient for a list of inputs.

get_finite_initial_cost()[source]#

Compute the absolute initial cost, resampling the initial parameters if needed.

join_parameters(parameters)[source]#

Setter for joining parameters. This method sets the fail gradient if the join adds parameters.

sensitivity_analysis(n_samples: int = 256, calc_second_order: bool = False) dict[source]#

Computes the parameter sensitivities on the combined cost function using SOBOL analysis. See pybop.analysis.sensitivity_analysis for more details.

Parameters:
  • n_samples (int, optional) – Number of samples for SOBOL sensitivity analysis, performs best as a power of 2, i.e. 128, 256, etc.

  • calc_second_order (bool, optional) – Whether to calculate second-order sensitivities.

simulate(inputs: pybop.parameters.parameter.Inputs) dict[str, numpy.ndarray] | tuple[dict[str, numpy.ndarray], dict[str, dict[str, numpy.ndarray]]][source]#

Evaluate the model with the given parameters and return the target.

Parameters:

inputs (Inputs) – Parameters for evaluation of the model.

Returns:

The simulated model output y(t), or y(ω) for EIS, for the given inputs.

Return type:

dict[str, np.ndarray[np.float64]]

simulateS1(inputs: pybop.parameters.parameter.Inputs)[source]#

Evaluate the model with the given parameters and return the target and their derivatives.

Parameters:

inputs (Inputs) – Parameters for evaluation of the model.

Returns:

A tuple containing the simulation result y(t) and the sensitivities dy/dx(t) for each parameter x and output variables y simulated with the given inputs.

Return type:

tuple[dict[str, np.ndarray[np.float64]], dict[str, dict[str, np.ndarray]]]

single_call(inputs: pybop.parameters.parameter.Inputs, calculate_grad: bool) float | tuple[float, numpy.ndarray][source]#

Evaluate the cost and (optionally) the gradient for a single set of inputs.

_cost[source]#
_has_sensitivities[source]#
_minimising = True[source]#
_simulator[source]#
property cost[source]#
domain = 'Time [s]'[source]#
property domain_data[source]#
property eis[source]#
property has_sensitivities[source]#
property minimising[source]#
property n_outputs[source]#
property n_parameters[source]#
property parameters[source]#
property simulator[source]#
property target[source]#
property target_data[source]#