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 = (10. / dim) * np.sum(xoutside ** 2, -1)
fadd = fadd + fpen
# TRANSFORMATION IN SEARCH SPACE
x = x - self.arrxopt # cannot be replaced with x -= arrxopt!
x = dot(x, self.rotation)
x = monotoneTFosc(x)
x = dot(x, self.linearTF)
# COMPUTATION core
if len(curshape) < 2: # popsize is one
ftrue = np.sum(dot(self.aK, np.cos(dot(self.bK.T, 2 * np.pi * (np.reshape(x, (1, len(x))) + 0.5)))))
else:
ftrue = np.zeros(curshape[0]) # curshape[0] is popsize
for k, i in enumerate(x):
# TODO: simplify next line
ftrue[k] = np.sum(dot(self.aK, np.cos(dot(self.bK.T, 2 * np.pi * (np.reshape(i, (1, len(i))) + 0.5)))))
ftrue = 10. * (ftrue / dim - self.f0) ** 3
try:
ftrue = np.hstack(ftrue)
except TypeError:
pass
fval = self.noise(ftrue)
# FINALIZE
ftrue += fadd
fval += fadd
return fval, ftrue
评论列表
文章目录