dimod.generators.or_gate

or_gate(in0: Hashable, in1: Hashable, out: Hashable, *, strength: float = 1.0) dimod.binary.binary_quadratic_model.BinaryQuadraticModel[source]

Generate a binary quadratic model with ground states corresponding to an OR gate.

Parameters
  • in0 – Variable label for one of the inputs.

  • in1 – Variable label for one of the inputs.

  • out – Variable label for the output.

  • strength – Energy of the lowest-energy infeasible state.

Returns

A binary quadratic model with ground states corresponding to an OR gate. The model has three variables and three interactions.

Examples

>>> bqm = dimod.generators.or_gate('x1', 'x2', 'z')
>>> print(dimod.ExactSolver().sample(bqm).lowest())
  x1 x2  z energy num_oc.
0  0  0  0    0.0       1
1  0  1  1    0.0       1
2  1  1  1    0.0       1
3  1  0  1    0.0       1
['BINARY', 4 rows, 4 samples, 3 variables]