pybop.problems.problem#
Classes#
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.
- 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[pybop.parameters.parameter.Inputs]) float | list[float][source]#
Evaluate the cost for one or more sets of inputs and return the cost value(s).
- Parameters:
inputs (Inputs | list[Inputs]) – Input parameters for cost evaluation. Supports a list of inputs.
- Returns:
The cost value(s).
- Return type:
float | list[float]
- evaluate(inputs: pybop.parameters.parameter.Inputs | list[pybop.parameters.parameter.Inputs], calculate_sensitivities: bool = False) pybop.costs.evaluation.Evaluation[source]#
Evaluate the cost for one or more sets of inputs and return the cost value(s) and (optionally) the sensitivities.
- Parameters:
inputs (Inputs | list[Inputs]) – Input parameters for cost evaluation. Supports a list of inputs.
calculate_sensitivities (bool) – Whether to also return the sensitivities (default: False).
- Returns:
The cost value(s) and (optionally) the gradient of the cost with respect to each input parameter.
- Return type:
- evaluate_batch(inputs: list[pybop.parameters.parameter.Inputs], calculate_sensitivities: bool = False) pybop.costs.evaluation.Evaluation[source]#
Evaluate the cost for each set of inputs and return the cost value(s) and (optionally) the sensitivities.
- Parameters:
inputs (list[Inputs]) – A list of input parameters.
calculate_sensitivities (bool) – Whether to also return the sensitivities (default: False).
- Returns:
Cost values of len(inputs) and (optionally) the gradient of the cost with respect to each input parameter with shape (len(inputs), len(parameters)).
- Return type:
- 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 | list[pybop.parameters.parameter.Inputs], calculate_sensitivities: bool = False) pybop.simulators.base_simulator.Solution | list[pybop.simulators.base_simulator.Solution][source]#
Simulate the model for one or more sets of inputs and return the solution and (optionally) the sensitivities.
- Parameters:
inputs (Inputs | list[Inputs]) – Input parameters. Support a list of inputs.
calculate_sensitivities (bool) – Whether to also return the sensitivities (default: False).
- Returns:
- The simulated model output y(t) and (optionally) the sensitivities dy/dx(t)
for output variable(s) y, domain t and parameter(s) x.
- Return type:
- simulate_batch(inputs: list[pybop.parameters.parameter.Inputs], calculate_sensitivities: bool = False) list[pybop.simulators.base_simulator.Solution | pybop._utils.FailedSolution][source]#
Simulate the model for each set of inputs and return the solution and (optionally) the sensitivities.
- Parameters:
inputs (list[Inputs]) – A list of input parameters.
- Returns:
A list of length(inputs) containing the simulated model output y(t) and (optionally) the sensitivities dy/dx(t) for output variable(s) y, domain t and parameter(s) x.
- Return type:
list[Solution]