forked from NiaOrg/NiaPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_hba.py
36 lines (29 loc) · 896 Bytes
/
run_hba.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
# 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
import logging
from NiaPy.algorithms.modified import HybridBatAlgorithm
logging.basicConfig()
logger = logging.getLogger('examples')
logger.setLevel('INFO')
# For reproducive results
random.seed(1234)
class MyBenchmark(object):
def __init__(self):
self.Lower = -11
self.Upper = 11
def function(self):
def evaluate(D, sol):
val = 0.0
for i in range(D):
val = val + sol[i] * sol[i]
return val
return evaluate
for i in range(10):
Algorithm = HybridBatAlgorithm(
D=10, NP=40, nFES=10000, A=0.9, r=0.1, F=0.001, CR=0.9, Qmin=0.0, Qmax=2.0, benchmark=MyBenchmark())
Best = Algorithm.run()
logger.info(Best)