dwavebinarycsp.Constraint.fix_variable#
- Constraint.fix_variable(v, value)[source]#
Fix the value of a variable and remove it from the constraint.
- Parameters:
Examples
This example creates a constraint that \(a \ne b\) on binary variables, fixes variable a to 0, and tests two candidate solutions.
>>> const = dwavebinarycsp.Constraint.from_func(operator.ne, ... ['a', 'b'], dwavebinarycsp.BINARY) >>> const.fix_variable('a', 0) >>> const.check({'b': 1}) True >>> const.check({'b': 0}) False