TreeDecompositionSolver.sample(bqm: dimod.binary.binary_quadratic_model.BinaryQuadraticModel, num_reads: Optional[int] = 1, elimination_order: Optional[List[Hashable]] = None) dimod.sampleset.SampleSet[source]

Find ground states of a binary quadratic model.

  • bqm – Binary quadratic model (BQM).

  • num_reads – Total number of samples to draw. The samples are drawn in order of energy so if num_reads=1, only the ground state is returned. If num_reads=2, the ground state and the first excited state are returned. If num_reads >= len(bqm)**2, samples are duplicated.

  • elimination_order – Variable elimination order. Should be a list of the variables in the binary quadratic model. If None, the min-fill heuristic 1 is used to generate one.


ValueError – The treewidth of the given BQM and elimination order cannot exceed the value provided in properties.


Gogate & Dechter, “A Complete Anytime Algorithm for Treewidth”, https://arxiv.org/abs/1207.4109