Closed KeXue-NJU closed 5 years ago
self.strategy = cma.CMAEvolutionStrategy(x_start, 0.5, {'bounds': [[-1], [1]]})
should do.
Check out the output of
import cma
cma.CMAOptions('boun')
{'BoundaryHandler': 'BoundTransform # or BoundPenalty, unused when ``bounds in (None, [None, None])``',
'bounds': '[None, None] # lower (=bounds[0]) and upper domain boundaries, each a scalar or a list/vector'}
Furthermore,
help(cma.CMAEvolutionStrategy)
gives an example, see also here.
Thanks a lot.
hello, can we set a different bounds for each dimension? for example, for 2dim case:
def f(x, y): # a 1-D function
return x**2 + y**2
x0 = [0.5, 0.8]
strategy = cma.CMAEvolutionStrategy(x0, 0.5, {'bounds': [[-1, 1], [0, 5]]})
if I do this, for me it throws an error as following :
ValueError: argument of inverse must be within the given bounds
The lower bound of the second variable, bounds[0][1]
, was set to 1
and the initial solution was 0.8
, below the lower bound, hence the error.
It worked. Thank you for your help!
Here are my core-codes: