Beispiel #1
0
    def set_parameters(self,
                       n=25,
                       c1=2.0,
                       c2=2.0,
                       w=0.7,
                       min_velocity=-1.5,
                       max_velocity=1.5,
                       repair=reflect_repair,
                       **ukwargs):
        r"""Set Particle Swarm Algorithm main parameters.

		Args:
			n (int): Population size
			c1 (float): Cognitive component.
			c2 (float): Social component.
			w (Union[float, numpy.ndarray]): Inertial weight.
			min_velocity (Union[float, numpy.ndarray]): Minimal velocity.
			max_velocity (Union[float, numpy.ndarray]): Maximal velocity.
			repair (Callable[[np.ndarray, np.ndarray, np.ndarray, dict], np.ndarray]): Repair method for velocity.
			**ukwargs: Additional arguments

		See Also:
			* :func:`NiaPy.algorithms.Algorithm.setParameters`
		"""
        Algorithm.set_parameters(self, n=n, **ukwargs)
        self.C1, self.C2, self.w, self.vMin, self.vMax, self.Repair = c1, c2, w, min_velocity, max_velocity, repair
Beispiel #2
0
    def set_parameters(self,
                       n=25,
                       SI_init=3,
                       SI_final=10,
                       SV_init=3,
                       SV_final=13,
                       min_w=0.3,
                       w_scale=0.7,
                       **ukwargs):
        r"""Set core arguments of FishSchoolSearch algorithm.

		Arguments:
			n (Optional[int]): Number of fishes in school.
			SI_init (Optional[int]): Length of initial individual step.
			SI_final (Optional[int]): Length of final individual step.
			SV_init (Optional[int]): Length of initial volatile step.
			SV_final (Optional[int]): Length of final volatile step.
			min_w (Optional[float]): Minimum weight of a fish.
			w_scale (Optional[float]): Maximum weight of a fish.

		See Also:
			* :func:`WeOptPy.algorithms.Algorithm.setParameters`
		"""
        Algorithm.set_parameters(self, n=n, **ukwargs)
        self.step_individual_init = SI_init
        self.step_individual_final = SI_final
        self.step_volitive_init = SV_init
        self.step_volitive_final = SV_final
        self.min_w = min_w
        self.w_scale = w_scale
Beispiel #3
0
    def set_parameters(self,
                       n=50,
                       N_max=0.01,
                       V_f=0.02,
                       D_max=0.002,
                       C_t=0.93,
                       W_n=0.42,
                       W_f=0.38,
                       d_s=2.63,
                       nn=5,
                       Cr=0.2,
                       Mu=0.05,
                       epsilon=1e-31,
                       **ukwargs):
        r"""Set the arguments of an algorithm.

		Arguments:
			n (Optional[int]): Number of krill herds in population.
			N_max (Optional[float]): Maximum induced speed.
			V_f (Optional[float]): Foraging speed.
			D_max (Optional[float]): Maximum diffusion speed.
			C_t (Optional[float]): Constant $\in [0, 2]$.
			W_n (Optional[Union[int, float, numpy.ndarray]]): Intera weights of the motion induced from neighbors :math:`\in [0, 1]`.
			W_f (Optional[Union[int, float, numpy.ndarray]]): Intera weights of the motion induced from foraging :math:`\in [0, 1]`.
			d_s (Optional[float]): Maximum euclidean distance for neighbors.
			nn (Optional[int]): Maximum neighbors for neighbors effect.
			Cr (Optional[float]): Crossover probability.
			Mu (Optional[float]): Mutation probability.
			epsilon (Optional[float]): Small numbers for division.

		See Also:
			* :func:`NiaPy.algorithms.algorithm.Algorithm.setParameters`
		"""
        Algorithm.set_parameters(self, n=n, **ukwargs)
        self.N_max, self.V_f, self.D_max, self.C_t, self.W_n, self.W_f, self.d_s, self.nn, self._Cr, self._Mu, self.epsilon = N_max, V_f, D_max, C_t, W_n, W_f, d_s, nn, Cr, Mu, epsilon
