dwave.embedding.chain_break_frequency¶

chain_break_frequency
(samples_like, embedding)[source]¶ Determine the frequency of chain breaks in the given samples.
Parameters:  samples_like (samples_like/
dimod.SampleSet
) – A collection of raw samples. ‘samples_like’ is an extension of NumPy’s array_like. Seedimod.as_samples()
.  embedding (dict) – Mapping from source graph to target graph as a dict of form {s: {t, …}, …}, where s is a sourcemodel variable and t is a targetmodel variable.
Returns: Frequency of chain breaks as a dict in the form {s: f, …}, where s is a variable in the source graph and float f the fraction of broken chains.
Return type: Examples
This example embeds a single source node, ‘a’, as a chain of two target nodes (0, 1) and uses
chain_break_frequency()
to show that out of two synthetic samples, one ([1, +1]) represents a broken chain.>>> import numpy as np ... >>> samples = np.array([[1, +1], [+1, +1]]) >>> embedding = {'a': {0, 1}} >>> print(dwave.embedding.chain_break_frequency(samples, embedding)['a']) 0.5
 samples_like (samples_like/