Example #1
0
 def test_custom_works_fine(self):
     mke_custom = MonkeyKingEvolutionV2(n=10,
                                        C_a=2,
                                        C_r=0.5,
                                        seed=self.seed)
     mke_customc = MonkeyKingEvolutionV2(n=10,
                                         C_a=2,
                                         C_r=0.5,
                                         seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, mke_custom, mke_customc,
                                          MyBenchmark())
Example #2
0
 def setUp(self):
     self.D = 40
     self.mkev2_custom = MonkeyKingEvolutionV2(D=self.D,
                                               nFES=1000,
                                               n=10,
                                               C_a=2,
                                               C_r=0.5,
                                               benchmark=MyBenchmark())
     self.mkev2_griewank = MonkeyKingEvolutionV2(D=self.D,
                                                 nFES=1000,
                                                 n=10,
                                                 C_a=5,
                                                 C_r=0.5,
                                                 benchmark=Griewank())
Example #3
0
 def test_custom_works_fine(self):
     mke_custom = MonkeyKingEvolutionV2(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 = MonkeyKingEvolutionV2(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)
Example #4
0
def logging_example(D=10,
                    nFES=50000,
                    nGEN=100000,
                    seed=None,
                    optType=OptimizationType.MINIMIZATION,
                    optFunc=MinMB,
                    **kn):
    task = TaskConvPrint(D=D,
                         nFES=nFES,
                         nGEN=nGEN,
                         optType=optType,
                         benchmark=optFunc())
    algo = MonkeyKingEvolutionV2(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]))
Example #5
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 = MonkeyKingEvolutionV2(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]))
Example #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 MonkeyKingEvolutionV2
from NiaPy.task import StoppingTask
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, benchmark=Sphere())
	algo = MonkeyKingEvolutionV2()
	best = algo.run(task)
	print('%s -> %s' % (best[0], best[1]))

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