dimod.AdjDictBQM.to_coo

AdjDictBQM.to_coo(fp=None, vartype_header=False)

Serialize the binary quadratic model to a COOrdinate format encoding.

COOrdinate is a sparse encoding for binary quadratic models.

Parameters:
  • fp (file, optional) – .write()-supporting file object to save the linear and quadratic biases of a binary quadratic model to. The model is stored as a list of 3-tuples, (i, j, bias), where \(i=j\) for linear biases. If not provided, returns a string.
  • vartype_header (bool, optional, default=False) – If true, the binary quadratic model’s variable type as prepended to the string or file as a header.

Note

Variables must use index lables (numeric lables). Binary quadratic models saved to COOrdinate format encoding do not preserve offsets.

Note

This method will be deprecated in the future. The preferred pattern is to use dump() or dumps() directly.