当前位置: 首页>>代码示例>>Python>>正文


Python Organism.function_population方法代码示例

本文整理汇总了Python中Bio.GA.Organism.function_population方法的典型用法代码示例。如果您正苦于以下问题:Python Organism.function_population方法的具体用法?Python Organism.function_population怎么用?Python Organism.function_population使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bio.GA.Organism的用法示例。


在下文中一共展示了Organism.function_population方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_schemas

# 需要导入模块: from Bio.GA import Organism [as 别名]
# 或者: from Bio.GA.Organism import function_population [as 别名]
    def find_schemas(self, fitness, num_schemas):
        """Find the given number of unique schemas using a genetic algorithm

        Arguments:

        o fitness - A callable object (ie. function) which will evaluate
        the fitness of a motif.

        o num_schemas - The number of unique schemas with good fitness
        that we want to generate.
        """
        start_population = \
           Organism.function_population(self.motif_generator.random_motif,
                                        self.initial_population,
                                        fitness)
        finisher = SimpleFinisher(num_schemas, self.min_generations)

        # set up the evolver and do the evolution
        evolver = GenerationEvolver(start_population, self.selector)
        evolved_pop = evolver.evolve(finisher.is_finished)

        # convert the evolved population into a PatternRepository
        schema_info = {}
        for org in evolved_pop:
            # convert the Genome from a MutableSeq to a Seq so that
            # the schemas are just strings (and not array("c")s)
            seq_genome = org.genome.toseq()
            schema_info[str(seq_genome)] = org.fitness

        return PatternRepository(schema_info)
开发者ID:Ambuj-UF,项目名称:ConCat-1.0,代码行数:32,代码来源:Schema.py

示例2: test_function_population

# 需要导入模块: from Bio.GA import Organism [as 别名]
# 或者: from Bio.GA.Organism import function_population [as 别名]
    def test_function_population(self):
        """Create a population using a function to generate genomes.
        """
        num_orgs = 10
        new_pop = Organism.function_population(genome_generator,
                                               num_orgs, fitness_calculator)

        self.assertEqual(len(new_pop), num_orgs, "Expected %s organisms, "
                         "got %s" % (num_orgs, len(new_pop)))
        for org in new_pop:
            self.assertIsInstance(org, Organism.Organism,
                                  "Expected to get an organism, got %r" % org)

            exp_fit = fitness_calculator(org.genome)
            self.assertEqual(org.fitness, exp_fit, "Expected fitness of %s, "
                             "got %s" % (org.fitness, exp_fit))
开发者ID:mtrellet,项目名称:biopython,代码行数:18,代码来源:test_GAOrganism.py

示例3: test_function_population

# 需要导入模块: from Bio.GA import Organism [as 别名]
# 或者: from Bio.GA.Organism import function_population [as 别名]
    def test_function_population(self):
        """Create a population using a function to generate genomes.
        """
        num_orgs = 10
        new_pop = Organism.function_population(genome_generator,
                                               num_orgs, fitness_calculator)

        assert len(new_pop) == num_orgs, "Expected %s organisms, got %s" \
               % (num_orgs, len(new_pops))

        for org in new_pop:
            assert isinstance(org, Organism.Organism), \
                   "Expected to get an organism, got %r" % org

            exp_fit = fitness_calculator(org.genome)
            assert org.fitness == exp_fit, \
                   "Expected fitness of %s, got %s" % (org.fitness, exp_fit)
开发者ID:BingW,项目名称:biopython,代码行数:19,代码来源:test_GAOrganism.py


注:本文中的Bio.GA.Organism.function_population方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。