dwave.samplers.TreeDecompositionSampler.sample

TreeDecompositionSampler.sample(bqm: dimod.binary.binary_quadratic_model.BinaryQuadraticModel, num_reads: Optional[int] = 1, elimination_order: Optional[List[Hashable]] = None, beta: Optional[float] = 1.0, marginals: Optional[bool] = True, seed: Optional[int] = None) dimod.sampleset.SampleSet[source]

Draw samples and compute marginals of a binary quadratic model.

Parameters
  • bqm – Binary quadratic model.

  • num_reads – Number of samples to draw.

  • 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.

  • betaBoltzmann distribution inverse temperature parameter.

  • marginals – Whether or not to compute the marginals. If True, they are included in the return SampleSet’s info field. See example in TreeDecompositionSampler.

  • seed – Random number generator seed. Negative values cause a time-based seed to be used.

Returns

  • 'log_partition_function': The log partition function.

If marginals=True, also contains:

  • 'variable_marginals': Dict of the form {v: p, ...}, where v is a variable in the binary quadratic model and p = prob(v == 1).

  • 'interaction_marginals': Dict of the form {(u, v): {(s, t): p, ...}, ...}, where (u, v) is an interaction in the binary quadratic model and p = prob(u == s & v == t).

Return type

Returned dimod.SampleSet.info contains

Raises

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

1

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