dwavebinarycsp.factories.constraint.gates.or_gate

or_gate(variables, vartype=<Vartype.BINARY: frozenset({0, 1})>, name='OR')[source]

OR gate.

Parameters:
  • variables (list) – Variable labels for the and gate as [in1, in2, out], where in1, in2 are inputs and out the gate’s output.
  • vartype (Vartype, optional, default='BINARY') –

    Variable type. Accepted input values:

    • Vartype.SPIN, ‘SPIN’, {-1, 1}
    • Vartype.BINARY, ‘BINARY’, {0, 1}
  • name (str, optional, default='OR') – Name for the constraint.
Returns:

Constraint that is satisfied when its variables are assigned values that match the valid states of an OR gate.

Return type:

Constraint(Constraint)

Examples

>>> import dwavebinarycsp
>>> import dwavebinarycsp.factories.constraint.gates as gates
>>> csp = dwavebinarycsp.ConstraintSatisfactionProblem(dwavebinarycsp.SPIN)
>>> csp.add_constraint(gates.or_gate(['x', 'y', 'z'], {-1,1}, name='OR1'))
>>> csp.check({'x': 1, 'y': -1, 'z': 1})
True