Пример #1
0
 def test_repair_fine(self):
     s = Individual(x=full(self.D, 100))
     self.assertFalse(self.task.isFeasible(s.x))
     s.repair(self.task)
     self.assertTrue(self.task.isFeasible(s.x))
Пример #2
0
 def test_eq_fine(self):
     self.assertFalse(self.s1 == self.s2)
     self.assertTrue(self.s1 == self.s1)
     s = Individual(x=self.s1.x)
     self.assertTrue(s == self.s1)
Пример #3
0
 def __init__(self, **kwargs):
     Individual.__init__(self, **kwargs)
     self.f_pb, self.x_pb = self.f, self.x
     self.MonkeyKing = False
Пример #4
0
Файл: jde.py Проект: tuahk/NiaPy
	def __init__(self, **kwargs):
		Individual.__init__(self, **kwargs)
		self.F, self.CR = kwargs.get('F', 2), kwargs.get('CR', 0.5)
Пример #5
0
 def setUp(self):
     self.D = 20
     self.x, self.task = rnd.uniform(-100, 100, self.D), StoppingTask(
         D=self.D, nFES=230, nGEN=inf, benchmark=MyBenchmark())
     self.s1, self.s2, self.s3 = Individual(x=self.x, e=False), Individual(
         task=self.task, rand=rnd), Individual(task=self.task)
Пример #6
0
	def __init__(self, **kwargs):
		task, x, rho = kwargs.get('task', None), kwargs.get('x', None), kwargs.get('rho', 1)
		if rho != None: self.rho = rho
		elif task != None or x != None: self.rho = 1.0
		Individual.__init__(self, **kwargs)
Пример #7
0
 def __init__(self, task, rand):
     Individual.__init__(self, task=task, e=False, rand=rand)
Пример #8
0
 def __init__(self, task):
     Individual.__init__(self, task=task, e=False)
Пример #9
0
	def runTask(self, task):
		pop = [Individual(task=task, rand=self.Rand) for _i in range(self.NP)]
		x_b = pop[argmin([c.f for c in pop])]
		while not task.stopCond(): pop, x_b = self.evolve(pop, x_b, task)
		return x_b.x, x_b.f
Пример #10
0
	def setUp(self):
		self.D = 20
		self.x, self.task = rnd.uniform(-100, 100, self.D), Task(self.D, 230, None, MyBenchmark())
		self.s1, self.s2, self.s3 = Individual(x=self.x), Individual(task=self.task, rand=rnd), Individual(task=self.task)
Пример #11
0
	def multiMutations(self, pop, i, x_b, task):
		L = [Individual(x=strategy(pop, i, x_b, self.F, self.CR, rnd=self.Rand), task=task, e=True, rand=self.Rand) for strategy in self.strategys]
		return L[argmin([x.f for x in L])]
Пример #12
0
	def __init__(self, **kwargs):
		Individual.__init__(self, **kwargs)
		self.age = 0
Пример #13
0
 def __init__(self, weight, **kwargs):
     Individual.__init__(self, **kwargs)
     self.weight = weight
     self.delta_pos = np.nan
     self.delta_cost = np.nan
     self.has_improved = False
Пример #14
0
 def __init__(self, SR, grade=0, enable=True, improved=False, **kwargs):
     Individual.__init__(self, **kwargs)
     self.SR, self.grade, self.enable, self.improved = SR, grade, enable, improved