def test_FA_iters_fine(self): task = StoppingTask(D=10, nGEN=1000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = FireflyAlgorithm(NP=25) algo.runTask(task) iters = task.iters() self.assertEqual(1000, iters)
def test_BA_iters_to_fes(self): task = StoppingTask(D=10, nGEN=1000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = BatAlgorithm(NP=10) algo.runTask(task) evals = task.evals() self.assertEqual(10000, evals)
def test_FA_evals_fine(self): task = StoppingTask(D=10, nFES=1000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = FireflyAlgorithm(NP=25) algo.runTask(task) evals = task.evals() self.assertEqual(1000, evals)
def test_BA_iters_to_fes(self): task = Task(D=10, nGEN=1000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = BatAlgorithm(task=task, NP=10) algo.run() evals = algo.task.evals() self.assertEqual(evals, 10010)
def test_DE_iters_fine(self): task = StoppingTask(D=10, nGEN=1000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = DifferentialEvolution(NP=40, CR=0.9, F=0.5) algo.runTask(task) iters = task.iters() self.assertEqual(1000, iters)
def test_FA_evals_fine(self): task = Task(D=10, nFES=1000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = FireflyAlgorithm(task=task, NP=25) algo.run() evals = algo.task.evals() self.assertEqual(evals, 1000)
def test_FA_iters_fine(self): task = Task(D=10, nGEN=1000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = FireflyAlgorithm(task=task, NP=25) algo.run() iters = algo.task.iters() self.assertEqual(iters, 1000)
def test_DE_evals_fine(self): task = Task(D=10, nFES=1000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = DifferentialEvolution(task=task, NP=40, CR=0.9, F=0.5) algo.run() evals = algo.task.evals() self.assertEqual(evals, 1000)
def function(self): return Sphere(self.Lower, self.Upper).function()
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI from NiaPy.benchmarks import Sphere from NiaPy.task import StoppingTask from NiaPy.algorithms.basic import BeesAlgorithm import sys sys.path.append('../') # we will run Bees Algorithm for 5 independent runs for i in range(5): task = StoppingTask(D=20, nGEN=2, benchmark=Sphere()) algo = BeesAlgorithm(NP=50, m=20, e=10, nep=20, nsp=15, ngh=7) best = algo.run(task) print('%s -> %s' % (best[0], best[1]))
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI import sys sys.path.append('../') # End of fix import random from NiaPy.algorithms.basic import CoralReefsOptimization from NiaPy.util import StoppingTask, OptimizationType from NiaPy.benchmarks import Sphere #we will run Coral Reefs Optimization algorithm for 5 independent runs for i in range(5): task = StoppingTask(D=10, nFES=1000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = CoralReefsOptimization(NP=40) best = algo.run(task=task) print best
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI from NiaPy.algorithms.basic import CovarianceMatrixAdaptionEvolutionStrategy from NiaPy.benchmarks import Sphere from NiaPy.task import StoppingTask import sys sys.path.append('../') # End of fix # we will run CMA-ES for 5 independent runs for i in range(5): task = StoppingTask(D=10, nFES=1000, logger=True, benchmark=Sphere()) algo = CovarianceMatrixAdaptionEvolutionStrategy(NP=20) best = algo.run(task) print('%s -> %s' % (best[0], best[1]))
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI import sys sys.path.append('../') # End of fix from NiaPy.algorithms.modified import ParameterFreeBatAlgorithm from NiaPy.task import StoppingTask from NiaPy.benchmarks import Sphere algo = ParameterFreeBatAlgorithm() for i in range(10): task = StoppingTask(D=10, nFES=10000, benchmark=Sphere(Upper=5.12, Lower=-5.12)) best = algo.run(task) print('%s -> %s' % (best[0], best[1])) print(algo.getParameters())
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI import sys sys.path.append('../') # End of fix import random import logging from NiaPy.task import StoppingTask from NiaPy.algorithms.basic import DifferentialEvolution from NiaPy.benchmarks import Griewank, Sphere # 1 Number of function evaluations (nFES) as a stopping criteria for i in range(10): task = StoppingTask(D=10, nFES=10000, benchmark=Sphere()) algo = DifferentialEvolution(NP=40, CR=0.9, F=0.5) best = algo.run(task) print('%s -> %s' % (best[0], best[1])) print('---------------------------------------') # 2 Number of generations (iterations) as a stopping criteria for i in range(10): task = StoppingTask(D=10, nGEN=1000, benchmark=Sphere()) algo = DifferentialEvolution(NP=40, CR=0.9, F=0.5) best = algo.run(task) print('%s -> %s' % (best[0], best[1])) print('---------------------------------------')
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI import sys sys.path.append('../') # End of fix import random from NiaPy.algorithms.basic import ComprehensiveLearningParticleSwarmOptimizer from NiaPy.benchmarks import Sphere from NiaPy.task import StoppingTask # we will run ParticleSwarmAlgorithm for 5 independent runs algo = ComprehensiveLearningParticleSwarmOptimizer(NP=50, C1=.3, C2=1.0, m=5, w=0.86, vMin=-2, vMax=2) for i in range(5): task = StoppingTask(D=25, nFES=20000, benchmark=Sphere()) best = algo.run(task=task) print('%s -> %f' % (best[0], best[1])) print(algo.getParameters()) # vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI import sys sys.path.append('../') # End of fix from NiaPy.algorithms.basic import KrillHerdV2 from NiaPy.task import StoppingTask from NiaPy.benchmarks import Sphere # we will run Fireworks Algorithm for 5 independent runs for i in range(5): task = StoppingTask(D=10, nGEN=50, benchmark=Sphere()) algo = KrillHerdV2(NP=70, Ainit=0.1, Afinal=0.9) best = algo.run(task) print('%s -> %s' % (best[0], best[1])) # vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI import sys sys.path.append('../') # End of fix import random from NiaPy.algorithms.basic import AgingNpMultiMutationDifferentialEvolution from NiaPy.algorithms.basic.de import CrossCurr2Best1, CrossBest2 from NiaPy.task import StoppingTask from NiaPy.benchmarks import Sphere # we will run Differential Evolution for 5 independent runs for i in range(5): task = StoppingTask(D=10, nFES=5000, benchmark=Sphere()) algo = AgingNpMultiMutationDifferentialEvolution(NP=10, F=0.2, CR=0.65, strategies=(CrossCurr2Best1, CrossBest2), delta_np=0.05, omega=0.9) best = algo.run(task) print('%s -> %s' % (best[0], best[1])) # vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Ackley, Griewank, Sphere, HappyCat ) """Example demonstrating the use of NiaPy Runner.""" runner = Runner( D=40, nFES=100, nRuns=2, useAlgorithms=[ GreyWolfOptimizer(), "FlowerPollinationAlgorithm", ParticleSwarmAlgorithm(), "HybridBatAlgorithm", "SimulatedAnnealing", "CuckooSearch"], useBenchmarks=[ Ackley(), Griewank(), Sphere(), HappyCat(), "rastrigin"] ) print(runner.run(verbose=True))
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI import sys sys.path.append('../') # End of fix from NiaPy.algorithms.basic import GravitationalSearchAlgorithm from NiaPy.util import StoppingTask, OptimizationType from NiaPy.benchmarks import Sphere # we will run Gravitational Search Algorithm for 5 independent runs for i in range(5): task = StoppingTask(D=10, nFES=10000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = GravitationalSearchAlgorithm(NP=40) best = algo.run(task=task) print(best)
# encoding=utf8 # This is temporary fix to import module from parent folder # It will be removed when package is published on PyPI import sys sys.path.append('../') # End of fix from NiaPy.task import StoppingTask from NiaPy.benchmarks import Sphere from NiaPy.algorithms.other import RandomSearch for i in range(1): task = StoppingTask(D=5, nGEN=5000, benchmark=Sphere()) algo = RandomSearch() best = algo.run(task=task) print(best)