dwave.samplers.TreeDecompositionSampler.sample#

TreeDecompositionSampler.sample(bqm: BinaryQuadraticModel, num_reads: int | None = 1, elimination_order: List[Hashable] | None = None, beta: float | None = 1.0, marginals: bool | None = True, seed: int | None = None) 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.