dimod.binary.BinaryQuadraticModel.reduce_quadratic#

BinaryQuadraticModel.reduce_quadratic(function: Callable, initializer: float | floating | integer | None = None) Any[source]#

Apply function of two arguments cumulatively to the quadratic biases.

See functools.reduce() for information on reducing an iterable to a single value.

Parameters:
  • function – Function of two arguments to apply cumulatively to quadratic biases.

  • initializer – A value to precede the linear biases.

Examples

>>> from operator import add
>>> bqm = dimod.BinaryQuadraticModel({0: 10},
...                                  {(0, 1): 1, (0, 2): 2, (1, 2): 5},
...                                  0, "BINARY")
>>> bqm.reduce_quadratic(add, 0.25)
8.25