dwavebinarycsp.Constraint.flip_variable#

Constraint.flip_variable(v)[source]#

Flip a variable in the constraint.

Parameters:

v (variable) – Variable in the constraint to take the complementary value of its construction value.

Examples

This example creates a constraint that \(a = b\) on binary variables and flips variable a.

>>> const = dwavebinarycsp.Constraint.from_func(operator.eq,
...             ['a', 'b'], dwavebinarycsp.BINARY)
>>> const.check({'a': 0, 'b': 0})
True
>>> const.flip_variable('a')
>>> const.check({'a': 1, 'b': 0})
True
>>> const.check({'a': 0, 'b': 0})
False