dimod.generators.halfadder_gate#
- halfadder_gate(in0: Hashable, in1: Hashable, sum_: Hashable, carry: Hashable, *, strength: float = 1.0) BinaryQuadraticModel [source]#
Generate a binary quadratic model with ground states corresponding to a half adder gate.
- Parameters:
in0 – Variable label for one of the inputs.
in1 – Variable label for one of the inputs.
sum – Variable label for the sum output.
carry – Variable label for the carry output.
strength – Energy of the lowest-energy infeasible state.
- Returns:
A binary quadratic model with ground states corresponding to a half adder gate. The model has four variables and six interactions.
Examples
>>> bqm = dimod.generators.halfadder_gate('a1', 'a2', 's', 'c') >>> print(dimod.ExactSolver().sample(bqm).lowest()) a1 a2 c s energy num_oc. 0 0 0 0 0 0.0 1 1 0 1 0 1 0.0 1 2 1 0 0 1 0.0 1 3 1 1 1 0 0.0 1 ['BINARY', 4 rows, 4 samples, 4 variables]