I checked scipy.optimize.anneal and I see no way to use discrete values. The way to implement this yourself is to create a custom "move" function, but the way you should specify a schedule (line by line) does not allow you to do this.
I think this is a big mistake, if you can just pass your own schedule class as a parameter, you can configure it to use discrete variables and much more.
The solution I found is to use this other implementation: https://github.com/perrygeo/python-simulated-annealing
Since you need to provide a function that changes state, you can control what values ββit has, or if they are discrete or continuous.
Hope this helps.
Marc garcia
source share