dimod.BinaryQuadraticModel.remove_interaction¶
-
BinaryQuadraticModel.remove_interaction(u, v)[source]¶ Remove interaction of variables u, v from a binary quadratic model.
Parameters: - u (variable) – One of the pair of variables in the binary quadratic model that has an interaction.
- v (variable) – One of the pair of variables in the binary quadratic model that has an interaction.
Notes
Any interaction not in the binary quadratic model is ignored.
Examples
This example creates an Ising model with three variables that has interactions between two, and then removes an interaction.
>>> import dimod ... >>> bqm = dimod.BinaryQuadraticModel({}, {('a', 'b'): -1.0, ('b', 'c'): 1.0}, 0.0, dimod.SPIN) >>> bqm.remove_interaction('b', 'c') >>> ('b', 'c') in bqm.quadratic False >>> bqm.remove_interaction('a', 'c') # not an interaction, so ignored >>> len(bqm.quadratic) 1