dimod.binary.BinaryQuadraticModel.reduce_neighborhood#
- BinaryQuadraticModel.reduce_neighborhood(v: Hashable, function: Callable, initializer: float | floating | integer | None = None) Any [source]#
Apply function of two arguments cumulatively to the quadratic biases associated with a single variable.
See
functools.reduce()
for information on reducing an iterable to a single value.- Parameters:
v – Variable in the binary quadratic model.
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_neighborhood(0, add, 0.25) 3.25