def update(self, es, function_values, **kwargs):
"""the first and second value in ``function_values``
must reflect two mirrored solutions sampled
in direction / in opposite direction of
the previous mean shift, respectively.
"""
# TODO: on the linear function, the two mirrored samples lead
# to a sharp increase of condition of the covariance matrix.
# They should not be used to update the covariance matrix,
# if the step-size inreases quickly. This should be fine with
# negative updates though.
if not self.initialized:
self.initialize(es.N, es.opts)
if 1 < 3:
# use the ranking difference of the mirrors for adaptation
# damp = 5 should be fine
z = np.where(es.fit.idx == 1)[0][0] - np.where(es.fit.idx == 0)[0][0]
z /= es.popsize - 1 # z in [-1, 1]
self.s = (1 - self.sp.c) * self.s + self.sp.c * np.sign(z) * np.abs(z)**self.sp.z_exponent
if self.s > 0:
es.sigma *= exp(self.s / self.sp.dampup)
else:
es.sigma *= exp(self.s / self.sp.dampdown)
#es.more_to_write.append(10**z)
评论列表
文章目录