dimod.binary.BinaryQuadraticModel.to_numpy_vectors#
- BinaryQuadraticModel.to_numpy_vectors(variable_order: Sequence[Hashable] | None = None, *, 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, index_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, sort_indices: bool = False, sort_labels: bool = True, return_labels: bool = False) BQMVectors | LabelledBQMVectors[source]#
Convert binary quadratic model to 1-dimensional NumPy arrays.
- Parameters:
variable_order – Variable order for the vector output. By default uses the order of the binary quadratic model.
sort_indices – Sort the indices of the interactions such that row is always less than column and then lexicographical.
sort_labels – Equivalent to setting
variable_order=sorted(bqm.variables). Ignored ifvariable_orderis provided.return_labels – If True, returns a list of variable labels in the order used.
- Returns:
A named tuple with fields
linear_biases,quadratic, andoffset. Ifreturn_labels == True, it also includes alabelsfield.linear_biasesis a lengthBinaryQuadraticModel.num_variablesarray containing the linear biases.quadraticis a named tuple with fieldsrow_indices,col_indices, andbiases.row_indicesandcol_indicesare lengthBinaryQuadraticModel.num_interactions`arrays containing the interaction indices.biasescontains the biases.offsetis the offset.labelsare the variable labels used.
Deprecated since version 0.10.0: The
dtypeandindex_dtypekeyword arguments will be removed in 0.12.0. They currently do nothing.