Задача E. Chromosome

Входной файл:Стандартный вход   Ограничение времени:1 сек
Выходной файл:Стандартный выход   Ограничение памяти:512 Мб

Условие

Требуется реализовать на языке Python класс Chromosome, который предполагается использовать при построении генетического алгоритма.

У класса должен быть следующий интерфейс:


class Chromosome:
    # Chromosome class constructor
    # Actual functionality is to set up an array called genes.
    # If boolean flag fillGenes is set to True, genes must be
    # filled with random values between 0 and 1, otherwise
    # it must be filled with 0.
    # Length of array genes must be equal to length 
    # constructor parameter.
    # Also initializes local variable mutationRate
    # with corresponding parameter.
    def __init__(self, length, mutationRate, fillGenes=False):
        pass
        
    # Creates two offspring children using a single crossover point.
    # The basic idea is to first pick a random position, create two 
    # children and then swap their genes starting from the randomly 
    # picked position point.
    # Children genes must be different from both of parents.
    # 
    # Returning type: (Chromosome, Chromosome)
    def Crossover(self, another):
        pass
        
    # Mutates the chromosome genes in place by randomly switching them
    # depending on mutationRate. More precisely, mutation
    # of i-th gene happens with probability of mutationRate.
    def Mutate(self):
        pass

   

У класса должны быть следующие поля:

Формат выходных данных

Код решения должен содержать только определение и реализацию класса.


0.053s 0.012s 13