def __init__(self, mutator, crossover, repairer=None): """Initialize the selector. Arguments: o mutator -- A Mutation object which will perform mutation on an individual. o crossover -- A Crossover object which will take two individuals and produce two new individuals which may have had crossover occur. o repairer -- A class which can do repair on rearranged genomes to eliminate infeasible individuals. If set at None, so repair will be done. """ AbstractSelection.__init__(self, mutator, crossover, repairer)
def __init__(self, mutator, crossover, repairer = None): """Initialize the selector. Arguments: o mutator -- A Mutation object which will perform mutation on an individual. o crossover -- A Crossover object which will take two individuals and produce two new individuals which may have had crossover occur. o repairer -- A class which can do repair on rearranged genomes to eliminate infeasible individuals. If set at None, so repair will be done. """ AbstractSelection.__init__(self, mutator, crossover, repairer)
def __init__(self, mutator, crossover, repairer, num_competitors=2): """Initialize the tournament selector. Arguments: o num_competitors-- The number of individiuals that should be involved in a selection round. By default we just have two individuals (head to head!). See AbstractSelection for a description of the arguments to the initializer. """ AbstractSelection.__init__(self, mutator, crossover, repairer) if num_competitors < 2: raise ValueError("Must have at least 2 competitors!") self._num_competitors = num_competitors
def __init__(self, mutator, crossover, repairer, num_competitors = 2): """Initialize the tournament selector. Arguments: o num_competitors-- The number of individiuals that should be involved in a selection round. By default we just have two individuals (head to head!). See AbstractSelection for a description of the arguments to the initializer. """ AbstractSelection.__init__(self, mutator, crossover, repairer) if num_competitors < 2: raise ValueError("Must have at least 2 competitors!") self._num_competitors = num_competitors