dimod.quadratic.Integers#

Integers(labels: int | Iterable[Hashable], dtype: dtype[Any] | None | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any] = None) Iterator[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