dimod.reference.samplers.ExactSolver.sample¶
-
ExactSolver.sample(bqm, **kwargs)[source]¶ Sample from a binary quadratic model.
Parameters: bqm ( BinaryQuadraticModel) – Binary quadratic model to be sampled from.Returns: A dimod Responseobject.Return type: ResponseExamples
This example provides samples for a two-variable Ising model.
>>> import dimod >>> sampler = dimod.ExactSolver() >>> bqm = dimod.BinaryQuadraticModel({0: 0.0, 1: 1.0}, {(0, 1): 0.5}, -0.5, dimod.SPIN) >>> response = sampler.sample(bqm) >>> response.data_vectors['energy'] array([-1., -2., 1., 0.])