WeightedSumGoal#

class WeightedSumGoal(measurements, weights, sum_of_squares_options=None)[source]#

Bases: NormalizableMeasurement, Differentiable

Combine multiple measurements into a single goal function.

__init__(measurements, weights, sum_of_squares_options=None)[source]#
Parameters:
  • measurements (list[DifferentiableNormalizableMeasurement]) – List of measurements.

  • weights (Array) – List of weights.

  • sum_of_squares_options (dict | None) –

    A dictionary that contains information about how to include the sum of square differences in the cost function. If not None then it must contain the keys:

    • weight (float): The weight of the sum of square differences.

    • meas_bool (list[bool]): A list of booleans of the same length as measurements. If an element is True, the corresponding measurement is included in the sum of square difference goal function.

Raises:

Methods

__init__(measurements, weights[, ...])

calculate_normalized_scalar(times)

Measure the normalized observable.

get_gradient(times)

Sum of weighted measurements from gradient-ized measurements.

get_value(times)

Sum of plain weighted measurements.

get_value_and_gradient(times)

Calculate the value and the gradient of the object.

Attributes

measurements

Return the list of measurements.

measurements_in_sum_of_squares

Return the list of measurements included in the sum of square difference cost function.

sum_of_square_options

Return the dictionary with the options about the sum of square differences goal function.

weights

Return the weights used in the weighted goal function.

calculate_normalized_scalar(times)[source]#

Measure the normalized observable.

Returns a single scalar value between 0 and 1. This function must be implemented by subclasses.

Parameters:

times (Array) – One-dimensional vector of timestamps.

Returns:

Returns a Float if implemented by a subclass.

Return type:

Float

get_gradient(times)[source]#

Sum of weighted measurements from gradient-ized measurements.

Parameters:

times (Array) – Array of times.

Returns:

The sum of gradients.

Return type:

Array

get_value(times)[source]#

Sum of plain weighted measurements.

Returns:

Returns the plain weighted sum.

Return type:

Array | Float

get_value_and_gradient(times)[source]#

Calculate the value and the gradient of the object.

Note

The default implementation here gathers the value and the gradient separately. For cases where the value can be obtained during the gradient calculation, this method is overwritten for efficiency.

Returns:

The value and the gradient of the object.

Return type:

tuple[Array | Float, Array]

property measurements: list[DifferentiableNormalizableMeasurement]#

Return the list of measurements.

property measurements_in_sum_of_squares: list[DifferentiableNormalizableMeasurement]#

Return the list of measurements included in the sum of square difference cost function.

property sum_of_square_options: dict | None#

Return the dictionary with the options about the sum of square differences goal function.

property weights: Array#

Return the weights used in the weighted goal function.