pybop.costs._weighted_cost#

Classes#

WeightedCost

A subclass for constructing a linear combination of cost functions as

Module Contents#

class pybop.costs._weighted_cost.WeightedCost(*costs, weights: list[float] | None = None)[source]#

Bases: pybop.BaseCost

A subclass for constructing a linear combination of cost functions as a single weighted cost function.

Inherits all parameters and attributes from BaseCost.

costs[source]#

The individual PyBOP cost objects.

Type:

pybop.BaseCost

weights#

A list of values with which to weight the cost values.

Type:

list[float]

has_identical_problems[source]#

If True, the shared problem will be evaluated once and saved before the self.compute() method of each cost is called (default: False).

Type:

bool

has_separable_problem[source]#

This attribute must be set to False for WeightedCost objects. If the corresponding attribute of an individual cost is True, the problem is separable from the cost function and will be evaluated before the individual cost evaluation is called.

Type:

bool

compute(y: dict, dy: numpy.ndarray = None, calculate_grad: bool = False) float | tuple[float, numpy.ndarray][source]#

Computes the cost function for the given predictions.

Parameters:
  • y (dict) – The dictionary of predictions with keys designating the signals for fitting.

  • dy (np.ndarray, optional) – The corresponding gradient with respect to the parameters for each signal.

  • calculate_grad (bool, optional) – A bool condition designating whether to calculate the gradient.

Returns:

The weighted cost value.

Return type:

float

_has_identical_problems[source]#
_has_separable_problem = False[source]#
costs[source]#
property has_identical_problems[source]#
minimising[source]#