Last change
on this file since 1242 was
1185,
checked in by Maciej Komosinski, 2 years ago
|
Renamed a module; new name is "evolalg_steps"
|
File size:
752 bytes
|
Line | |
---|
1 | from evolalg_steps.selection.selection import Selection |
---|
2 | from deap import tools |
---|
3 | import copy |
---|
4 | |
---|
5 | |
---|
6 | class NSGA2Selection(Selection): |
---|
7 | def __init__(self, copy=False, *args, **kwargs): |
---|
8 | super(NSGA2Selection, self).__init__(*args, **kwargs, copy=copy) |
---|
9 | |
---|
10 | def call(self, population, count=None): |
---|
11 | super(NSGA2Selection, self).call(population) |
---|
12 | pop = tools.selNSGA2(population, len(population)) |
---|
13 | # make count divisible by 4, required by deap.tools.selTournamentDCD() |
---|
14 | remainder=count % 4 |
---|
15 | if remainder > 0: |
---|
16 | count += 4-remainder |
---|
17 | return copy.deepcopy(tools.selTournamentDCD(pop, count)) # "The individuals sequence length has to be a multiple of 4 only if k is equal to the length of individuals" |
---|
Note: See
TracBrowser
for help on using the repository browser.