11

I am trying to use the scipy.optimize package to optimize a discrete optimization problem (global optimization). Acc to the doc, simulated annealing implemented in scipy.optimize.anneal should be a good choice for the same. But I am not sure how to force the optimizer to search only integer values of the search space. Can someone help?

An illustrative example:

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

where, $x1, x2 \in I$

Hotschke
  • 9,402
  • 6
  • 46
  • 53
goofd
  • 2,028
  • 2
  • 21
  • 33

1 Answers1

5

I've checked scipy.optimize.anneal, and I can't see a way to use discrete values. The way to implement it yourself, is to create a custom "move" function, but the way you have to specify the schedule (by a string) prevents you from doing so.

I think it is a big mistake, if you could just pass a custom schedule class as the parameter, you could customize it for using discrete variables and many more things.

The solution I found is to use this other implementation instead: https://github.com/perrygeo/python-simulated-annealing

Because you have to provide the function which modifies the state, you have control on what values it can have, or if they are discrete or continuous.

Asclepius
  • 57,944
  • 17
  • 167
  • 143
Marc Garcia
  • 3,287
  • 2
  • 28
  • 37
  • thanks a lot.. super : I was looking for something like this. In the meantime I implemented the SA myself to have the control you said – goofd Jun 14 '13 at 23:57