qbsolv icon indicating copy to clipboard operation
qbsolv copied to clipboard

QBSolv.sample accepts but ignores num_reads

Open spakin opened this issue 5 years ago • 1 comments

Description QBSolv.sample accepts num_reads as a parameter but returns a number of samples that seems to have no relation to the value provided.

To Reproduce

#! /usr/bin/env python

from dwave_qbsolv import QBSolv
import dimod

bqm = dimod.BinaryQuadraticModel({}, {(q0, q1): -1 for q0 in range(24) for q1 in range(q0 + 1, 25)}, 0.0, dimod.SPIN)
result = QBSolv().sample(bqm, num_reads=10)
print(result)

Here's what I observe as output:

   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 ... 24 energy num_oc.
0 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 ... +1 -300.0      27
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... -1 -300.0      24
['SPIN', 2 rows, 51 samples, 25 variables]

Expected behavior I expected the output to end with ['SPIN', 2 rows, 10 samples, 25 variables].

Environment:

  • OS: Ubuntu 20.04
  • Python version: 3.8.2
  • dwave-qbsolv version: 0.3.0

spakin avatar Jul 21 '20 23:07 spakin

Actually, it looks like num_reads is getting passed to the underlying sampler. Perhaps this issue needs to be a documentation-clarification request and/or a feature request for a way to specify the number of samples the caller would like returned.

spakin avatar Jul 21 '20 23:07 spakin