예제 #1
0
 def test_griewank_works_fine(self):
     mke_griewank = MonkeyKingEvolutionV1(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 = MonkeyKingEvolutionV1(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)
예제 #2
0
 def test_griewank_works_fine(self):
     fwa_griewank = FireworksAlgorithm(D=self.D,
                                       nFES=self.nFES,
                                       nGEN=self.nGEN,
                                       n=10,
                                       C_a=5,
                                       C_r=0.5,
                                       benchmark=Griewank(),
                                       seed=self.seed)
     fwa_griewankc = FireworksAlgorithm(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, fwa_griewank, fwa_griewankc)
예제 #3
0
파일: test_mke.py 프로젝트: tuahk/NiaPy
 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())
예제 #4
0
파일: test_mke.py 프로젝트: tuahk/NiaPy
 def test_griewank_works_fine(self):
     fun = Griewank().function()
     x = self.mkev2_griewank.run()
     self.assertTrue(x)
     self.assertAlmostEqual(fun(self.D, x[0]), x[1], delta=1e2)
예제 #5
0
                             r=0.5,
                             Qmin=0.0,
                             Qmax=2.0,
                             benchmark=MyBenchmark())
    Best = Algorithm.run()
    logger.info(Best)

# example using predifined benchmark function
# available benchmarks are:
# - griewank
# - rastrigin
# - rosenbrock
# - sphere
logger.info('Running with default Griewank benchmark...')

griewank = Griewank()

for i in range(10):
    Algorithm = BatAlgorithm(D=10,
                             NP=40,
                             nFES=10000,
                             A=0.5,
                             r=0.5,
                             Qmin=0.0,
                             Qmax=2.0,
                             benchmark=griewank)
    Best = Algorithm.run()
    Best = Algorithm.run()
    logger.info(Best)

logger.info(
예제 #6
0
파일: run_hsaba.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.modified import HybridSelfAdaptiveBatAlgorithm
from NiaPy.task import StoppingTask
from NiaPy.benchmarks import Griewank

# we will run Bat Algorithm for 5 independent runs
algo = HybridSelfAdaptiveBatAlgorithm(NP=50)
for i in range(5):
    task = StoppingTask(D=10,
                        nGEN=10000,
                        benchmark=Griewank(Upper=600, Lower=-600))
    best = algo.run(task)
    print('%s -> %s' % (best[0], best[1]))
print(algo.getParameters())

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
예제 #7
0
    Ackley,
    Griewank,
    Sphere,
    HappyCat
)


"""Example demonstrating the use of NiaPy Runner."""


runner = Runner(
    D=40,
    nFES=100,
    nRuns=2,
    useAlgorithms=[
        GreyWolfOptimizer(),
        "FlowerPollinationAlgorithm",
        ParticleSwarmAlgorithm(),
        "HybridBatAlgorithm",
        "SimulatedAnnealing",
        "CuckooSearch"],
    useBenchmarks=[
        Ackley(),
        Griewank(),
        Sphere(),
        HappyCat(),
        "rastrigin"]
)

print(runner.run(verbose=True))
예제 #8
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 SelfAdaptiveDifferentialEvolution
from NiaPy.task import StoppingTask
from NiaPy.benchmarks import Griewank

# we will run jDE algorithm for 5 independent runs
algo = SelfAdaptiveDifferentialEvolution(NP=40, F=0.5, F_l=0.0, F_u=2.0, Tao1=0.9, CR=0.5, Tao2=0.45)
for i in range(5):
	task = StoppingTask(D=10, nFES=10000, benchmark=Griewank(Lower=-600, Upper=600), logger=True)
	best = algo.run(task)
	print('%s -> %s' % (best[0], best[1]))
print(algo.getParameters())

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

예제 #9
0
파일: run_de.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.task import StoppingTask
from NiaPy.benchmarks import Griewank
from NiaPy.algorithms.basic import DifferentialEvolution

# we will run Differential Evolution for 5 independent runs
algo = DifferentialEvolution(NP=50, F=0.5, CR=0.9)
for i in range(5):
    task = StoppingTask(D=10,
                        nFES=10000,
                        benchmark=Griewank(Lower=-600, Upper=600),
                        logger=True)
    best = algo.run(task)
    print('%s -> %s' % (best[0], best[1]))
print(algo.getParameters())
예제 #10
0
파일: run_aba.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.modified import AdaptiveBatAlgorithm
from NiaPy.task import StoppingTask
from NiaPy.benchmarks import Griewank

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

예제 #11
0
파일: run_aco.py 프로젝트: kozulic/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 AntColonyOptimization
from NiaPy.util import StoppingTask, OptimizationType
from NiaPy.benchmarks import Sphere
from NiaPy.benchmarks import Ackley
from NiaPy.benchmarks import Griewank

# we will run Ant Colony Optimization for 5 independent runs
for i in range(5):
    task = StoppingTask(D=10, nGEN=1000, optType=OptimizationType.MINIMIZATION, benchmark=Griewank())
    algo = AntColonyOptimization(NP=40)
    best = algo.run(task=task)
    print('%s -> %s' % (best[0], best[1]))