Beispiel #4
0
    def set_parameters(self,
                       n=30,
                       MR=0.1,
                       C1=2.05,
                       SMP=3,
                       SPC=True,
                       CDC=0.85,
                       SRD=0.2,
                       vMax=1.9,
                       **ukwargs):
        r"""Set the algorithm parameters.

		Arguments:
			n (int): Number of individuals in population
			MR (float): Mixture ratio
			C1 (float): Constant in tracing mode
			SMP (int): Seeking memory pool
			SPC (bool): Self-position considering
			CDC (float): Decides how many dimensions will be varied
			SRD (float): Seeking range of the selected dimension
			vMax (float): Maximal velocity

			See Also:
				* :func:`WeOptPy.algorithms.Algorithm.setParameters`
		"""
        Algorithm.set_parameters(self, n=n, **ukwargs)
        self.MR, self.C1, self.SMP, self.SPC, self.CDC, self.SRD, self.vMax = MR, C1, SMP, SPC, CDC, SRD, vMax
Beispiel #5
0
    def set_parameters(self, n=25, **ukwargs):
        r"""Set the algorithm parameters.

		Arguments:
			n (int): Number of individuals in population

		See Also:
			* :func:`NiaPy.algorithms.algorithm.Algorithm.setParameters`
		"""
        Algorithm.set_parameters(self, n=n, **ukwargs)
Beispiel #6
0
    def set_parameters(self, n=10, C_a=1.5, C_r=0.5, **ukwargs):
        r"""Set the arguments of an algorithm.

		Arguments:
			n (int): Number of sparks :math:`\in [1, \infty)`.
			C_a (float): Amplification coefficient :math:`\in [1, \infty)`.
			C_r (float): Reduction coefficient :math:`\in (0, 1)`.
		"""
        ukwargs.pop('n', None)
        Algorithm.set_parameters(self, n=1, **ukwargs)
        self.n, self.C_a, self.C_r = n, C_a, C_r
Beispiel #7
0
    def set_parameters(self, n=40, G_0=2.467, epsilon=1e-17, **ukwargs):
        r"""Set the algorithm parameters.

        Arguments:
            G_0 (float): Starting gravitational constant.
            epsilon (float): TODO.

        See Also:
            * :func:`NiaPy.algorithms.algorithm.Algorithm.setParameters`
        """
        Algorithm.set_parameters(self, n=n, **ukwargs)
        self.G_0, self.epsilon = G_0, epsilon
Beispiel #8
0
	def set_parameters(self, n=20, PAR=5.0 / 12.0, PER=1.2, **ukwargs):
		r"""Set the parameters of the algorithm.

		Args:
			n (Optional[int]): Population size.
			PAR (Optional[int]): Partition.
			PER (Optional[int]): Period.
			ukwargs (Dict[str, Any]): Additional arguments.

		See Also:
			* :func:`NiaPy.algorithms.Algorithm.setParameters`
		"""
		Algorithm.set_parameters(self, n=n, **ukwargs)
		self.NP, self.PAR, self.PER, self.keep, self.BAR, self.NP1 = n, PAR, PER, 2, PAR, int(np.ceil(PAR * n))
		self.NP2 = int(n - self.NP1)
Beispiel #9
0
	def set_parameters(self, n=50, omega=0.25, mu=0.5, alpha=0.5, S_init=10, E_init=10, T_min=-10, T_max=10, **ukwargs):
		r"""Set the arguments of an algorithm.

		Arguments:
			n (Optional[int]): Population size :math:`\in [1, \infty)`.
			T_min (Optional[float]): Minimum temperature, must be true :math:`$T_{min} < T_{max}`.
			T_max (Optional[float]): Maximum temperature, must be true :math:`T_{min} < T_{max}`.
			omega (Optional[float]): Burden factor :math:`\in [0, 1]`.
			mu (Optional[float]): Dying rate :math:`\in [0, 1]`.
			S_init (Optional[float]): Initial supply :math:`\in (0, \infty)`.
			E_init (Optional[float]): Initial endurance :math:`\in (0, \infty)`.

		See Also:
			* :func:`WeOptPy.algorithms.Algorithm.setParameters`
		"""
		Algorithm.set_parameters(self, n=n, itype=Camel, init_pop_func=ukwargs.pop('init_pop_func', self.init_pop), **ukwargs)
		self.omega, self.mu, self.alpha, self.S_init, self.E_init, self.T_min, self.T_max = omega, mu, alpha, S_init, E_init, T_min, T_max
