Skip to content
This repository was archived by the owner on Jan 26, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions python/dwave_qbsolv/dimod_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self):
@dimod.decorators.bqm_index_labels
def sample(self, bqm, num_repeats=50, seed=None, algorithm=None,
verbosity=-1, timeout=2592000, solver_limit=None, solver=None,
target=None, find_max=False, **sample_kwargs):
target=None, find_max=False, n_solutions=20, **sample_kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this num_reads? I know n_solutions is consistent with QBSolv locally, but we use num_reads in all of the other Ocean samplers.

"""Sample low-energy states defined by a QUBO using qbsolv.

Note:
Expand Down Expand Up @@ -71,6 +71,8 @@ def sample(self, bqm, num_repeats=50, seed=None, algorithm=None,
a state with this energy value or better is discoverd. Default is None.
find_max (bool, optional): Switches from searching for minimization to
maximization. Default is False (minimization).
n_solutions (int, optional): The maximum number of solution samples
returned. Default is 20.

Returns:
:obj:`Response`
Expand All @@ -93,7 +95,8 @@ def sample(self, bqm, num_repeats=50, seed=None, algorithm=None,
Q, offset = bqm.to_qubo()
samples, energies, counts = run_qbsolv(Q=Q, num_repeats=num_repeats, seed=seed, algorithm=algorithm,
verbosity=verbosity, timeout=timeout, solver_limit=solver_limit,
solver=solver, target=target, find_max=find_max, sample_kwargs=sample_kwargs)
solver=solver, target=target, find_max=find_max,
n_solutions=n_solutions, sample_kwargs=sample_kwargs)

response = dimod.SampleSet.from_samples(samples, energy=energies,
num_occurrences=counts, vartype=dimod.BINARY)
Expand Down
4 changes: 2 additions & 2 deletions python/dwave_qbsolv/qbsolv_binding.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ log = logging.getLogger(__name__)

def run_qbsolv(Q, num_repeats=50, seed=17932241798878, verbosity=-1,
algorithm=None, timeout=2592000, solver_limit=None,
solver=None, target=None, find_max=False, sample_kwargs={}):
solver=None, target=None, find_max=False, sample_kwargs={},
n_solutions=20):
"""Entry point to `solve` method in the qbsolv library.

Arguments are described in the dimod wrapper.
Expand Down Expand Up @@ -87,7 +88,6 @@ def run_qbsolv(Q, num_repeats=50, seed=17932241798878, verbosity=-1,
Verbose_ = verbosity

global algo_
cdef int n_solutions = 20 # the maximimum number of solutions returned
if algorithm is None or algorithm == ENERGY_IMPACT:
algo_[0] = "o"
algo_[1] = 0
Expand Down