dimod.SampleSet.lowest#

SampleSet.lowest(rtol=1e-05, atol=1e-08)[source]#

Return a sample set containing the lowest-energy samples.

A sample is included if its energy is within tolerance of the lowest energy in the sample set. The following equation is used to determine if two values are equivalent:

absolute(a - b) <= (atol + rtol * absolute(b))

See numpy.isclose() for additional details and caveats.

Parameters:
  • rtol (float, optional, default=1.e-5) – The relative tolerance (see above).

  • atol (float, optional, default=1.e-8) – The absolute tolerance (see above).

Returns:

A new sample set containing the lowest energy samples as delimited by configured tolerances from the lowest energy sample in the current sample set.

Return type:

SampleSet

Examples

>>> sampleset = dimod.ExactSolver().sample_ising({'a': .001},
...                                              {('a', 'b'): -1})
>>> print(sampleset.lowest())
   a  b energy num_oc.
0 -1 -1 -1.001       1
['SPIN', 1 rows, 1 samples, 2 variables]
>>> print(sampleset.lowest(atol=.1))
   a  b energy num_oc.
0 -1 -1 -1.001       1
1 +1 +1 -0.999       1
['SPIN', 2 rows, 2 samples, 2 variables]

Note

“Lowest energy” is the lowest energy in the sample set. This is not always the “ground energy” which is the lowest energy possible for a binary quadratic model.