Passed
Pull Request — master (#233)
by Grega
11:33
created

run_clpso   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
import random
9
from NiaPy.algorithms.basic import ComprehensiveLearningParticleSwarmOptimizer
10
from NiaPy.task.task import StoppingTask, OptimizationType
11
from NiaPy.benchmarks import Sphere
12
13
# we will run ParticleSwarmAlgorithm for 5 independent runs
14
algo = ComprehensiveLearningParticleSwarmOptimizer(NP=50, C1=.3, C2=1.0, m=5, w=0.86, vMin=-2, vMax=2)
15
for i in range(5):
16
	task = StoppingTask(D=25, nFES=20000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere())
17
	best = algo.run(task=task)
18
	print('%s -> %f' % (best[0], best[1]))
19
# print(algo.getParameters())
20
21
# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
22