Skip to content
This repository has been archived by the owner on Jan 26, 2023. It is now read-only.

QBSolv.sample accepts but ignores num_reads #150

Open
spakin opened this issue Jul 21, 2020 · 1 comment
Open

QBSolv.sample accepts but ignores num_reads #150

spakin opened this issue Jul 21, 2020 · 1 comment

Comments

@spakin
Copy link
Contributor

spakin commented Jul 21, 2020

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
Copy link
Contributor Author

spakin commented Jul 21, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant