Skip to content

Commit

Permalink
Merge pull request #1 from lucijabrezocnik/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
lucijabrezocnik committed Jul 19, 2020
2 parents ff5cabf + 681154f commit 002d284
Show file tree
Hide file tree
Showing 36 changed files with 488 additions and 86 deletions.
12 changes: 12 additions & 0 deletions NiaPy/algorithms/basic/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ class ArtificialBeeColonyAlgorithm(Algorithm):
"""
Name = ['ArtificialBeeColonyAlgorithm', 'ABC']

@staticmethod
def algorithmInfo():
r"""Get algorithms information.
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""Karaboga, D., and Bahriye B. "A powerful and efficient algorithm for numerical function optimization: artificial bee colony (ABC) algorithm." Journal of global optimization 39.3 (2007): 459-471."""

@staticmethod
def typeParameters():
r"""Return functions for checking values of parameters.
Expand Down
5 changes: 4 additions & 1 deletion NiaPy/algorithms/basic/ba.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ def algorithmInfo():
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r'''Yang, Xin-She. "A new metaheuristic bat-inspired algorithm." Nature inspired cooperative strategies for optimization (NICSO 2010). Springer, Berlin, Heidelberg, 2010. 65-74.'''
return r"""Yang, Xin-She. "A new metaheuristic bat-inspired algorithm." Nature inspired cooperative strategies for optimization (NICSO 2010). Springer, Berlin, Heidelberg, 2010. 65-74."""

@staticmethod
def typeParameters():
Expand Down
21 changes: 12 additions & 9 deletions NiaPy/algorithms/basic/bea.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ class BeesAlgorithm(Algorithm):

@staticmethod
def algorithmInfo():
return r"""
Description: A new population-based search algorithm called the Bees Algorithm (BA) is presented. The algorithm mimics the food foraging behaviour of swarms of honey bees.
Authors: D.T. Pham, A. Ghanbarzadeh, E. Koç, S. Otri, S. Rahim, M. Zaidi
Year: 2006
Main reference: DT Pham, A Ghanbarzadeh, E Koc, S Otri, S Rahim, and M Zaidi. The bees algorithm-a novel tool for complex optimisation problems. In Proceedings of the 2nd Virtual International Conference on Intelligent Production Machines and Systems (IPROMS 2006), pages 454–459, 2006
"""
r"""Get information about algorithm.
Returns:
str: Algorithm information
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""DT Pham, A Ghanbarzadeh, E Koc, S Otri, S Rahim, and M Zaidi. The bees algorithm-a novel tool for complex optimisation problems. In Proceedings of the 2nd Virtual International Conference on Intelligent Production Machines and Systems (IPROMS 2006), pages 454–459, 2006"""

@staticmethod
def typeParameters():
Expand Down Expand Up @@ -118,7 +121,7 @@ def beeDance(self, x, task, ngh):
Args:
x (numpy.ndarray): One instance from the population.
task (Task): Optimization task
task (Task): Optimization task.
ngh (float): A small value for patch search.
Returns:
Expand Down Expand Up @@ -191,8 +194,8 @@ def runIteration(self, task, BeesPosition, BeesCost, xb, fxb, ngh, **dparams):
Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, float, Dict[str, Any]]:
1. New population.
2. New population fitness/function values.
3. New global best solution
4. New global best fitness/objective value
3. New global best solution.
4. New global best fitness/objective value.
5. Additional arguments:
* ngh (float): A small value used for patches.
"""
Expand Down
3 changes: 3 additions & 0 deletions NiaPy/algorithms/basic/ca.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ def algorithmInfo():
Returns:
str: Algorithm information
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r'''Ali, Ramzy. (2016). Novel Optimization Algorithm Inspired by Camel Traveling Behavior. Iraq J. Electrical and Electronic Engineering. 12. 167-177.'''

Expand Down
12 changes: 12 additions & 0 deletions NiaPy/algorithms/basic/cro.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ class CoralReefsOptimization(Algorithm):
"""
Name = ['CoralReefsOptimization', 'CRO']

@staticmethod
def algorithmInfo():
r"""Get algorithms information.
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""S. Salcedo-Sanz, J. Del Ser, I. Landa-Torres, S. Gil-López, and J. A. Portilla-Figueras, “The Coral Reefs Optimization Algorithm: A Novel Metaheuristic for Efficiently Solving Optimization Problems,” The Scientific World Journal, vol. 2014, Article ID 739768, 15 pages, 2014."""

