Beispiel #1
0
 def test_custom_works_fine(self):
     ca_custom = MultiStrategyDifferentialEvolutionMTS(NP=40,
                                                       seed=self.seed)
     ca_customc = MultiStrategyDifferentialEvolutionMTS(NP=40,
                                                        seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, ca_custom, ca_customc,
                                          MyBenchmark())
Beispiel #2
0
 def test_griewank_works_fine(self):
     ca_griewank = MultiStrategyDifferentialEvolutionMTS(NP=40,
                                                         seed=self.seed)
     ca_griewankc = MultiStrategyDifferentialEvolutionMTS(NP=40,
                                                          seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, ca_griewank, ca_griewankc)
Beispiel #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

from NiaPy.algorithms.modified import MultiStrategyDifferentialEvolutionMTS
from NiaPy.algorithms.basic.de import CrossCurr2Best1, CrossBest1
from NiaPy.util 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=5000,
                        optType=OptimizationType.MINIMIZATION,
                        benchmark=Sphere())
    algo = MultiStrategyDifferentialEvolutionMTS(NP=50,
                                                 F=0.5,
                                                 CR=0.4,
                                                 strategies=(CrossBest1,
                                                             CrossCurr2Best1))
    best = algo.run(task=task)
    print('%s -> %s' % (best[0].x, best[1]))

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3