Beispiel #10
0
	def set_parameters(self, n=10, lt=3, al=10, lsc=1, gsc=1, tr=0.3, **ukwargs):
		r"""Set the parameters of the algorithm.

		Args:
			n (Optional[int]): Population size.
			lt (Optional[int]): Life time parameter.
			al (Optional[int]): Area limit parameter.
			lsc (Optional[int]): Local seeding changes parameter.
			gsc (Optional[int]): Global seeding changes parameter.
			tr (Optional[float]): Transfer rate parameter.
			ukwargs (Dict[str, Any]): Additional arguments.

		See Also:
			* :func:`WeOptPy.algorithms.Algorithm.setParameters`
		"""
		Algorithm.set_parameters(self, n=n, **ukwargs)
		self.lt, self.al, self.lsc, self.gsc, self.tr = lt, al, lsc, gsc, tr
Beispiel #11
0
	def set_parameters(self, n=25, l0=5, nt=5, rho=0.4, gamma=0.6, beta=0.08, s=0.03, Distance=euclidean, **ukwargs):
		r"""Set the arguments of an algorithm.

		Arguments:
			n (Optional[int]): Number of glowworms in population.
			l0 (Optional[float]): Initial luciferin quantity for each glowworm.
			nt (Optional[float]): --
			rs (Optional]float]): Maximum sensing range.
			rho (Optional[float]): Luciferin decay constant.
			gamma (Optional[float]): Luciferin enhancement constant.
			beta (Optional[float]): --
			s (Optional[float]): --
			Distance (Optional[Callable[[numpy.ndarray, numpy.ndarray], float]]]): Measure distance between two individuals.
		"""
		ukwargs.pop('n', None)
		Algorithm.set_parameters(self, n=n, **ukwargs)
		self.l0, self.nt, self.rho, self.gamma, self.beta, self.s, self.Distance = l0, nt, rho, gamma, beta, s, Distance
Beispiel #12
0
    def set_parameters(self,
                       n=25,
                       ts=5,
                       mr=0.25,
                       cr=0.25,
                       selection=tournament_selection,
                       crossover=uniform_crossover,
                       mutation=uniform_mutation,
                       **ukwargs):
        r"""Set the parameters of the algorithm.

		Arguments:
			n (Optional[int]): Population size.
			ts (Optional[int]): Tournament selection.
			mr (Optional[int]): Mutation rate.
			cr (Optional[float]): Crossover rate.
			selection (Optional[Callable[[numpy.ndarray[Individual], int, int, Individual, mtrand.RandomState], Individual]]): Selection operator.
			crossover (Optional[Callable[[numpy.ndarray[Individual], int, float, mtrand.RandomState], Individual]]): Crossover operator.
			mutation (Optional[Callable[[numpy.ndarray[Individual], int, float, Task, mtrand.RandomState], Individual]]): Mutation operator.

		See Also:
			* :func:`WeOptPy.algorithms.Algorithm.setParameters`
			* Selection:
				* :func:`WeOptPy.algorithms.TournamentSelection`
				* :func:`WeOptPy.algorithms.RouletteSelection`
			* Crossover:
				* :func:`WeOptPy.algorithms.UniformCrossover`
				* :func:`WeOptPy.algorithms.TwoPointCrossover`
				* :func:`WeOptPy.algorithms.MultiPointCrossover`
				* :func:`WeOptPy.algorithms.CrossoverUros`
			* Mutations:
				* :func:`WeOptPy.algorithms.UniformMutation`
				* :func:`WeOptPy.algorithms.CreepMutation`
				* :func:`WeOptPy.algorithms.MutationUros`
		"""
        Algorithm.set_parameters(self,
                                 n=n,
                                 itype=ukwargs.pop('itype', Individual),
                                 init_pop_func=ukwargs.pop(
                                     'init_pop_func', default_individual_init),
                                 **ukwargs)
        self.Ts, self.Mr, self.Cr = ts, mr, cr
        self.Selection, self.Crossover, self.Mutation = selection, crossover, mutation
