I need to find the global minimum of a function F(x_1, x_2, ...) whose entries can take only two possible values, 0 and 1. I'm trying to use scipy.optimize.shgo like this
optimize.shgo( F , bounds, args= args , constraints=cons)
but I don't know how to pass the two-possible-values restriction in shgo.
Thanks in advance!
You cannot. Simplicial homology global optimization is designed for continuous function optimization and does not suit your discrete case. And in general, scipy optimization does not have support for discrete variables even for annealing. Theoretically, using non-convex constraints you can restrict discrete values but it never works well in practice.
Depends on your function type you may look to bonmin or cbc solver via https://pypi.org/project/Pyomo/ interface or to annealing https://pypi.org/project/simanneal/ or there are should be plenty of genetic optimization implementations.