def __init__(self, cromossom=30 * np.random.random(30) - 15, sigma=np.random.random(), it_number=1): self.cromossom = cromossom self.sigma = sigma self.fitness = ackleyFunc(self.cromossom) self.threshold = 0.5 self.eps = 1e-12 self.it_number = it_number
def mutate_index(self, i): sigma = self.sigma[i] * np.exp(self.t * np.random.randn() + self.tl * np.random.randn()) sigma = np.maximum(sigma, self.threshold) cromossom = self.cromossom cromossom[i] = self.cromossom[i] + np.random.randn()*sigma if ackleyFunc(cromossom) <= self.fitness: self.cromossom[i] = cromossom[i] self.sigma[i] = sigma
def __init__(self, cromossom=30 * np.random.random(30) - 15, sigma=np.random.random(), improvement_count=0, it_number=1): self.cromossom = cromossom self.sigma = sigma self.fitness = ackleyFunc(self.cromossom) self.eps = 1e-12 self.improvement_count = improvement_count self.it_number = it_number self.sigma_parameter = 0.95
def __init__(self, cromossom=30 * np.random.random(30) - 15, sigma=np.random.random(30), it_number=1): self.cromossom = cromossom self.sigma = sigma self.fitness = ackleyFunc(self.cromossom) self.eps = 1e-12 self.it_number = it_number self.sigma_parameter = 0.95 self.t = 0.05 / np.sqrt(2 * 30) self.tl = 0.05 / np.sqrt(np.sqrt(2 * 30)) self.threshold = 1
def set_fitness(self): self.fitness = ackleyFunc(self.cromossom)