@staticmethod
def typeParameters():
r"""Get dictionary with functions for checking values of parameters.
Expand Down
3 changes: 3 additions & 0 deletions NiaPy/algorithms/basic/cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def algorithmInfo():
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""Yang, Xin-She, and Suash Deb. "Cuckoo search via Lévy flights." Nature & Biologically Inspired Computing, 2009. NaBIC 2009. World Congress on. IEEE, 2009."""

Expand Down
28 changes: 20 additions & 8 deletions NiaPy/algorithms/basic/cso.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ class CatSwarmOptimization(Algorithm):
"""
Name = ['CatSwarmOptimization', 'CSO']

@staticmethod
def algorithmInfo():
r"""Get algorithm information.
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""Chu, Shu-Chuan & Tsai, Pei-Wei & Pan, Jeng-Shyang. (2006). Cat Swarm Optimization. 854-858. 10.1007/11801603_94."""

@staticmethod
def typeParameters(): return {
'NP': lambda x: isinstance(x, int) and x > 0,
Expand All @@ -41,14 +53,14 @@ def setParameters(self, NP=30, MR=0.1, C1=2.05, SMP=3, SPC=True, CDC=0.85, SRD=0
r"""Set the algorithm parameters.
Arguments:
NP (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
NP (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:`NiaPy.algorithms.Algorithm.setParameters`
Expand Down
60 changes: 60 additions & 0 deletions NiaPy/algorithms/basic/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ class EvolutionStrategy1p1(Algorithm):
"""
Name = ['EvolutionStrategy1p1', 'EvolutionStrategy(1+1)', 'ES(1+1)']

@staticmethod
def algorithmInfo():
r"""Get algorithms information.
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""TODO"""

@staticmethod
def typeParameters():
r"""Get dictionary with functions for checking values of parameters.
Expand Down Expand Up @@ -198,6 +210,18 @@ class EvolutionStrategyMp1(EvolutionStrategy1p1):
"""
Name = ['EvolutionStrategyMp1', 'EvolutionStrategy(mu+1)', 'ES(m+1)']

@staticmethod
def algorithmInfo():
r"""Get algorithms information.
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""TODO"""

def setParameters(self, **kwargs):
r"""Set core parameters of EvolutionStrategy(mu+1) algorithm.
Expand Down Expand Up @@ -238,6 +262,18 @@ class EvolutionStrategyMpL(EvolutionStrategy1p1):
"""
Name = ['EvolutionStrategyMpL', 'EvolutionStrategy(mu+lambda)', 'ES(m+l)']

@staticmethod
def algorithmInfo():
r"""Get algorithms information.
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""TODO"""

@staticmethod
def typeParameters():
r"""TODO.
Expand Down Expand Up @@ -383,6 +419,18 @@ class EvolutionStrategyML(EvolutionStrategyMpL):
"""
Name = ['EvolutionStrategyML', 'EvolutionStrategy(mu,lambda)', 'ES(m,l)']

@staticmethod
def algorithmInfo():
r"""Get algorithms information.
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""TODO"""

def newPop(self, pop):
r"""Return new population.
Expand Down Expand Up @@ -507,6 +555,18 @@ class CovarianceMatrixAdaptionEvolutionStrategy(Algorithm):
Name = ['CovarianceMatrixAdaptionEvolutionStrategy', 'CMA-ES', 'CMAES']
epsilon = 1e-20

@staticmethod
def algorithmInfo():
r"""Get algorithms information.
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""TODO"""

@staticmethod
def typeParameters(): return {
'epsilon': lambda x: isinstance(x, (float, int)) and 0 < x < 1
Expand Down
17 changes: 10 additions & 7 deletions NiaPy/algorithms/basic/fa.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ class FireflyAlgorithm(Algorithm):

@staticmethod
def algorithmInfo():
return r"""
Description: Firefly algorithm is inspired by the flashing behavior of fireflies.
Author: Xin-She Yang
Year: 2008
Main reference: Yang, Xin-She. Nature-Inspired Metaheuristic Algorithms, Luniver Press, 2008.
"""
r"""Get algorithms information.
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""Fister, I., Fister Jr, I., Yang, X. S., & Brest, J. (2013). A comprehensive review of firefly algorithms. Swarm and Evolutionary Computation, 13, 34-46."""

@staticmethod
def typeParameters():
Expand Down Expand Up @@ -94,7 +97,7 @@ def alpha_new(self, a, alpha):
alpha (float):
Returns:
float: New value of parameter alpha
float: New value of parameter alpha.
"""
delta = 1.0 - pow(pow(10.0, -4.0) / 0.9, 1.0 / float(a))
return (1 - delta) * alpha
Expand Down
10 changes: 4 additions & 6 deletions NiaPy/algorithms/basic/foa.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ def algorithmInfo():
Returns:
str: Algorithm information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""
Description: Forest Optimization Algorithm is inspired by few trees in the forests which can survive for several decades, while other trees could live for a limited period.
Authors: Manizheh Ghaemi, Mohammad-Reza Feizi-Derakhshi
Year: 2014
Main reference: Manizheh Ghaemi, Mohammad-Reza Feizi-Derakhshi, Forest Optimization Algorithm, Expert Systems with Applications, Volume 41, Issue 15, 2014, Pages 6676-6687, ISSN 0957-4174, https://doi.org/10.1016/j.eswa.2014.05.009.
"""
return r"""Manizheh Ghaemi, Mohammad-Reza Feizi-Derakhshi, Forest Optimization Algorithm, Expert Systems with Applications, Volume 41, Issue 15, 2014, Pages 6676-6687, ISSN 0957-4174, https://doi.org/10.1016/j.eswa.2014.05.009."""

@staticmethod
def typeParameters():
Expand Down
16 changes: 14 additions & 2 deletions NiaPy/algorithms/basic/fpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ class FlowerPollinationAlgorithm(Algorithm):
"""
Name = ['FlowerPollinationAlgorithm', 'FPA']

@staticmethod
def algorithmInfo():
r"""Get default information of algorithm.
Returns:
str: Basic information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""Yang, Xin-She. "Flower pollination algorithm for global optimization. International conference on unconventional computing and natural computation. Springer, Berlin, Heidelberg, 2012."""

@staticmethod
def typeParameters():
r"""TODO.
Expand Down Expand Up @@ -122,8 +134,8 @@ def runIteration(self, task, Sol, Sol_f, xb, fxb, S, **dparams):
Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, float, Dict[str, Any]]:
1. New population.
2. New populations fitness/function values.
3. New global best solution
4. New global best solution fitness/objective value
3. New global best solution.
4. New global best solution fitness/objective value.
5. Additional arguments.
"""
for i in range(self.NP):
Expand Down
12 changes: 12 additions & 0 deletions NiaPy/algorithms/basic/fss.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ class FishSchoolSearch(Algorithm):
"""
Name = ['FSS', 'FishSchoolSearch']

@staticmethod
def algorithmInfo():
r"""Get default information of algorithm.
Returns:
str: Basic information.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""Bastos Filho, Lima Neto, Lins, D. O. Nascimento and P. Lima, “A novel search algorithm based on fish school behavior,” in 2008 IEEE International Conference on Systems, Man and Cybernetics, Oct 2008, pp. 2646–2651."""

@staticmethod
def typeParameters():
# TODO
Expand Down
6 changes: 3 additions & 3 deletions NiaPy/algorithms/basic/fwa.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__all__ = ['FireworksAlgorithm', 'EnhancedFireworksAlgorithm', 'DynamicFireworksAlgorithm', 'DynamicFireworksAlgorithmGauss', 'BareBonesFireworksAlgorithm']

class BareBonesFireworksAlgorithm(Algorithm):
r"""Implementation of bare bone fireworks algorithm.
r"""Implementation of Bare Bones Fireworks Algorithm.
Algorithm:
Bare Bones Fireworks Algorithm
Expand Down Expand Up @@ -134,7 +134,7 @@ class FireworksAlgorithm(Algorithm):
https://www.springer.com/gp/book/9783662463529
Reference paper:
Tan, Ying. "Firework Algorithm: A Novel Swarm Intelligence Optimization Method." (2015).
Tan, Ying. "Fireworks algorithm." Heidelberg, Germany: Springer 10 (2015): 978-3
Attributes:
Name (List[str]): List of stirngs representing algorithm names.
Expand All @@ -151,7 +151,7 @@ def algorithmInfo():
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""Tan, Ying. "Firework Algorithm: A Novel Swarm Intelligence Optimization Method." (2015)."""
return r"""Tan, Ying. "Fireworks algorithm." Heidelberg, Germany: Springer 10 (2015): 978-3."""

@staticmethod
def typeParameters(): return {
Expand Down
5 changes: 4 additions & 1 deletion NiaPy/algorithms/basic/ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def CreepMutation(pop, ic, mr, task, rnd=rand):
return asarray(nx)

class GeneticAlgorithm(Algorithm):
r"""Implementation of Genetic algorithm.
r"""Implementation of Genetic Algorithm.
Algorithm:
Genetic algorithm
Expand Down Expand Up @@ -201,6 +201,9 @@ def algorithmInfo():
Returns:
str: Basic information of algorithm.
See Also:
* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
"""
return r"""On info"""

Expand Down

0 comments on commit 002d284

Please sign in to comment.