dimod.quadratic.IntegerArray#
- IntegerArray(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) ndarray [source]#
Return a NumPy array of 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.
- Returns:
Array of quadratic models, each with a single integer variable.
Examples
This example creates a quadratic model that represents a clique (fully-connected graph) of three nodes with integer values.
>>> import numpy as np >>> i = dimod.IntegerArray(["i0", "i1", "i2"]) >>> j = dimod.IntegerArray(["j0", "j1", "j2"]) >>> qm = dimod.quicksum(dimod.quicksum(np.outer(i, j))) >>> print(qm.to_polystring()) i0*j0 + j0*i1 + j0*i2 + i0*j1 + i1*j1 + i2*j1 + i0*j2 + i1*j2 + i2*j2