dwave-system
dwave-system copied to clipboard
Add embedding validity check in FixedEmbeddingComposite and possibly others
FixedEmbeddingComposite currently accepts invalid embeddings (in a sense that chains are not disjoint). Sampling might succeed, but the effective problem that ran on the child sampler is probably not what user wanted (due to implicit chains).
For example:
import dimod
from dwave.system import DWaveSampler, FixedEmbeddingComposite
embedding= {'a': [0, 4], 'b': [4, 3]}
sampler = FixedEmbeddingComposite(DWaveSampler(), embedding)
bqm = dimod.BQM.from_ising({}, {'ab': 1})
sampleset = sampler.sample(bqm)
will happily sample, but checking the sampler's edgelist will fail with an informative message:
>>> sampler.edgelist
...
ValueError: target node 4 assigned to more than one source node