def test_griewank_works_fine(self): es_griewank = EvolutionStrategyMp1(mu=30, k=25, c_a=1.5, c_r=0.5, seed=self.seed) es_griewankc = EvolutionStrategyMp1(mu=30, k=25, c_a=1.5, c_r=0.5, seed=self.seed) AlgorithmTestCase.algorithm_run_test(self, es_griewank, es_griewankc)
def test_custom_works_fine(self): es_custom = EvolutionStrategyMp1(mu=45, k=50, c_a=1.1, c_r=0.5, seed=self.seed) es_customc = EvolutionStrategyMp1(mu=45, k=50, c_a=1.1, c_r=0.5, seed=self.seed) AlgorithmTestCase.algorithm_run_test(self, es_custom, es_customc, MyBenchmark())
def simple_example(runs=10): for i in range(runs): algo = EvolutionStrategyMp1(D=50, nFES=50000, seed=None, benchmark=MyBenchmark()) best = algo.run() logger.info('%s %s' % (best[0], best[1]))
def test_griewank_works_fine(self): es_griewank = EvolutionStrategyMp1(D=self.D, nFES=self.nFES, nGEN=self.nGEN, mu=30, k=25, c_a=1.5, c_r=0.5, benchmark=Griewank(), seed=self.seed) es_griewankc = EvolutionStrategyMp1(D=self.D, nFES=self.nFES, nGEN=self.nGEN, mu=30, k=25, c_a=1.5, c_r=0.5, benchmark=Griewank(), seed=self.seed) AlgorithmTestCase.algorithm_run_test(self, es_griewank, es_griewankc)
def test_custom_works_fine(self): es_custom = EvolutionStrategyMp1(D=self.D, nFES=self.nFES, nGEN=self.nGEN, mu=45, k=50, c_a=1.1, c_r=0.5, benchmark=MyBenchmark(), seed=self.seed) es_customc = EvolutionStrategyMp1(D=self.D, nFES=self.nFES, nGEN=self.nGEN, mu=45, k=50, c_a=1.1, c_r=0.5, benchmark=MyBenchmark(), seed=self.seed) AlgorithmTestCase.algorithm_run_test(self, es_custom, es_customc)
def plot_example(): task = TaskConvPlot(D=50, nFES=50000, nGEN=10000, benchmark=MyBenchmark()) algo = EvolutionStrategyMp1(mu=65, k=25, c_a=1.5, c_r=0.25, seed=None, task=task) best = algo.run() logger.info('%s %s' % (best[0], best[1])) input('Press [enter] to continue')
def logging_example(): task = TaskConvPrint(D=50, nFES=50000, nGEN=50000, benchmark=MyBenchmark()) algo = EvolutionStrategyMp1(mu=50, k=25, c_a=1.5, c_r=0.25, seed=None, task=task) best = algo.run() logger.info('nFES:%s nGEN:%s\n%s %s' % (task.Evals, task.Iters, 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 EvolutionStrategyMp1 from NiaPy.task.task import StoppingTask, OptimizationType from NiaPy.benchmarks import Sphere #we will run Differential Evolution for 5 independent runs for i in range(5): task = StoppingTask(D=10, nFES=10000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) algo = EvolutionStrategyMp1() best = algo.run(task=task) print('%s -> %f' % (best[0].x, best[1])) # vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
def setUp(self): self.D = 40 self.es_custom = EvolutionStrategyMp1(D=self.D, nFES=1000, mu=45, k=50, c_a=1.1, c_r=0.5, benchmark=MyBenchmark()) self.es_griewank = EvolutionStrategyMp1(D=self.D, nFES=1000, mu=30, k=25, c_a=1.5, c_r=0.5, benchmark=Griewank())