Closed DevelopDaily closed 4 years ago
Hello @DevelopDaily, I am not finding an embedding for this Q matrix, using find_embedding
. Could you please capture the embedding that you found, as a JSON object, and attach it here? find_embedding
, for me, is returning an empty set, indicating that it didn't find an embedding.
find_embedding
returns an empty dictionary when it cannot find an embedding. FixedEmbeddingComposite
then raises an exception to indicate that to the user.
When you say that "find_embedding
actually succeeds" do you mean that it returns an embedding or an empty dict?
The find_embedding
returns an empty dictionary. I expect the find_embedding
would also throw an exception if it cannot find an embedding as the FixedEmbeddingComposite
does. Anyway, that is my wrong assumption.
Now that I understand the empty dictionary return actually means "failed to find an embedding", what should I do to make it find one?
Mind you, my QUBO matrix is quite simple. It is populated with random numbers between -10 and 10.
First you should make sure that you're targeting an advantage system rather than a QPU.
sampler = DWaveSampler(solver=dict(topology__type='pegasus'))
If your QUBO is dense, you should try to use DWaveCliqueSampler with an advantage system. I believe 96 variables should fit.
sampler = DWaveCliqueSampler(solver=dict(topology__type='pegasus'))
An alternative would be to tune the running of minorminer, to see if a longer run will result in it finding an embedding.
An intermediate solution is to use the clique embedder (this is done under the hood with DWaveCliqueSampler)
from minorminer.busclique import find_clique_embedding
sampler_graph = sampler.to_networkx_graph()
found = find_clique_embedding(96, sampler_graph)
Good suggestion, @arcondello. Just a minor typo, it should say topology__type='pegasus'
.
Thank's @randomir, fixed above.
@arcondello Thanks. Your advice works perfectly.
@boothby Your code does not work for me. Could you please elaborate more on your code? When running it, I got these arcane errors:
File "minorminer/busclique.pyx", line 85, in minorminer.busclique.find_clique_embedding
AttributeError: 'int' object has no attribute 'graph'
File "minorminer/busclique.pyx", line 90, in minorminer.busclique.find_clique_embedding
ValueError: g must be either a dwave_networkx.chimera_graph or a dwave_networkx.pegasus_graph
Ah, my apologies, I swapped the arguments to find_clique_embedding
. I've edited my comment.
@boothby Thanks. It works beautifully now.
Here is a simple test case to crash the function
FixedEmbeddingComposite
. The QUBO info is in this file q96.zip, which is used to construct a 96x96 QUBOnumpy
matrix.The strange thing is that the
find_embedding
actually succeeds, but theFixedEmbeddingComposite
crashes with this error:ValueError: no embedding found