-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathrun_mshde.py
More file actions
20 lines (17 loc) · 812 Bytes
/
run_mshde.py
File metadata and controls
20 lines (17 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# encoding=utf8
# This is temporary fix to import module from parent folder
# It will be removed when package is published on PyPI
import sys
sys.path.append('../')
# End of fix
from niapy.algorithms.modified import MultiStrategyDifferentialEvolutionMTS
from niapy.algorithms.basic.de import cross_curr2best1, cross_best1
from niapy.task import Task
from niapy.problems import Sphere
# we will run Differential Evolution for 5 independent runs
for i in range(5):
task = Task(problem=Sphere(dimension=10), max_evals=10000)
algo = MultiStrategyDifferentialEvolutionMTS(population_size=50, differential_weight=0.5, crossover_probability=0.9,
strategies=(cross_best1, cross_curr2best1))
best = algo.run(task)
print('%s -> %s' % (best[0], best[1]))