dwavebinarycsp.factories.constraint.gates.fulladder_gate#
- fulladder_gate(variables, vartype=Vartype.BINARY, name='FULL_ADDER')[source]#
Full adder.
- Parameters:
variables (list) – Variable labels for the and gate as [in1, in2, in3, sum, carry], where in1, in2, in3 are inputs to be added and sum and ‘carry’ the resultant outputs.
vartype (Vartype, optional, default='BINARY') –
Variable type. Accepted input values:
Vartype.SPIN, ‘SPIN’, {-1, 1}
Vartype.BINARY, ‘BINARY’, {0, 1}
name (str, optional, default='FULL_ADDER') – Name for the constraint.
- Returns:
Constraint that is satisfied when its variables are assigned values that match the valid states of a Boolean full adder.
- Return type:
Constraint(
Constraint
)
Examples
>>> import dwavebinarycsp.factories.constraint.gates as gates >>> csp = dwavebinarycsp.ConstraintSatisfactionProblem(dwavebinarycsp.BINARY) >>> csp.add_constraint(gates.fulladder_gate(['a', 'b', 'c_in', 'total', 'c_out'], name='FA1')) >>> csp.check({'a': 1, 'b': 0, 'c_in': 1, 'total': 0, 'c_out': 1}) True