dwavesystems / dwavesystems/dwave-system
Unhelpful error message from embed_bqm
- Dominant language
- Python
- Stars
- 98
- Forks
- 67
- Avg merge
- 7m
- Merged PRs (30d)
- 1
Description
```
Q = {(0, 0): 2, (0, 1): -2, (0, 2): -2, (1, 2): 2}
chainstrength = 1
bqm = BinaryQuadraticModel.from_qubo(Q, offset=-2)
dwave_sampler = DWaveSampler()
A = dwave_sampler.edgelist
embedding = find_embedding(Q, A)
bqm_embedded = embed_bqm(bqm, embedding, A, chain_strength=chainstrength)
```
This snippet does not run successfully. Here is the error message:
```
Traceback (most recent call last):
File "one_frustrated.py", line 38, in
bqm_embedded = embed_bqm(bqm, embedding, A, chain_strength=chainstrength)
File "//anaconda/envs/37/lib/python3.7/site-packages/dwave/embedding/transforms.py", line 134, in embed_bqm
raise InvalidNodeError(v, next(u not in target_adjacency for u in chain))
dwave.embedding.exceptions.InvalidNodeError: chain for 0 contains a node label True not contained in the target graph
```
This wasn't a helpful error message. It turns out the problem was what I was passing in, the A item.
I had to change the call to embed_bqm to this:
```
Q = {(0, 0): 2, (0, 1): -2, (0, 2): -2, (1, 2): 2}
chainstrength = 1
bqm = BinaryQuadraticModel.from_qubo(Q, offset=-2)
dwave_sampler = DWaveSampler()
A = dwave_sampler.edgelist
embedding = find_embedding(Q, A)
bqm_embedded = embed_bqm(bqm, embedding, dwave_sampler.adjacency, chain_strength=chainstrength)
```
Notice now I'm passing the adjacency message instead of an edgelist.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.