dimod.binary.BinaryQuadraticModel.from_numpy_vectors#

classmethod BinaryQuadraticModel.from_numpy_vectors(linear: ~numpy._typing._array_like._SupportsArray[~numpy.dtype[~typing.Any]] | ~numpy._typing._nested_sequence._NestedSequence[~numpy._typing._array_like._SupportsArray[~numpy.dtype[~typing.Any]]] | bool | int | float | complex | str | bytes | ~numpy._typing._nested_sequence._NestedSequence[bool | int | float | complex | str | bytes], quadratic: ~numpy._typing._array_like._SupportsArray[~numpy.dtype[~typing.Any]] | ~numpy._typing._nested_sequence._NestedSequence[~numpy._typing._array_like._SupportsArray[~numpy.dtype[~typing.Any]]] | bool | int | float | complex | str | bytes | ~numpy._typing._nested_sequence._NestedSequence[bool | int | float | complex | str | bytes], offset: float, vartype: ~dimod.vartypes.Vartype, *, variable_order: ~typing.Iterable | None = None, dtype: ~numpy.dtype[~typing.Any] | None | type[~typing.Any] | ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]] | str | tuple[~typing.Any, int] | tuple[~typing.Any, ~typing.SupportsIndex | ~collections.abc.Sequence[~typing.SupportsIndex]] | list[~typing.Any] | ~numpy._typing._dtype_like._DTypeDict | tuple[~typing.Any, ~typing.Any] = <class 'numpy.float64'>) BinaryQuadraticModel[source]#

Create a binary quadratic model from NumPy vectors.

Parameters:
  • linear – Linear biases.

  • quadratic – Quadratic biases.

  • offset – Offset of the binary quadratic model.

  • vartype

    Variable type for the binary quadratic model. Accepted input values:

  • variable_order – Variable order for the binary quadratic model’s labels.

  • dtype – Data type for the returned binary quadratic model.

Returns:

A binary quadratic model.

Examples

>>> import numpy as np
>>> linear = np.ones(10)
>>> quadratic = (np.arange(0, 10), np.arange(1, 11), -np.ones(10))
>>> bqm = dimod.BQM.from_numpy_vectors(linear, quadratic, 0, "BINARY")