dimod.binary.BinaryQuadraticModel.add_quadratic_from

BinaryQuadraticModel.add_quadratic_from(quadratic: Union[Mapping, Iterable])[source]

Add quadratic biases to the binary quadratic model.

Parameters

quadratic – Interactions and their associated quadratic biases, as either a dict of form {(u, v): bias, ...} or an iterable of (u, v, bias) triplets, where u and v are variables in the model and bias is the associated quadratic bias. If a variable is not present in the model, it is added. If the interaction already exists, the bias is added.

Raises

ValueError – If any self-loops are given. E.g. (u, u, bias) is not a valid triplet.