dimod.quadratic.Integers

Integers(labels: Union[int, Iterable[Hashable]], 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) Iterator[dimod.quadratic.quadratic_model.QuadraticModel][source]

Yield quadratic models, each with a single integer variable.

Parameters
  • labels – Either an iterable of variable labels or a number. If a number labels are generated using uuid.UUID.

  • dtype – Data type for the returned quadratic models.

Yields

A QuadraticModel for each integer variable.

Examples

>>> i, j = dimod.Integers(['i', 'j'])
>>> qm = 2*(pow(i, 2) + pow(j, 2)) - 3*i*j - i - j
>>> print(qm.to_polystring())
-i - j + 2*i*i - 3*i*j + 2*j*j