dimod.quadratic.IntegerArray¶
- IntegerArray(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) numpy.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