Attention
dwavegreedy
is deprecated since dwaveoceansdk
6.1.0 in favor of
dwavesamplers and will be removed in dwaveoceansdk
8.0.0.
Samplers¶
The dwavegreedy package currently includes just one sampler,
SteepestDescentSampler
, which is an alias for
SteepestDescentSolver
.
A sampler accepts a binary quadratic model (BQM) and returns variable assignments. Samplers generally try to find minimizing values but can also sample from distributions defined by the BQM.
SteepestDescentSolver¶
Class¶
 class SteepestDescentSolver[source]¶
Steepest descent sampler for binary quadratic models.
Steepest descent is the discrete analogue of gradient descent, but the best move is computed using a local minimization rather rather than computing a gradient. The dimension along which to descend is determined, at each step, by the variable flip that causes the greatest reduction in energy.
Solves convex problems to optimality.
Number of downhill runs (samples produced) is determined by
num_reads
, number ofinitial_states
, or a combination of the two, depending on theinitial_states_generator
.For a given input model’s graph \(G = (V, E)\), \(V\) being a set of graph vertices and \(E\) a set of edges, runtime complexity of the underlying C++ implementation is \(O(E)\) for initialization phase and \(O(V)\) per downhill step.
In the
large_sparse_opt
mode, runtime complexity on sparse graphs is \(O(V*logV)\) for initialization and \(O(max\_degree * logV)\) per downhill step.Aliased as
SteepestDescentSampler
.Examples
Solve a simple Ising problem.
>>> from dwave.samplers import SteepestDescentSampler ... >>> sampler = SteepestDescentSampler() >>> samples = sampler.sample_ising({0: 2, 1: 2}, {(0, 1): 1}) ... >>> print(samples) 0 1 energy num_oc. num_st. 0 1 1 5.0 1 2 ['SPIN', 1 rows, 1 samples, 2 variables]
Postprocesses samples generated by another sampler (simulated annealing in this example):
>>> from dwave.samplers import SteepestDescentSampler, SimulatedAnnealingSampler >>> import dimod ... >>> bqm = dimod.generators.ran_r(5, 3) >>> samples = SimulatedAnnealingSampler().sample(bqm) >>> postprocessed = SteepestDescentSampler().sample(bqm, initial_states=samples)
For additional examples, see
sample()
.
Attributes¶
Values for parameters accepted by the sampling methods. 

Keyword arguments accepted by the sampling methods. 
Methods¶

Sample from a binary quadratic model. 

Sample from an Ising model using the implemented sample method. 
Sample from a QUBO using the implemented sample method. 
SteepestDescentSampler¶
Class¶
 SteepestDescentSampler[source]¶
alias of
dwave.samplers.greedy.sampler.SteepestDescentSolver