-
Notifications
You must be signed in to change notification settings - Fork 80
/
runner.py
49 lines (40 loc) · 1.11 KB
/
runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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 numpy as np
from niapy import Runner
from niapy.algorithms.basic import (
GreyWolfOptimizer,
ParticleSwarmAlgorithm
)
from niapy.problems import (
Problem,
Ackley,
Griewank,
Sphere,
HappyCat
)
"""Example demonstrating the use of niapy Runner."""
class MyProblem(Problem):
def __init__(self, dimension, lower=-10, upper=10, *args, **kwargs):
super().__init__(dimension, lower, upper, *args, **kwargs)
def _evaluate(self, x):
return np.sum(x ** 2)
runner = Runner(dimension=40, max_evals=100, runs=2, algorithms=[
GreyWolfOptimizer(),
"FlowerPollinationAlgorithm",
ParticleSwarmAlgorithm(),
"HybridBatAlgorithm",
"SimulatedAnnealing",
"CuckooSearch"], problems=[
Ackley(dimension=40),
Griewank(dimension=40),
Sphere(dimension=40),
HappyCat(dimension=40),
"rastrigin",
MyProblem(dimension=40)
])
runner.run(export='dataframe', verbose=True)