def fix_variable(self, v, value):
variables = self.variables<EOL>try:<EOL><INDENT>idx = variables.index(v)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise ValueError("<STR_LIT>".format(v))<EOL><DEDENT>if value not in self.vartype.value:<EOL><INDENT>raise ValueError("<STR_LIT>".format(self.vartype.value, value))<EOL><DEDENT>configurations = frozenset(config[:idx] + config[idx + <NUM_LIT:1>:]  <EOL>for config in self.configurations<EOL>if config[idx] == value)<EOL>if not configurations:<EOL><INDENT>raise UnsatError("<STR_LIT>".format(v, value))<EOL><DEDENT>variables = variables[:idx] + variables[idx + <NUM_LIT:1>:]<EOL>self.configurations = configurations<EOL>self.variables = variables<EOL>def func(*args): return args in configurations<EOL>self.func = func<EOL>self.name = '<STR_LIT>'.format(self.name, v, value)<EOL>
Fix the value of a variable and remove it from the constraint.

        Args:
            v (variable):
                Variable in the constraint to be set to a constant value.

            val (int):
                Value assigned to the variable. Values must match the :class:`.Vartype` of the
                constraint.

        Examples:
            This example creates a constraint that :math:`a \\ne b` on binary variables,
            fixes variable a to 0, and tests two candidate solutions.

            >>> import dwavebinarycsp
            >>> 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