Esempio n. 1
0
 def test_custom_works_fine(self):
     ca_custom = DynNpMultiStrategyDifferentialEvolutionMTS(NP=40,
                                                            seed=self.seed)
     ca_customc = DynNpMultiStrategyDifferentialEvolutionMTS(NP=40,
                                                             seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, ca_custom, ca_customc,
                                          MyBenchmark())
Esempio n. 2
0
	def test_griewank_works_fine(self):
		ca_griewank = DynNpMultiStrategyDifferentialEvolutionMTS(NP=40, D=self.D, nGEN=self.nGEN, nFES=self.nFES, benchmark=Griewank(), seed=self.seed)
		ca_griewankc = DynNpMultiStrategyDifferentialEvolutionMTS(NP=40, D=self.D, nGEN=self.nGEN, nFES=self.nFES, benchmark=Griewank(), seed=self.seed)
		AlgorithmTestCase.algorithm_run_test(self, ca_griewank, ca_griewankc)
Esempio n. 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 DynNpMultiStrategyDifferentialEvolutionMTS
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 = DynNpMultiStrategyDifferentialEvolutionMTS(NP=50,
                                                      F=0.5,
                                                      CR=0.9,
                                                      pmax=10)
    best = algo.run(task=task)
    print('%s -> %s' % (best[0].x, best[1]))

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Esempio n. 4
0
 def test_griewank_works_fine(self):
     ca_griewank = DynNpMultiStrategyDifferentialEvolutionMTS(
         NP=40, seed=self.seed)
     ca_griewankc = DynNpMultiStrategyDifferentialEvolutionMTS(
         NP=40, seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, ca_griewank, ca_griewankc)