Skip to content

Commit

Permalink
Merge pull request #161 from NiaOrg/fix-version-1
Browse files Browse the repository at this point in the history
fix Bat and Hybrid Bat algorithm
  • Loading branch information
GregaVrbancic authored Oct 24, 2018
2 parents 74736ab + 8a604eb commit 4f2e1e9
Show file tree
Hide file tree
Showing 50 changed files with 376 additions and 321 deletions.
2 changes: 1 addition & 1 deletion .pycodestyle.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# E501: line too long (checked by PyLint)
# E711: comparison to None (used to improve test style)
# E712: comparison to True (used to improve test style)
ignore = E401,E402,E501,E711,E712
ignore = E401,E402,E501,W504,E711,E712
4 changes: 3 additions & 1 deletion .pylint.ini
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ disable=print-statement,
similarities,
too-many-locals,
too-many-statements,
too-many-instance-attributes
too-many-instance-attributes,
old-style-class,
W504

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pydocstyle: install

PYTEST := pipenv run py.test
COVERAGE := pipenv run coverage
COVERAGE_SPACE := pipenv run coverage.space
COVERAGE_SPACE := pipenv run coveragespace

RANDOM_SEED ?= $(shell date +%s)
FAILURES := .cache/v/cache/lastfailed
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
logger.setLevel('INFO')


class Runner(object):
class Runner:
r"""Runner utility feature.
Feature which enables running multiple algorithms with multiple benchmarks.
Expand Down
4 changes: 2 additions & 2 deletions NiaPy/algorithms/basic/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['ArtificialBeeColonyAlgorithm']


class SolutionABC(object):
class SolutionABC:

def __init__(self, D, LB, UB):
self.D = D
Expand Down Expand Up @@ -34,7 +34,7 @@ def toString(self):
pass


class ArtificialBeeColonyAlgorithm(object):
class ArtificialBeeColonyAlgorithm:
r"""Implementation of Artificial Bee Colony algorithm.
**Algorithm:** Artificial Bee Colony algorithm
Expand Down
4 changes: 2 additions & 2 deletions NiaPy/algorithms/basic/ba.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = ['BatAlgorithm']


class BatAlgorithm(object):
class BatAlgorithm:
r"""Implementation of Bat algorithm.
**Algorithm:** Bat algorithm
Expand Down Expand Up @@ -126,7 +126,7 @@ def move_bat(self):
while self.eval_flag is not False:
for i in range(self.NP):
rnd = random.uniform(0, 1)
self.Q[i] = self.Qmin + (self.Qmin - self.Qmax) * rnd
self.Q[i] = self.Qmin + (self.Qmax - self.Qmin) * rnd
for j in range(self.D):
self.v[i][j] = self.v[i][j] + (self.Sol[i][j] -
self.best[j]) * self.Q[i]
Expand Down
4 changes: 2 additions & 2 deletions NiaPy/algorithms/basic/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['DifferentialEvolutionAlgorithm']


class SolutionDE(object):
class SolutionDE:

def __init__(self, D, LB, UB):
self.D = D
Expand Down Expand Up @@ -34,7 +34,7 @@ def __eq__(self, other):
return self.Solution == other.Solution and self.Fitness == other.Fitness


class DifferentialEvolutionAlgorithm(object):
class DifferentialEvolutionAlgorithm:
r"""Implementation of Differential evolution algorithm.
**Algorithm:** Differential evolution algorithm
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/algorithms/basic/fa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['FireflyAlgorithm']


class FireflyAlgorithm(object):
class FireflyAlgorithm:
r"""Implementation of Firefly algorithm.
**Algorithm:** Firefly algorithm
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/algorithms/basic/fpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__all__ = ['FlowerPollinationAlgorithm']


class FlowerPollinationAlgorithm(object):
class FlowerPollinationAlgorithm:
r"""Implementation of Flower Pollination algorithm.
**Algorithm:** Flower Pollination algorithm
Expand Down
4 changes: 2 additions & 2 deletions NiaPy/algorithms/basic/ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['GeneticAlgorithm']


class Chromosome(object):
class Chromosome:
def __init__(self, D, LB, UB):
self.D = D
self.LB = LB
Expand Down Expand Up @@ -36,7 +36,7 @@ def toString(self):
print([i for i in self.Solution])


class GeneticAlgorithm(object):
class GeneticAlgorithm:
r"""Implementation of Genetic algorithm.
**Algorithm:** Genetic algorithm
Expand Down
7 changes: 3 additions & 4 deletions NiaPy/algorithms/basic/gwo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = ['GreyWolfOptimizer']


class GreyWolfOptimizer(object):
class GreyWolfOptimizer:
r"""Implementation of Grey wolf optimizer.
**Algorithm:** Grey wolf optimizer
Expand Down Expand Up @@ -104,12 +104,11 @@ def move(self):
self.Alpha_score = Fit
self.Alpha_pos = self.Positions[i]

if ((Fit > self.Alpha_score) and (Fit < self.Beta_score)):
if self.Alpha_score < Fit < self.Beta_score:
self.Beta_score = Fit
self.Beta_pos = self.Positions[i]

if ((Fit > self.Alpha_score) and (Fit > self.Beta_score) and
(Fit < self.Delta_score)):
if self.Alpha_score < Fit and self.Beta_score < Fit < self.Delta_score:
self.Delta_score = Fit
self.Delta_pos = self.Positions[i]

Expand Down
2 changes: 1 addition & 1 deletion NiaPy/algorithms/basic/pso.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__all__ = ['ParticleSwarmAlgorithm']


class ParticleSwarmAlgorithm(object):
class ParticleSwarmAlgorithm:
r"""Implementation of Particle Swarm Optimization algorithm.
**Algorithm:** Particle Swarm Optimization algorithm
Expand Down
4 changes: 2 additions & 2 deletions NiaPy/algorithms/modified/hba.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__all__ = ['HybridBatAlgorithm']


class HybridBatAlgorithm(object):
class HybridBatAlgorithm:
r"""Implementation of Hybrid bat algorithm.
**Algorithm:** Hybrid bat algorithm
Expand Down Expand Up @@ -126,7 +126,7 @@ def move_bat(self):
while self.eval_flag is not False:
for i in range(self.NP):
rnd = random.uniform(0, 1)
self.Q[i] = self.Qmin + (self.Qmin - self.Qmax) * rnd
self.Q[i] = self.Qmin + (self.Qmax - self.Qmin) * rnd

j = None
for j in range(self.D):
Expand Down
4 changes: 2 additions & 2 deletions NiaPy/algorithms/modified/jde.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['SelfAdaptiveDifferentialEvolutionAlgorithm']


class SolutionjDE(object):
class SolutionjDE:

def __init__(self, D, LB, UB, F, CR):
self.D = D
Expand Down Expand Up @@ -39,7 +39,7 @@ def __eq__(self, other):
return self.Solution == other.Solution and self.Fitness == other.Fitness


class SelfAdaptiveDifferentialEvolutionAlgorithm(object):
class SelfAdaptiveDifferentialEvolutionAlgorithm:
r"""Implementation of Self-adaptive differential evolution algorithm.
**Algorithm:** Self-adaptive differential evolution algorithm
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/ackley.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Ackley']


class Ackley(object):
class Ackley:
r"""Implementation of Ackley function.
Date: 2018
Expand Down
4 changes: 2 additions & 2 deletions NiaPy/benchmarks/alpine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__all__ = ['Alpine1', 'Alpine2']


class Alpine1(object):
class Alpine1:
r"""Implementation of Alpine1 function.
Date: 2018
Expand Down Expand Up @@ -61,7 +61,7 @@ def evaluate(D, sol):
return evaluate


class Alpine2(object):
class Alpine2:
r"""Implementation of Alpine2 function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/chungReynolds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['ChungReynolds']


class ChungReynolds(object):
class ChungReynolds:
r"""Implementation of Chung Reynolds functions.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/csendes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Csendes']


class Csendes(object):
class Csendes:
r"""Implementation of Csendes function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/griewank.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Griewank']


class Griewank(object):
class Griewank:
r"""Implementation of Griewank function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/happyCat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['HappyCat']


class HappyCat(object):
class HappyCat:
r"""Implementation of Happy cat function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/pinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Pinter']


class Pinter(object):
class Pinter:
r"""Implementation of Pintér function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/qing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Qing']


class Qing(object):
class Qing:
r"""Implementation of Qing function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/quintic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Quintic']


class Quintic(object):
class Quintic:
r"""Implementation of Quintic function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/rastrigin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Rastrigin']


class Rastrigin(object):
class Rastrigin:
r"""Implementation of Rastrigin benchmark function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/ridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Ridge']


class Ridge(object):
class Ridge:
r"""Implementation of Ridge function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/rosenbrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Rosenbrock']


class Rosenbrock(object):
class Rosenbrock:
r"""Implementation of Rosenbrock benchmark function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/salomon.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['Salomon']


class Salomon(object):
class Salomon:
r"""Implementation of Salomon function.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/schumerSteiglitz.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ['SchumerSteiglitz']


class SchumerSteiglitz(object):
class SchumerSteiglitz:
r"""Implementation of Schumer Steiglitz function.
Date: 2018
Expand Down
6 changes: 3 additions & 3 deletions NiaPy/benchmarks/schwefel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__all__ = ['Schwefel', 'Schwefel221', 'Schwefel222']


class Schwefel(object):
class Schwefel:
r"""Implementation of Schewel function.
Date: 2018
Expand Down Expand Up @@ -58,7 +58,7 @@ def evaluate(D, sol):
return evaluate


class Schwefel221(object):
class Schwefel221:
r"""Schwefel 2.21 function implementation.
Date: 2018
Expand Down Expand Up @@ -112,7 +112,7 @@ def evaluate(D, sol):
return evaluate


class Schwefel222(object):
class Schwefel222:
r"""Schwefel 2.22 function implementation.
Date: 2018
Expand Down
2 changes: 1 addition & 1 deletion NiaPy/benchmarks/sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__all__ = ['Sphere']


class Sphere(object):
class Sphere:
r"""Implementation of Sphere functions.
Date: 2018
Expand Down
6 changes: 3 additions & 3 deletions NiaPy/benchmarks/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__all__ = ['Step', 'Step2', 'Step3']


class Step(object):
class Step:
r"""Implementation of Step function.
Date: 2018
Expand Down Expand Up @@ -64,7 +64,7 @@ def evaluate(D, sol):
return evaluate


class Step2(object):
class Step2:
r"""Step2 function implementation.
Date: 2018
Expand Down Expand Up @@ -119,7 +119,7 @@ def evaluate(D, sol):
return evaluate


class Step3(object):
class Step3:
r"""Step3 function implementation.
Date: 2018
Expand Down
Loading

0 comments on commit 4f2e1e9

Please sign in to comment.