Discrete optimization in python

I am trying to use the scipy.optimize package to optimize the discrete optimization problem (global optimization). According to the document, simulated annealing implemented in scipy.optimize.anneal should be a good choice for him. But I'm not sure how to make the optimizer search only integer values ​​of the search space. Can anyone help?

Illustrative example:

f(x1,x2) = (1-0.4*x1)^2 + 100*(0.6*x2 -0.4*x1^2)^2

where, $x1, x2 \in I$

+7
source share
1 answer

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.

+4
source

All Articles