Example #1
0
 def test_griewank_works_fine(self):
     de_griewank = AgingNpMultiMutationDifferentialEvolution(NP=10,
                                                             CR=0.5,
                                                             F=0.9,
                                                             seed=self.seed)
     de_griewankc = AgingNpMultiMutationDifferentialEvolution(
         NP=10, CR=0.5, F=0.9, seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, de_griewank, de_griewankc,
                                          'griewank')
Example #2
0
 def test_custom_works_fine(self):
     de_custom = AgingNpMultiMutationDifferentialEvolution(NP=40,
                                                           F=0.5,
                                                           CR=0.9,
                                                           seed=self.seed)
     de_customc = AgingNpMultiMutationDifferentialEvolution(NP=40,
                                                            F=0.5,
                                                            CR=0.9,
                                                            seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, de_custom, de_customc,
                                          MyBenchmark())
Example #3
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 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
Example #4
0
 def test_type_parameters(self):
     d = AgingNpMultiMutationDifferentialEvolution.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))
Example #5
0
 def test_algorithm_info(self):
     self.assertIsNotNone(
         AgingNpMultiMutationDifferentialEvolution.algorithmInfo())