Simulated Annealing in a specific time

I am using D-Wave's simulated annealing sampler. I want to run SA in one hour. Anyone know any parameters to set time for running this SA sampler? or I need to write a loop to iterate SA within one hour. My purpose is to keep one SA running in one hour, not multiple SAs running in one hour.

Hope anyone can suggest me the way to do it.

0

Comments

6 comments
  • Hello,

    The SimulatedAnnealingSampler does not have functionality out of the box to allow for an annealing time to be set.

    One way of enabling a timed type of behaviour is to loop over the simulated annealing sampler in a for loop or with something like the dwave-hybrid workflow
    The problem can be run once to estimate how long one run takes, and then repeated enough times to fill an hour's worth of time.
    The num_reads can be set to 1 to produce a single sample.
    It was suggested to set the number of sweeps such that the run time is 5-10% of the total run time.
    In addition, it's important to pass some parameters and not let the default go through, because neal (SimulatedAnnealingSampler) spends some time finding the beta_range (which can be passed from one call to the other)

    There are also different kinds of solvers/samplers that can take a time value as a parameter, such as TabuSampler and LeapHybridSampler.

    I hope this is all helpful.

    Please let us know if you have any questions.

     

    0
    Comment actions Permalink
  • Thank you, David.

    I also have another concern. I see in the documentation of SimulatedAnnealingSampler (https://docs.ocean.dwavesys.com/projects/neal/en/latest/_modules/neal/sampler.html#SimulatedAnnealingSampler), it has "interrupt_function" parameter. Do you know how can I use this parameter? I want to find samples that these samples' energy is less than a threshold. How can I do with using this parameter?

    Regards, 

    0
    Comment actions Permalink
  • Hello,

    The interrupt_function gets called in between each sample. 
    Although it has many potential uses, I believe this was originally used to interrupt the SimulatedAnnealingSampler if another sampler had completed in the dwave-hybrid workflows.
    I believe this could be done using state, but I would have to write some test code.

    I need to do a little more research to see if the energy state of the last iteration of the Simulated Annealer is available to the function call. 
    It might not be.

    One thing you would have to be careful of is making sure the sampler doesn't run indefinitely.
    You can imagine a scenario where you define an energy level that is lower than the possible lowest energy state.
    In this scenario you would want to have a max time.

    To use the interrupt function, you would define a function that takes no parameters and then pass it in as a parameter.

    def my_interrupt_function():
        return True

    sampler = SimulatedAnnealingSampler()
    sampleset = sampler.sample(bqm, interrupt_function = my_interrupt_function)

    I hope this information is helpful in the mean time. 
    I will try to get back to you with more information about if it's possible to access energy states from this call.

     

    1
    Comment actions Permalink
  • I just heard back from my technical team, and they let me know that with the current implementation it is not possible to access the energies on the interrupt.

    I believe it is possible to do short simulated annealing runs, checking the results and then passing them back in at the start.

    The dwave-hybrid workflows that I mentioned above would help make this easier, so it might be a good place to start.

    Please let us know if you have any more questions.

    1
    Comment actions Permalink
  • This is also a good time to mention that if there is functionality that you would like, it is always possible to put in a feature request.

    Not all feature requests can be implemented, but letting us know what you need/want is really helpful all around.

    My colleague put in a feature request on your behalf:
    https://github.com/dwavesystems/dwave-neal/issues/82

    Feel free to watch or comment on this feature request so you can see if any movement on this occurs.

    0
    Comment actions Permalink
  • Thank you so much David J

    1
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post