Passed
Push — master ( 48c291...a40ac0 )
by Grega
02:23 queued 24s
created

run_hdev1   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 0
1
# encoding=utf8
2
# This is temporary fix to import module from parent folder
3
# It will be removed when package is published on PyPI
4
import sys
5
sys.path.append('../')
6
# End of fix
7
8
from NiaPy.algorithms.modified import DifferentialEvolutionMTSv1
9
from NiaPy.algorithms.basic.de import CrossBest2
10
from NiaPy.util import StoppingTask, OptimizationType
11
from NiaPy.benchmarks import Sphere
12
13
# we will run Differential Evolution for 5 independent runs
14
for i in range(5):
15
    task = StoppingTask(D=10, nFES=5000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere())
16
    algo = DifferentialEvolutionMTSv1(NP=50, F=0.5, CR=0.9, CrossMutt=CrossBest2, NoLsTests=5, NoLs=3, NoEnabled=4)
17
    best = algo.run(task=task)
18
    print('%s -> %s' % (best[0].x, best[1]))
19