Esempio n. 1
0
 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)
Esempio n. 2
0
 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())
Esempio n. 3
0
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]))
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
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')
Esempio n. 7
0
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]))
Esempio n. 8
0
# 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
Esempio n. 9
0
	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())