コード例 #1
0
    def setUp(self):

        start_gene_length = 10
        max_gene_length = 20
        member_no = 1

        self.g = Genotype(start_gene_length, max_gene_length, member_no)
コード例 #2
0
    def create_genotypes(self):
        """
        This function creates a genotype using the input parameters for each
        member of the population, and transfers operating parameters to the
        genotype for running the fitness functions.

        """

        member_no = 0
        while member_no < self._population_size:
            gene = Genotype(self._start_gene_length, self._max_gene_length,
                            member_no)
            #   a local copy is made because variables
            #   can be saved within the local_bnf
            gene.local_bnf = deepcopy(self.bnf)
            gene.local_bnf['<member_no>'] = [gene.member_no]
            gene._max_program_length = self._max_program_length
            gene._fitness = self._fitness_fail
            gene._fitness_fail = self._fitness_fail
            gene._extend_genotype = self._extend_genotype
            gene._timeouts = self._timeouts
            gene._wrap = self._wrap
            self.population.append(gene)
            member_no += 1