dimod.binary.Binary

Binary(label: Optional[Hashable] = None, bias: Union[float, numpy.floating, numpy.integer] = 1, dtype: Union[numpy.dtype, None, type, numpy.typing._dtype_like._SupportsDType[numpy.dtype], str, Tuple[Any, int], Tuple[Any, Union[typing_extensions.SupportsIndex, Sequence[typing_extensions.SupportsIndex]]], List[Any], numpy.typing._dtype_like._DTypeDict, Tuple[Any, Any]] = None) dimod.binary.binary_quadratic_model.BinaryQuadraticModel[source]

Return a binary quadratic model with a single binary variable.

Parameters
  • label – Hashable label to identify the variable. Defaults to a generated uuid.UUID as a string.

  • bias – Bias to apply to the variable.

  • dtype – Data type for the returned binary quadratic model.

Returns

A BinaryQuadraticModel representing a binary variable.

Examples

This example generates a BQM to represent the polynomial, :math:3x -1.5`, where \(x\) is a binary variable with values \(\{0, 1\}\).

>>> x = dimod.Binary('x')
>>> bqm = 3*x - 1.5
>>> print(bqm.to_polystring())
-1.5 + 3*x