dimod.ConstrainedQuadraticModel.substitute_self_loops#

ConstrainedQuadraticModel.substitute_self_loops() dict[Hashable, Hashable][source]#

Replace any self-loops in the objective or constraints.

Self-loop \(i^2\) is removed by introducing a new variable \(j\) with interaction \(i*j\) and adding constraint \(j == i\).

Acts on the objective and constraints in-place.

Returns:

Mapping from the integer variable labels to their introduced counterparts. The constraint enforcing \(j == i\) uses the same label.