def init_population(self, task): r"""Initialize starting population. Args: task (Task): Optimization task Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. Initialized population 2. Initialized population function/fitness values 3. Additional arguments: 4. Additional keyword arguments: * best_flames (numpy.ndarray): Best individuals * best_flame_fitness (numpy.ndarray): Best individuals fitness/function values * previous_population (numpy.ndarray): Previous population * previous_fitness (numpy.ndarray[float]): Previous population fitness/function values See Also: * :func:`NiaPy.algorithms.algorithm.Algorithm.initPopulation` """ moth_pos, moth_fitness, args, d = Algorithm.init_population(self, task) # Create best population indexes = np.argsort(moth_fitness) best_flames, best_flame_fitness = moth_pos[indexes], moth_fitness[ indexes] # Init previous population previous_population, previous_fitness = np.zeros( (self.NP, task.D)), np.zeros(self.NP) d.update({ 'best_flames': best_flames, 'best_flame_fitness': best_flame_fitness, 'previous_population': previous_population, 'previous_fitness': previous_fitness }) return moth_pos, moth_fitness, args, d
def init_population(self, task): r"""Initialize the first herd/population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. Initialized herd/population. 2. Initialized herd/populations function/fitness values. 3. Additional arguments. 4. Additional keyword arguments: * KHo (numpy.ndarray): TODO * KHo_f (float): TODO * N (numpy.ndarray): TODO * F (numpy.ndarray): TODO * Dt (numpy.ndarray): TODO See Also: * :func:`NiaPy.algorithms.Algorithm.initPopulation` """ KH, KH_f, args, kwargs = Algorithm.init_population(self, task) KHo, KHo_f = np.full([self.NP, task.D], task.optType.value * np.inf), np.full( self.NP, task.optType.value * np.inf) N, F, Dt = np.full(self.NP, .0), np.full(self.NP, .0), np.mean(task.range()) / 2 kwargs.update({'KHo': KHo, 'KHo_f': KHo_f, 'N': N, 'F': F, 'Dt': Dt}) return KH, KH_f, args, kwargs
def init_population(self, task): r"""Initialize population and dynamic arguments of the Particle Swarm Optimization algorithm. Args: task: Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. Initial population. 2. Initial population fitness/function values. 3. Additional arguments. 4. Additional keyword arguments: * popb (numpy.ndarray): particles best population. * fpopb (numpy.ndarray[float]): particles best positions function/fitness value. * w (numpy.ndarray): Inertial weight. * min_velocity (numpy.ndarray): Minimal velocity. * max_velocity (numpy.ndarray): Maximal velocity. * V (numpy.ndarray): Initial velocity of particle. See Also: * :func:`NiaPy.algorithms.Algorithm.initPopulation` """ pop, fpop, args, d = Algorithm.init_population(self, task) d.update(self.init(task)) d.update({'popb': pop.copy(), 'fpopb': fpop.copy()}) return pop, fpop, args, d
def init_population(self, task): r"""Initialize stating population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. Initialized population. 2. Initialized populations function/fitness values. 3. Additional arguments. 4. Additional keyword arguments: * W_n (numpy.ndarray): Weights neighborhood. * W_f (numpy.ndarray): Weights foraging. * N (numpy.ndarray): TODO * F (numpy.ndarray): TODO See Also: * :func:`NiaPy.algorithms.algorithm.Algorithm.initPopulation` """ KH, KH_f, args, kwargs = Algorithm.init_population(self, task) W_n, W_f = self.init_weights(task) N, F = np.full(self.NP, .0), np.full(self.NP, .0) kwargs.update({'W_n': W_n, 'W_f': W_f, 'N': N, 'F': F}) return KH, KH_f, args, kwargs
def init_population(self, task): r"""Initialize starting population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, float, list, dict]: 1. Initial solution. 2. Initial solution function/fitness value. 3. Additional arguments. 4. Additional keyword arguments: * a (numpy.ndarray): Starting amplitude or search range. """ x, x_fit, args, d = Algorithm.init_population(self, task) d.update({'a': task.bRange}) return x, x_fit, args, d
def init_population(self, task): r"""Initialize first population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. New harmony/population. 2. New population fitness/function values. 3. Additional parameters. 4. Additional keyword parameters. See Also: * :func:`WeOptPy.algorithms.Algorithm.initPopulation` """ return Algorithm.init_population(self, task)
def init_population(self, task): r"""Initialize population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. New population of Camels. 2. New population fitness/function values. 3. Additional arguments. 4. Additional keyword arguments. See Also: * :func:`WeOptPy.algorithms.Algorithm.initPopulation` """ caravan, fcaravan, args, kwargs = Algorithm.init_population(self, task) return caravan, fcaravan, args, kwargs
def init_population(self, task): r"""Initialize population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. Initialized population. 2. Initialized population function/fitness values. 3. Additional arguments. 4. Additional keyword arguments: * Ah (): TODO * Ab (): TODO """ FW, FW_f, args, _ = Algorithm.init_population(self, task) Ah, Ab = self.init_amplitude(task) return FW, FW_f, args, {'Ah': Ah, 'Ab': Ab}
def init_population(self, task): r"""Initialize staring population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, Dict[str, Any]]: 1. Initialized population. 2. Initialized populations fitness/function values. 3. Additional arguments: * v (numpy.ndarray): TODO See Also: * :func:`NiaPy.algorithms.algorithm.Algorithm.initPopulation` """ X, X_f, args, _ = Algorithm.init_population(self, task) v = np.full([self.NP, task.D], 0.0) return X, X_f, args, {'v': v}
def init_population(self, task): r"""Init population. Args: task (Task): Optimization task Returns: Tuple(numpy.ndarray[MkeSolution], numpy.ndarray, list, dict]: 1. Initialized solutions 2. Fitness/function values of solution 3. Additional arguments 4. Additional keyword arguments """ pop, fpop, args, kwargs = Algorithm.init_population(self, task) for i in self.Rand.choice(self.NP, int(self.R * len(pop)), replace=False): pop[i].MonkeyKing = True return pop, fpop, args, kwargs
def init_population(self, task): r"""Initialize the starting population. Args: task (Task): Optimization task Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. New population. 2. New population fitness/function values. 3. Additional arguments. 4. Additional keyword arguments: * age (numpy.ndarray): Age of trees. See Also: * :func:`WeOptPy.algorithms.Algorithm.initPopulation` """ Trees, Evaluations, args, _ = Algorithm.init_population(self, task) age = np.zeros(self.NP, dtype=np.int32) self.dx = np.absolute(task.Upper) / 5 return Trees, Evaluations, args, {'age': age}
def init_population(self, task): r"""Initialize population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray[float], list, dict]: 1. Initialized population of glowwarms. 2. Initialized populations function/fitness values. 3. Additional arguments. 4. Additional keyword arguments: * L (numpy.ndarray): TODO. * R (numpy.ndarray): TODO. * rs (numpy.ndarray): TODO. """ GS, GS_f, args, kwargs = Algorithm.init_population(self, task) rs = euclidean(np.full(task.D, 0), task.bRange) L, R = np.full(self.NP, self.l0), np.full(self.NP, rs) kwargs.update({'L': L, 'R': R, 'rs': rs}) return GS, GS_f, args, kwargs
def init_population(self, task): r"""Initialize starting population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. Initialized population. 2. Initialized populations function/fitness values. 3. Additional arguments. 4. Additional keyword arguments: * Ah (numpy.ndarray): Initialized amplitudes. See Also: * :func:`NiaPy.algorithms.algorithm.Algorithm.initPopulation` """ FW, FW_f, args, kwargs = Algorithm.init_population(self, task) Ah = self.init_amplitude(task) kwargs.update({'Ah': Ah}) return FW, FW_f, args, kwargs
def init_population(self, task): r"""Initialize population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray[float], Dict[str, Any]]: 1. Initialized population. 2. Initialized populations fitness/function values. 3. Additional arguments: 4. Additional keyword arguments: * Dictionary of modes (seek or trace) and velocities for each cat See Also: * :func:`WeOptPy.algorithms.Algorithm.initPopulation` """ pop, fpop, args, d = Algorithm.init_population(self, task) d['modes'] = self.random_seek_trace() d['velocities'] = self.uniform(-self.vMax, self.vMax, [len(pop), task.D]) return pop, fpop, args, d
def init_population(self, task): r"""Initialize the population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. Initialized population. 2. Initialized population function/fitness values. 3. Additional arguments. 4. Additional keyword arguments: * k (int): TODO. * c (int): TODO. See Also: * :func:`NiaPy.algorithms.algorithm.Algorithm.initPopulation` """ x, x_f, args, d = Algorithm.init_population(self, task) k, c = int(ceil(self.NP / task.D)), int(ceil(self.C * task.D)) d.update({'k': k, 'c': c}) return x, x_f, args, d
def init_population(self, task): r"""Initialize population. Args: task (Task): Optimization task. Returns: Tuple[numpy.ndarray, numpy.ndarray, list, dict]: 1. Initialized population. 2. Initialized populations fitness/function values. 3. Additional arguments: 4. Additional keyword arguments: * a (): TODO See Also: * :func:`NiaPy.algorithms.Algorithm.initPopulation` """ pop, fpop, args, d = Algorithm.init_population(self, task) si = np.argsort(fpop) A, A_f, B, B_f, D, D_f = np.copy(pop[si[0]]), fpop[si[0]], np.copy( pop[si[1]]), fpop[si[1]], np.copy(pop[si[2]]), fpop[si[2]] d.update({'A': A, 'A_f': A_f, 'B': B, 'B_f': B_f, 'D': D, 'D_f': D_f}) return pop, fpop, args, d