dimod.BinaryQuadraticModel.remove_variable¶
-
BinaryQuadraticModel.remove_variable(v)[source]¶ Remove variable v and all its interactions from a binary quadratic model.
Parameters: v (variable) – The variable to be removed from the binary quadratic model. Notes
If the specified variable is not in the binary quadratic model, this function does nothing.
Examples
This example creates an Ising model and then removes one variable.
>>> import dimod ... >>> bqm = dimod.BinaryQuadraticModel({'a': 0.0, 'b': 1.0, 'c': 2.0}, ... {('a', 'b'): 0.25, ('a','c'): 0.5, ('b','c'): 0.75}, ... -0.5, dimod.SPIN) >>> bqm.remove_variable('a') >>> 'a' in bqm.linear False >>> ('b','c') in bqm.quadratic True