コード例 #1
0
 def test_griewank_works_fine(self):
     dynnpjde_griewank = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm(
         D=self.D,
         NP=40,
         nFES=self.nFES,
         nGEN=self.nGEN,
         F=0.5,
         F_l=0.0,
         F_u=2.0,
         Tao1=0.9,
         CR=0.1,
         Tao2=0.45,
         benchmark='griewank',
         seed=self.seed)
     dynnpjde_griewankc = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm(
         D=self.D,
         NP=40,
         nFES=self.nFES,
         nGEN=self.nGEN,
         F=0.5,
         F_l=0.0,
         F_u=2.0,
         Tao1=0.9,
         CR=0.1,
         Tao2=0.45,
         benchmark='griewank',
         seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, dynnpjde_griewank,
                                          dynnpjde_griewankc)
コード例 #2
0
 def test_custom_works_fine(self):
     dynnpjde_custom = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm(
         D=self.D,
         NP=40,
         nFES=self.nFES,
         nGEN=self.nGEN,
         F=0.5,
         F_l=0.0,
         F_u=2.0,
         Tao1=0.9,
         CR=0.1,
         Tao2=0.45,
         benchmark=MyBenchmark(),
         seed=self.seed)
     dynnpjde_customc = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm(
         D=self.D,
         NP=40,
         nFES=self.nFES,
         nGEN=self.nGEN,
         F=0.5,
         F_l=0.0,
         F_u=2.0,
         Tao1=0.9,
         CR=0.1,
         Tao2=0.45,
         benchmark=MyBenchmark(),
         seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, dynnpjde_custom,
                                          dynnpjde_customc)
コード例 #3
0
 def test_typeParameters(self):
     d = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm.typeParameters()
     self.assertTrue(d['rp'](10))
     self.assertTrue(d['rp'](10.10))
     self.assertFalse(d['rp'](0))
     self.assertFalse(d['rp'](-10))
     self.assertTrue(d['pmax'](10))
     self.assertFalse(d['pmax'](0))
     self.assertFalse(d['pmax'](-10))
     self.assertFalse(d['pmax'](10.12))
コード例 #4
0
 def test_griewank_works_fine(self):
     dynnpjde_griewank = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm(
         NP=40,
         F=0.5,
         F_l=0.0,
         F_u=2.0,
         Tao1=0.9,
         CR=0.1,
         Tao2=0.45,
         seed=self.seed)
     dynnpjde_griewankc = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm(
         NP=40,
         F=0.5,
         F_l=0.0,
         F_u=2.0,
         Tao1=0.9,
         CR=0.1,
         Tao2=0.45,
         seed=self.seed)
     AlgorithmTestCase.test_algorithm_run(self, dynnpjde_griewank,
                                          dynnpjde_griewankc)
コード例 #5
0
 def test_custom_works_fine(self):
     dynnpjde_custom = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm(
         NP=40,
         F=0.5,
         F_l=0.0,
         F_u=2.0,
         Tao1=0.9,
         CR=0.1,
         Tao2=0.45,
         seed=self.seed)
     dynnpjde_customc = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm(
         NP=40,
         F=0.5,
         F_l=0.0,
         F_u=2.0,
         Tao1=0.9,
         CR=0.1,
         Tao2=0.45,
         seed=self.seed)
     AlgorithmTestCase.test_algorithm_run(self, dynnpjde_custom,
                                          dynnpjde_customc, MyBenchmark())
コード例 #6
0
ファイル: run_dynnpjde.py プロジェクト: mrspock434/NiaPy
# 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.modified import DynNpSelfAdaptiveDifferentialEvolutionAlgorithm
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=10000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere())
	algo = DynNpSelfAdaptiveDifferentialEvolutionAlgorithm(NP=90, F=0.64, CR=0.9, pmax=25)
	best = algo.run(task=task)
	print('%s -> %s' % (best[0].x, best[1]))

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