コード例 #1
0
ファイル: test_ha.py プロジェクト: tuahk/NiaPy
 def setUp(self):
     self.D = 40
     self.hs_custom = HarmonySearchV1(D=self.D,
                                      nFES=1000,
                                      benchmark=MyBenchmark())
     self.hs_griewank = HarmonySearchV1(D=self.D,
                                        nFES=1000,
                                        benchmark=Griewank())
コード例 #2
0
 def test_griewank_works_fine(self):
     hs_griewank = HarmonySearchV1(D=self.D,
                                   nFES=self.nFES,
                                   nGEN=self.nGEN,
                                   seed=self.seed,
                                   benchmark=Griewank())
     hs_griewankc = HarmonySearchV1(D=self.D,
                                    nFES=self.nFES,
                                    nGEN=self.nGEN,
                                    seed=self.seed,
                                    benchmark=Griewank())
     AlgorithmTestCase.algorithm_run_test(self, hs_griewank, hs_griewankc)
コード例 #3
0
 def test_custom_works_fine(self):
     hs_costom = HarmonySearchV1(D=self.D,
                                 nFES=self.nFES,
                                 nGEN=self.nGEN,
                                 seed=self.seed,
                                 benchmark=MyBenchmark())
     hs_costomc = HarmonySearchV1(D=self.D,
                                  nFES=self.nFES,
                                  nGEN=self.nGEN,
                                  seed=self.seed,
                                  benchmark=MyBenchmark())
     AlgorithmTestCase.algorithm_run_test(self, hs_costom, hs_costomc)
コード例 #4
0
ファイル: test_hs.py プロジェクト: taylorhawks/NiaPy
 def test_type_parameters(self):
     d = HarmonySearchV1.typeParameters()
     self.assertIsNone(d.get('b_range', None))
     self.assertIsNotNone(d.get('dw_min', None))
     self.assertIsNotNone(d.get('dw_max', None))
     self.assertTrue(d['dw_min'](10))
     self.assertFalse(d['dw_min'](-10))
     self.assertTrue(d['dw_max'](10))
     self.assertFalse(d['dw_max'](-10))
コード例 #5
0
def plot_example():
    task = TaskConvPlot(D=50, nFES=50000, nGEN=50000, benchmark=MyBenchmark())
    algo = HarmonySearchV1(HMS=50,
                           r_accept=0.7,
                           r_pa=0.2,
                           b_range=1.1,
                           task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')
コード例 #6
0
def simple_example(runs=10):
    for i in range(runs):
        algo = HarmonySearchV1(D=50,
                               nFES=50000,
                               HMS=50,
                               r_accept=0.7,
                               r_pa=0.2,
                               benchmark=MyBenchmark())
        best = algo.run()
        logger.info('%s %s' % (best[0], best[1]))
コード例 #7
0
def logging_example():
    task = TaskConvPrint(D=50, nFES=50000, nGEN=50000, benchmark=MyBenchmark())
    algo = HarmonySearchV1(HMS=50,
                           r_accept=0.7,
                           r_pa=0.2,
                           bw_min=0.32,
                           bw_max=1.5,
                           seed=None,
                           task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
コード例 #8
0
ファイル: test_hs.py プロジェクト: taylorhawks/NiaPy
 def test_griewank_works_fine(self):
     hs_griewank = HarmonySearchV1(seed=self.seed)
     hs_griewankc = HarmonySearchV1(seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, hs_griewank, hs_griewankc)
コード例 #9
0
ファイル: test_hs.py プロジェクト: taylorhawks/NiaPy
 def test_custom_works_fine(self):
     hs_costom = HarmonySearchV1(seed=self.seed)
     hs_costomc = HarmonySearchV1(seed=self.seed)
     AlgorithmTestCase.algorithm_run_test(self, hs_costom, hs_costomc,
                                          MyBenchmark())
コード例 #10
0
ファイル: run_hsv1.py プロジェクト: zyumons/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

from NiaPy.algorithms.basic import HarmonySearchV1
from NiaPy.task import StoppingTask
from NiaPy.benchmarks import Sphere

# we will run Bat Algorithm for 5 independent runs
algo = HarmonySearchV1()
for i in range(5):
    task = StoppingTask(D=10, nGEN=1000, benchmark=Sphere())
    best = algo.run(task)
    print('%s -> %s' % (best[0], best[1]))
print(algo.getParameters())

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