Пример #1
0
 def test_griewank_works_fine(self):
     mke_griewank = MonkeyKingEvolutionV3(n=10,
                                          C_a=5,
                                          C_r=0.5,
                                          seed=self.seed)
     mke_griewankc = MonkeyKingEvolutionV3(n=10,
                                           C_a=5,
                                           C_r=0.5,
                                           seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, mke_griewank, mke_griewankc)
Пример #2
0
 def test_custom_works_fine(self):
     mke_custom = MonkeyKingEvolutionV3(n=10,
                                        C_a=2,
                                        C_r=0.5,
                                        seed=self.seed)
     mke_customc = MonkeyKingEvolutionV3(n=10,
                                         C_a=2,
                                         C_r=0.5,
                                         seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, mke_custom, mke_customc,
                                          MyBenchmark())
Пример #3
0
 def setUp(self):
     self.D = 40
     self.mkev3_custom = MonkeyKingEvolutionV3(D=self.D,
                                               nFES=1000,
                                               n=10,
                                               C_a=2,
                                               C_r=0.5,
                                               benchmark=MyBenchmark())
     self.mkev3_griewank = MonkeyKingEvolutionV3(D=self.D,
                                                 nFES=1000,
                                                 n=10,
                                                 C_a=5,
                                                 C_r=0.5,
                                                 benchmark=Griewank())
Пример #4
0
 def test_griewank_works_fine(self):
     mke_griewank = MonkeyKingEvolutionV3(D=self.D,
                                          nFES=self.nFES,
                                          nGEN=self.nGEN,
                                          n=10,
                                          C_a=5,
                                          C_r=0.5,
                                          benchmark=Griewank(),
                                          seed=self.seed)
     mke_griewankc = MonkeyKingEvolutionV3(D=self.D,
                                           nFES=self.nFES,
                                           nGEN=self.nGEN,
                                           n=10,
                                           C_a=5,
                                           C_r=0.5,
                                           benchmark=Griewank(),
                                           seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, mke_griewank, mke_griewankc)
Пример #5
0
 def test_custom_works_fine(self):
     mke_custom = MonkeyKingEvolutionV3(D=self.D,
                                        nFES=self.nFES,
                                        nGEN=self.nGEN,
                                        n=10,
                                        C_a=2,
                                        C_r=0.5,
                                        benchmark=MyBenchmark(),
                                        seed=self.seed)
     mke_customc = MonkeyKingEvolutionV3(D=self.D,
                                         nFES=self.nFES,
                                         nGEN=self.nGEN,
                                         n=10,
                                         C_a=2,
                                         C_r=0.5,
                                         benchmark=MyBenchmark(),
                                         seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, mke_custom, mke_customc)
Пример #6
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 MonkeyKingEvolutionV3
from NiaPy.util import StoppingTask, OptimizationType
from NiaPy.benchmarks import Sphere

# we will run Nelder Mead algorithm for 5 independent runs
for i in range(5):
    task = StoppingTask(D=10,
                        nGEN=50,
                        optType=OptimizationType.MINIMIZATION,
                        benchmark=Sphere())
    algo = MonkeyKingEvolutionV3()
    best = algo.run(task=task)
    print('%s -> %s' % (best[0], best[1]))

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Пример #7
0
def plot_example(D=10, nFES=50000, nGEN=100000, seed=None, optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPlot(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = MonkeyKingEvolutionV3(NP=25, C=3, F=0.5, FC=0.5, R=0.4, task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))
	input('Press [enter] to continue')
Пример #8
0
def simple_example(runs=10, D=10, nFES=50000, nGEN=100000, seed=None, optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	for i in range(10):
		Algorithm = MonkeyKingEvolutionV3(D=D, nFES=nFES, NP=25, C=3, F=0.5, FC=0.5, R=0.4, optType=optType, benchmark=optFunc())
		Best = Algorithm.run()
		logger.info('%s %s' % (Best[0], Best[1]))