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 if variable_order is provided.

  • return_labels – If True, returns a list of variable labels in the order used.

Returns:

A named tuple with fields linear_biases, quadratic, and offset. If return_labels == True, it also includes a labels field.

linear_biases is a length BinaryQuadraticModel.num_variables array containing the linear biases.

quadratic is a named tuple with fields row_indices, col_indices, and biases. row_indices and col_indices are length BinaryQuadraticModel.num_interactions` arrays containing the interaction indices. biases contains the biases.

offset is the offset.

labels are the variable labels used.

Deprecated since version 0.10.0: The dtype and index_dtype keyword arguments will be removed in 0.12.0. They currently do nothing.