dimod.QuadraticModel.energies#

QuadraticModel.energies(samples_like, 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) ndarray[source]#

Determine the energies of the given samples-like.

Parameters:
  • samples_like (samples_like) – Raw samples. samples_like is an extension of NumPy’s array_like structure. See as_samples().

  • dtype – Desired NumPy data type for the energy. Defaults to float64.

Returns:

Energies for the samples.

Examples

>>> from dimod import QuadraticModel, Binary
>>> qm = QuadraticModel()
>>> qm.add_variables_from('BINARY', ['x', 'y'])
>>> qm.add_quadratic('x', 'y', -2)
>>> qm.energies([{'x': 1, 'y': 0}, {'x': 0, 'y': 0}, {'x': 1, 'y': 1}])
array([ 0.,  0., -2.])