| Total Complexity | 0 |
| Total Lines | 19 |
| 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 | import random |
||
| 9 | from NiaPy.algorithms.basic import ParticleSwarmAlgorithm |
||
| 10 | from NiaPy.task import StoppingTask, OptimizationType |
||
| 11 | from NiaPy.benchmarks import Sphere |
||
| 12 | |||
| 13 | #we will run ParticleSwarmAlgorithm for 5 independent runs |
||
| 14 | for i in range(5): |
||
| 15 | task = StoppingTask(D=10, nFES=1000, benchmark=Sphere()) |
||
| 16 | algo = ParticleSwarmAlgorithm(NP=40, C1=2.0, C2=2.0, w=0.7, vMin=-4, vMax=4) |
||
| 17 | best = algo.run(task=task) |
||
| 18 | print (best) |
||
| 19 |