diff --git a/python/dwave_qbsolv/dimod_wrapper.py b/python/dwave_qbsolv/dimod_wrapper.py index c4de3617..b7013f8e 100644 --- a/python/dwave_qbsolv/dimod_wrapper.py +++ b/python/dwave_qbsolv/dimod_wrapper.py @@ -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): """Sample low-energy states defined by a QUBO using qbsolv. Note: @@ -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` @@ -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) diff --git a/python/dwave_qbsolv/qbsolv_binding.pyx b/python/dwave_qbsolv/qbsolv_binding.pyx index 67abfff4..8ae5d01d 100644 --- a/python/dwave_qbsolv/qbsolv_binding.pyx +++ b/python/dwave_qbsolv/qbsolv_binding.pyx @@ -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. @@ -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