Last change
on this file since 1223 was
1190,
checked in by Maciej Komosinski, 2 years ago
|
Added the "evolalg" module for evolutionary optimization
|
File size:
848 bytes
|
Line | |
---|
1 | import numpy as np |
---|
2 | |
---|
3 | from ..base.experiment_islands_model_abc import ExperimentIslands |
---|
4 | from ..structures.hall_of_fame import HallOfFame |
---|
5 | |
---|
6 | |
---|
7 | class ExperimentNumericalIslands(ExperimentIslands): |
---|
8 | def __init__(self, hof_size, popsize, number_of_populations, migration_interval, save_only_best) -> None: |
---|
9 | ExperimentIslands.__init__(self,popsize=popsize, |
---|
10 | hof_size=hof_size, |
---|
11 | number_of_populations=number_of_populations, |
---|
12 | migration_interval=migration_interval, |
---|
13 | save_only_best=save_only_best) |
---|
14 | |
---|
15 | def mutate(self, gen1): |
---|
16 | return gen1 + np.random.randint(-10, 10, len(gen1)) |
---|
17 | |
---|
18 | def cross_over(self, gen1, gen2): |
---|
19 | return gen1 |
---|
20 | |
---|
21 | def evaluate(self, genotype): |
---|
22 | return 1/sum([x*x for x in genotype]) |
---|
Note: See
TracBrowser
for help on using the repository browser.