dwavesystems / dwave-neal

An implementation of a simulated annealing sampler for general Ising model graphs in C++ with a dimod Python wrapper.
https://docs.ocean.dwavesys.com/projects/neal/en/latest
Apache License 2.0
50 stars 44 forks source link

Pass some context to user-supplied interrupt callback #82

Open randomir opened 4 years ago

randomir commented 4 years ago

Currently, the interrupt callback function is called after each sample (read), but it receives no context, like last sample or energy. Furthermore, it's not even possible to capture references to sample/energy arrays in closure because they are created in cython code and returned to python on the very end of sampling (i.e. after interrupted).

So, providing references to sample/energy numpy arrays (semi-filled) on each call of interrupt callback would enable user to stop sampling when energy threshold is reached, for example.