dimod.QuadraticModel.add_quadratic_from#
- QuadraticModel.add_quadratic_from(quadratic: Mapping[tuple[Hashable, Hashable], float | floating | integer] | Iterable[tuple[Hashable, Hashable, float | floating | integer]])[source]#
Add quadratic biases.
- 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, whereu
andv
are variables in the model andbias
is the associated quadratic bias. If the interaction already exists, the bias is added.- Raises:
ValueError – If a specified variable is not in the model.
ValueError – If any self-loops are given on binary-valued variables. E.g.
(u, u, bias)
is not a valid triplet for spin variables.