dwavebinarycsp.factories.constraint.sat.sat2in4#

sat2in4(pos, neg=(), vartype=Vartype.BINARY, name='2-in-4')[source]#

Two-in-four (2-in-4) satisfiability.

Parameters:
  • pos (iterable) – Variable labels, as an iterable, for non-negated variables of the constraint. Exactly four variables are specified by pos and neg together.

  • neg (tuple) – Variable labels, as an iterable, for negated variables of the constraint. Exactly four variables are specified by pos and neg together.

  • vartype (Vartype, optional, default='BINARY') –

    Variable type. Accepted input values:

    • Vartype.SPIN, ‘SPIN’, {-1, 1}

    • Vartype.BINARY, ‘BINARY’, {0, 1}

  • name (str, optional, default='2-in-4') – Name for the constraint.

Returns:

Constraint that is satisfied when its variables are assigned values that satisfy a two-in-four satisfiability problem.

Return type:

Constraint(Constraint)

Examples

>>> import dwavebinarycsp.factories.constraint.sat as sat
>>> csp = dwavebinarycsp.ConstraintSatisfactionProblem(dwavebinarycsp.BINARY)
>>> csp.add_constraint(sat.sat2in4(['w', 'x', 'y', 'z'], vartype='BINARY', name='sat1'))
>>> csp.check({'w': 1, 'x': 1, 'y': 0, 'z': 0})
True