[Solved] ValueError when running the automated minor-embedding example

When I run the automated minnor-embedding example from the Docs:

from dwave.system.samplers import DWaveSampler
from dwave.system.composites import EmbeddingComposite

# Set Q for the problem QUBO
linear = {('x0', 'x0'): -1, ('x1', 'x1'): -1, ('x2', 'x2'): -1}
quadratic = {('x0', 'x1'): 2, ('x0', 'x2'): 2, ('x1', 'x2'): 2}
Q = dict(linear)
Q.update(quadratic)

# Minor-embed and sample 1000 times on a default D-Wave system
response = EmbeddingComposite(DWaveSampler()).sample_qubo(Q, num_reads=1000)
for sample, energy, num_occurrences in response.data():
print(sample, "Energy: ", energy, "Occurrences: ", num_occurrences)

I get this error:
for sample, energy, num_occurrences in response.data():
ValueError: too many values to unpack (expected 3)

Any way of debugging this?

0

Comments

1 comment
  • I found the solution. response.data() has an extra value _chain in its output. So changing

    for sample, energy, num_occurrences in response.data():
    print(sample, "Energy: ", energy, "Occurrences: ", num_occurrences)

    to

    for sample, energy, num_occurrences, chain in response.data():
    print(sample, "Energy: ", energy, "Occurrences: ", num_occurrences, "Chain:", chain)

    solves the problem.
    2
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post