# How can we get execution time of each annealing while using Neal Simulated Annealing Sampler?

I need to calculate the TTS or Total Time to Solution for the solutions generated using Neal Simulated Annealing Sampler. For the same, I need TAU or annealing time for each annealing cycle. Please help.

1 comment
• Hi Deepak,

Apologies for the delayed response!

The neal.SimulatedAnnealingSampler utilizes a classical heuristic simulated annealing algorithm that runs locally on your system. It solves problems in a fundamentally different way than Quantum annealing (please refer here for more details).

That being said, to fetch the above-requested values, here are the key steps you can perform. Please note, the values you’ll get are machine-dependent, and parameters (such as num_reads, num_sweeps) should be properly tuned to get the correct statistics and error bars:

• You have to compute the ground state energy: on small problems, this can be done by running simulated annealing for many reads, e.g. 10k and many sweeps e.g. 1k, 10k, 100k. The “putative” ground state energy will be the minimum energy you recorded.
• Remember to extract the optimal temperatures (`beta_range`) of SA, from the `beta_range = ``response.info``['beta_range']` and keep them fixed over the entire study: every time you call the `sample` method, just pass the `beta_range` argument. This is to avoid “wasting time” resetting them every time.
• Once you pass the beta range to SA, the time for one read can be estimated as time to sample some predetermined `num_reads` e.g. 1000, divided by `num_reads`.
• The problem then is that there is a tradeoff between how fast you anneal (how many `num_sweeps` you set) and how well SA performs. As an example, for 10 sweeps SA will be very fast but it may not reach optimality, whereas for many, say 100000 sweeps, SA will be slow but it will often get the ground state.
• The goal is to find the optimal number of sweeps for which the estimated TTS is minimal: the latter can be estimated knowing the time for one read and the probability of reaching the ground state. In other words, in a plot with `num_sweeps` on the x-axis and TTS on the y-axis, you would expect a convex function (as shown in the research paper linked below).

Page 13 of the research paper ‘Defining and detecting quantum speedup’, by Troels R., Zhihui W., Joshua J., Sergio B., Sergei I., David W., John M., Daniel L., Matthias T. (2014), explains each of the above steps in more detail.

I hope this helps! Please let us know if you have any other questions.