def _evalfull(self, x):
fadd = self.fopt
curshape, dim = self.shape_(x)
# it is assumed x are row vectors
if self.lastshape != curshape:
self.initwithsize(curshape, dim)
# BOUNDARY HANDLING
xoutside = np.maximum(0, np.abs(x) - 5.) * sign(x)
fpen = 1e4 * np.sum(xoutside ** 2, -1)
fadd = fadd + fpen
# TRANSFORMATION IN SEARCH SPACE
x = self.arrscales * x
# COMPUTATION core
s = 1 - .5 / ((dim + 20)**0.5 - 4.1) # tested up to DIM = 160 p in [0.25,0.33]
d = 1 # shift [1,3], smaller is more difficult
mu2 = -((self._mu1 ** 2 - d) / s) ** .5
ftrue = np.minimum(np.sum((x - self._mu1) ** 2, -1),
d * dim + s * np.sum((x - mu2) ** 2, -1))
ftrue = ftrue + 10 * (dim - np.sum(np.cos(2 * np.pi * dot(x - self._mu1, self.linearTF)), -1))
fval = self.noise(ftrue)
# FINALIZE
ftrue += fadd
fval += fadd
return fval, ftrue
# dictbbob = {'sphere': F1, 'ellipsoid': F2, 'Rastrigin': F3}
评论列表
文章目录