dwave.samplers.PlanarGraphSolver.sample#
- PlanarGraphSolver.sample(bqm: BinaryQuadraticModel, pos: Mapping[Hashable, Tuple[float, float]] | None = None, **kwargs) SampleSet [source]#
Find a ground state of a planar Ising problem without linear biases.
- Parameters:
bqm – Binary quadratic model representing a planar Ising model with no linear biases.
pos – Position for each node as a dict of form
{node: (x-coordinate, y-coordinate),...}
.
Examples
>>> import dimod >>> from dwave.samplers.planar import PlanarGraphSolver >>> bqm = dimod.BinaryQuadraticModel.empty(dimod.SPIN) >>> bqm.add_interaction('a', 'b', +1.0) >>> bqm.add_interaction('b', 'c', +1.0) >>> bqm.add_interaction('c', 'a', +1.0) >>> pos = {'a': (0, 0), 'b': (1, 0), 'c': (0, 1)} >>> sampleset = PlanarGraphSolver().sample(bqm, pos) >>> print(sampleset) a b c energy num_oc. 0 +1 -1 -1 -1.0 1 ['SPIN', 1 rows, 1 samples, 3 variables]