dimod.AdjDictBQM.from_numpy_matrix

classmethod AdjDictBQM.from_numpy_matrix(mat, variable_order=None, offset=0.0, interactions=None)

Create a binary quadratic model from a NumPy array.

Parameters
  • mat (numpy.ndarray) – Coefficients of a quadratic unconstrained binary optimization (QUBO) model formatted as a square NumPy 2D array.

  • variable_order (list, optional) – If provided, labels the QUBO variables; otherwise, row/column indices are used. If variable_order is longer than the array, extra values are ignored.

  • offset (optional, default=0.0) – Constant offset for the binary quadratic model.

  • interactions (iterable, optional, default=[]) – Any additional 0.0-bias interactions to be added to the binary quadratic model. Only works for shapeable binary quadratic models.

Returns

Binary quadratic model with vartype set to Vartype.BINARY.

Note

This method will be deprecated in the future. The preferred pattern is to use the constructor directly.