dimod.DiscreteQuadraticModel.to_numpy_vectors#
- DiscreteQuadraticModel.to_numpy_vectors(return_offset: bool = False)[source]#
Convert the DQM to five numpy vectors and the labels.
- Parameters:
return_offset – Boolean flag to optionally return energy offset value.
- Returns:
A named tuple with fields [‘case_starts’, ‘linear_biases’, ‘quadratic’, ‘labels’].
case_starts: A length
num_variables()
array. The cases associated with variable v are in the range [case_starts[v], cases_starts[v+1]).linear_biases: A length
num_cases()
array. The linear biases.quadratic: A named tuple with fields [‘row_indices’, ‘col_indices’, ‘biases’].
row_indices: A length
num_case_interactions()
array. If the case interactions were defined in a sparse matrix, these would be the row indices.col_indices: A length
num_case_interactions()
array. If the case interactions were defined in a sparse matrix, these would be the column indices.biases: A length
num_case_interactions()
array. If the case interactions were defined in a sparse matrix, these would be the values.
labels: The variable labels in a
Sequence
.
If return_labels=True, this method will instead return a tuple (case_starts, linear_biases, (irow, icol, qdata), labels) where labels is a list of the variable labels.
- Return type:
DQMVectors
See also