dwave-system icon indicating copy to clipboard operation
dwave-system copied to clipboard

Add embedding validity check in FixedEmbeddingComposite and possibly others

Open randomir opened this issue 5 years ago • 0 comments

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

randomir avatar Feb 22 '20 16:02 randomir