-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimising discrete variables #177
Comments
The option The current documentation is indeed poor: in the computation of the objective function (or in a wrapper around the objective function), the user still also has to make sure to "interpret" the variables as integers, like by taking the Then, using the |
An example: import cma
print(cma.CMAOptions('integer')
{'integer_variables': '[] # index list, invokes basic integer handling: prevent std dev to become too small in the given variables'} As mentioned above, the solutions themselves are still vectors of floats, but the rounded or truncated values of their integer variables can be used as the integer value. import numpy as np
import cma
class F_int:
def __init__(self, f):
self.f = f
def __call__(self, x):
return self.f(np.floor(x))
x0 = 4 * [14] # dimension 4
x, es = cma.fmin2(F_int(cma.ff.ellirot), x0, 1,
{'integer_variables': list(range(len(x0))),
'bounds': [-1, 15 - 1e-9],
'tolflatfitness':9})
finds ~10% of the time the global optimum ( |
It makes sense now, thank you! |
Is there an natural way of optimising parameters over a discrete space? eg. integer space = {-1,0,1}
The integer_variables option
'integer_variables' : [-1,0,1]
seems to be ignored by the sampler and still suggests non-integer variables.There seem to be some research on using CMAES for discrete optimisation but no implementation seems to be available: A discrete version of CMA-ES - arXiv
The text was updated successfully, but these errors were encountered: