Passed
Pull Request — master (#202)
by Grega
01:02
created

run_ga.MaxMB.function()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 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 GeneticAlgorithm
9
from NiaPy.algorithms.basic.ga import MutationUros, CrossoverUros
10
from NiaPy.util import StoppingTask, OptimizationType
11
from NiaPy.benchmarks import Sphere
12
13
# we will run Fireworks Algorithm for 5 independent runs
14
for i in range(5):
15
	task = StoppingTask(D=10, nFES=4000, optType=OptimizationType.MINIMIZATION, benchmark=Sphere())
16
	algo = GeneticAlgorithm(NP=100, Crossover=CrossoverUros, Mutation=MutationUros, Cr=0.45, Mr=0.9)
17
	best = algo.run(task=task)
18
	print('%s -> %s' % (best[0].x, best[1]))
19
20
# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
21