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.
- target_data#
An array containing the target data to fit.
- Type:
array-like
- n_outputs#
The number of outputs in the model.
- Type:
int
- minimising#
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).
- 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:
- 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.
- get_model_inputs(inputs: pybop.parameters.parameter.Inputs)[source]#
- 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:
- 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.simulators.failed_solution.FailedSolution][source]#
Simulate the model for each set of inputs and return the solution and (optionally) the sensitivities.
- _cost#
- _has_sensitivities#
- _minimising = True#
- _parameters#
- _simulator#
- property cost#
- property domain#
- property domain_data#
- property has_sensitivities#
- property minimising#
- property n_parameters#
- property parameters#
- property simulator#
- property target#
- property target_data#