dimod.higherorder.polynomial.BinaryPolynomial.energy#
- BinaryPolynomial.energy(sample_like, dtype=<class 'float'>)[source]#
Energy of the given sample.
- Parameters:
sample_like (samples_like) – A raw sample. sample-like is an extension of NumPy’s array_like structure. See
as_samples()
.dtype (
numpy.dtype
, optional) – Data type of the returned energy. Defaults to float.
- Returns:
The energy.
Examples
>>> poly = dimod.BinaryPolynomial({('x', 'y'): -1, ('x', 'y', 'z'): 0.5}, ... 'BINARY') >>> poly.energy({'x': 1, 'y': 1, 'z': 0}) -1.0