two simulated annealer give different solution
yuxin-chang opened this issue · 1 comments
Hello Joseph,
I got different solutions from qubovert.sim.anneal_qubo() and neal.SimulatedAnnealingSampler().sample_qubo().
Here is my code if you would like to run it on your side:
simulated_annealer.zip
Please let me know if you have some explanations, or there is something wrong in my code.
Also I am confused of SimulatedAnnealingSampler().sample_qubo(dwave_qubo, num_runs=10)
I looked into cource code of neal: I did not find any statement about num_runs. Could you please clarify it with me?
Thank you,
Yuxin
Hey Yuxin,
There are a few parts to the answer to your question.
- Simulated annealing is inherently a random algorithm. Therefore, it's not guaranteed that two runs of even the same simulated annealing algorithm will give the same result.
- qubovert's implementation of simulated annealing is slightly different than neal's implementation, so it will not always get the same result as neal.
- It looks like you are generating random QUBOs, and they probably have a degenerate optimal solution. This means that there are multiple solutions that give the same optimal QUBO value. Therefore it is very likely that the output of simulated annealing will be one of these many possible optimal solutions.
- Most importantly, though, in your code it looks like you are running neal 10 times but qubovert only once. The
num_runs
parameter in neal is analogous to thenum_anneals
parameter in qubovert. In your code, you setnum_runs=10
butnum_anneals=1
.
My recommendation: try setting num_anneals=10
and you should start seeing more comparable results between neal and qubovert. However please keep in mind that qubovert and neal still may return different result; this is just the nature of simulated annealing.
Also keep an eye out for updates of qubovert, I will be updating it soon. Among other things, I plan to make the anneal_qubo
function faster.