dimod.BinaryQuadraticModel.remove_variables_from

BinaryQuadraticModel.remove_variables_from(variables)[source]

Remove specified variables and all of their interactions from a binary quadratic model.

Parameters:variables (iterable) – A collection of variables to be removed from the binary quadratic model. If any variable is not in the model, it is ignored.

Examples

This example creates an Ising model with three variables and interactions among all of them, and then removes two variables.

>>> import dimod
...
>>> bqm = dimod.BinaryQuadraticModel({0: 0.0, 1: 1.0, 2: 2.0},
...                                  {(0, 1): 0.25, (0,2): 0.5, (1,2): 0.75},
...                                  -0.5, dimod.SPIN)
>>> bqm.remove_variables_from([0, 1])
>>> len(bqm.linear)
1
>>> len(bqm.quadratic)
0