Total Complexity | 0 |
Total Lines | 18 |
Duplicated Lines | 0 % |
Changes | 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 CenterParticleSwarmOptimization |
||
9 | from NiaPy.task.task import StoppingTask, OptimizationType |
||
10 | from NiaPy.benchmarks import Sphere |
||
11 | |||
12 | # we will run ParticleSwarmAlgorithm for 5 independent runs |
||
13 | algo = CenterParticleSwarmOptimization(NP=51, C1=1.3, C2=2.0, w=0.86, vMin=-1, vMax=1) |
||
14 | for i in range(5): |
||
15 | task = StoppingTask(D=25, nFES=20000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere()) |
||
16 | best = algo.run(task=task) |
||
17 | print('%s -> %f' % (best[0], best[1])) |
||
18 | # print(algo.getParameters()) |
||
21 |