Beispiel #13
0
    def set_parameters(self,
                       HMS=30,
                       r_accept=0.7,
                       r_pa=0.35,
                       b_range=1.42,
                       **ukwargs):
        r"""Set the arguments of the algorithm.

		Arguments:
			HMS (Optional[int]): Number of harmony in the memory
			r_accept (Optional[float]): Probability of accepting new bandwidth to harmony.
			r_pa (Optional[float]): Probability of accepting random bandwidth into harmony.
			b_range (Optional[float]): Bandwidth range.

		See Also:
			* :func:`WeOptPy.algorithms.Algorithm.setParameters`
		"""
        ukwargs.pop('n', None)
        Algorithm.set_parameters(self, n=HMS, **ukwargs)
        self.r_accept, self.r_pa, self.b_range = r_accept, r_pa, b_range
Beispiel #14
0
    def set_parameters(self,
                       N=40,
                       m=40,
                       a=1,
                       b=2,
                       A=40,
                       epsilon=1e-31,
                       **ukwargs):
        r"""Set the arguments of an algorithm.

		Arguments:
			N (int): Number of Fireworks
			m (int): Number of sparks
			a (int): Limitation of sparks
			b (int): Limitation of sparks
			A (float): TODO.
			epsilon (float): Small number for non 0 devision
		"""
        ukwargs.pop('n', None)
        Algorithm.set_parameters(self, n=N, **ukwargs)
        self.m, self.a, self.b, self.A, self.epsilon = m, a, b, A, epsilon
Beispiel #15
0
    def set_parameters(self, n=40, f=0.7, r=0.3, c=3, fc=0.5, **ukwargs):
        r"""Set Monkey King Evolution v1 algorithms static parameters.

		Args:
			n (int): Population size.
			f (float): Scale factor for normal particle.
			r (float): Percentage value of now many new particle Monkey King particle creates. Value in rage [0, 1].
			c (int): Number of new particles generated by Monkey King particle.
			fc (float): Scale factor for Monkey King particles.
			ukwargs (Dict[str, Any]): Additional arguments.

		See Also:
			* :func:`NiaPy.algorithms.algorithm.Algorithm.setParameters`
		"""
        Algorithm.set_parameters(self,
                                 n=n,
                                 itype=ukwargs.pop('itype', MkeSolution),
                                 init_pop_func=ukwargs.pop(
                                     'init_pop_func', default_individual_init),
                                 **ukwargs)
        self.F, self.R, self.C, self.FC = f, r, c, fc
Beispiel #16
0
    def set_parameters(self,
                       N=25,
                       phi=0.4,
                       Fa=0.5,
                       Fb=0.5,
                       Fd=0.3,
                       k=25,
                       P_Cr=0.5,
                       P_F=0.36,
                       SexualCrossover=sexual_crossover_simple,
                       Brooding=brooding_simple,
                       Distance=euclidean,
                       **ukwargs):
        r"""Set the parameters of the algorithm.

		Arguments:
			N (int): population size for population initialization.
			phi (int): TODO.
			Fa (float): Value $\in [0, 1]$ for Asexual reproduction size.
			Fb (float): Value $\in [0, 1]$ for Brooding size.
			Fd (float): Value $\in [0, 1]$ for Depredation size.
			k (int): Trys for larvae setting.
			SexualCrossover (Callable[[numpy.ndarray, float, Task, mtrand.RandomState, Dict[str, Any]], Tuple[numpy.ndarray, numpy.ndarray]]): Crossover function.
			P_Cr (float): Crossover rate $\in [0, 1]$.
			Brooding (Callable[[numpy.ndarray, float, Task, mtrand.RandomState, dict], Tuple[numpy.ndarray, numpy.ndarray]]): Brooding function.
			P_F (float): Crossover rate $\in [0, 1]$.
			Distance (Callable[[numpy.ndarray, numpy.ndarray], float]): Funciton for calculating distance between corals.

		See Also:
			* :func:`WeOptPy.algorithms.Algorithm.setParameters`
		"""
        ukwargs.pop('n', None)
        Algorithm.set_parameters(self, n=N, **ukwargs)
        self.phi, self.k, self.P_Cr, self.P_F = phi, k, P_Cr, P_F
        self.Fa, self.Fb, self.Fd = int(self.NP * Fa), int(self.NP * Fb), int(
            self.NP * Fd)
        self.SexualCrossover, self.Brooding, self.Distance = SexualCrossover, Brooding, Distance