Пример #1
0
 def test_griewank_works_proportional_fine(self):
     de_griewank = AgingNpDifferentialEvolution(NP=10,
                                                CR=0.5,
                                                F=0.9,
                                                age=proportional,
                                                seed=self.seed)
     de_griewankc = AgingNpDifferentialEvolution(NP=10,
                                                 CR=0.5,
                                                 F=0.9,
                                                 age=proportional,
                                                 seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, de_griewank, de_griewankc,
                                          'griewank')
Пример #2
0
 def test_custom_works_proportional_fine(self):
     de_custom = AgingNpDifferentialEvolution(NP=40,
                                              F=0.5,
                                              CR=0.9,
                                              age=proportional,
                                              seed=self.seed)
     de_customc = AgingNpDifferentialEvolution(NP=40,
                                               F=0.5,
                                               CR=0.9,
                                               age=proportional,
                                               seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, de_custom, de_customc,
                                          MyBenchmark())
Пример #3
0
 def test_griewank_works_fine(self):
     de_griewank = AgingNpDifferentialEvolution(NP=10,
                                                D=self.D,
                                                nFES=self.nFES,
                                                nGEN=self.nGEN,
                                                CR=0.5,
                                                F=0.9,
                                                benchmark='griewank',
                                                seed=self.seed)
     de_griewankc = AgingNpDifferentialEvolution(NP=10,
                                                 D=self.D,
                                                 nFES=self.nFES,
                                                 nGEN=self.nGEN,
                                                 CR=0.5,
                                                 F=0.9,
                                                 benchmark='griewank',
                                                 seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, de_griewank, de_griewankc)
Пример #4
0
 def test_Custom_works_fine(self):
     de_custom = AgingNpDifferentialEvolution(D=self.D,
                                              NP=40,
                                              nFES=self.nFES,
                                              nGEN=self.nGEN,
                                              F=0.5,
                                              CR=0.9,
                                              benchmark=MyBenchmark(),
                                              seed=self.seed)
     de_customc = AgingNpDifferentialEvolution(D=self.D,
                                               NP=40,
                                               nFES=self.nFES,
                                               nGEN=self.nGEN,
                                               F=0.5,
                                               CR=0.9,
                                               benchmark=MyBenchmark(),
                                               seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, de_custom, de_customc)
Пример #5
0
# 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 AgingNpDifferentialEvolution
from NiaPy.algorithms.basic.de import bilinear
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 = AgingNpDifferentialEvolution(NP=40,
                                        F=0.63,
                                        CR=0.9,
                                        Lt_min=3,
                                        Lt_max=7,
                                        omega=0.2,
                                        delta_np=0.1,
                                        age=bilinear)
    best = algo.run(task=task)
    print('%s -> %s' % (best[0].x, best[1]))

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Пример #6
0
 def test_type_parameters(self):
     d = AgingNpDifferentialEvolution.typeParameters()
     self.assertIsNotNone(d.pop('Lt_min', None))
     self.assertIsNotNone(d.pop('Lt_max', None))
     self.assertIsNotNone(d.pop('delta_np', None))
     self.assertIsNotNone(d.pop('omega', None))
Пример #7
0
 def test_algorithm_info(self):
     self.assertIsNotNone(AgingNpDifferentialEvolution.algorithmInfo())