forked from NiaOrg/NiaPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_mfo.py
32 lines (26 loc) · 799 Bytes
/
run_mfo.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
# 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.basic import MothFlameOptimizer
logging.basicConfig()
logger = logging.getLogger('examples')
logger.setLevel('INFO')
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 = MothFlameOptimizer(D=10, NP=20, nGEN=10000, seed=1234, benchmark=MyBenchmark())
Best = Algorithm.run()
logger.info(Best)