source: framspy/evolalg_steps/selection/nsga2.py @ 1297

Last change on this file since 1297 was 1185, checked in by Maciej Komosinski, 2 years ago

Renamed a module; new name is "evolalg_steps"

File size: 752 bytes
RevLine 
[1185]1from evolalg_steps.selection.selection import Selection
[1147]2from deap import tools
3import copy
4
5
6class 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))
[1148]13        # make count divisible by 4, required by deap.tools.selTournamentDCD()
[1147]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.