Passed
Push — master ( bf6d5c...a49e28 )
by Grega
01:20
created

run_cso   A

Complexity

Total Complexity 0

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 22
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.basic import CatSwarmOptimization
9
from NiaPy.task.task import StoppingTask, OptimizationType
10
from NiaPy.benchmarks import Sphere
11
12
# we will run Cat Swarm Optimization for 5 independent runs
13
for i in range(1):
14
    task = StoppingTask(D=10, nFES=1000, optType=OptimizationType.MINIMIZATION, logger=True, benchmark=Sphere())
15
    algo = CatSwarmOptimization()
16
    best = algo.run(task=task)
17
    #print(best,'\n', Sphere().function()(task.D,best[0]))
18
    print('%s -> %s' % (best[0], best[1]))
19
20
    #plot a convergence graph
21
    task.plot()