本文整理汇总了Python中Population.Population.genPopulation方法的典型用法代码示例。如果您正苦于以下问题:Python Population.genPopulation方法的具体用法?Python Population.genPopulation怎么用?Python Population.genPopulation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population.Population
的用法示例。
在下文中一共展示了Population.genPopulation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateTests
# 需要导入模块: from Population import Population [as 别名]
# 或者: from Population.Population import genPopulation [as 别名]
def generateTests():
# Test IP
# 6 alleles, 6 loci, popSize / 3 mothers and fathers, 5 children
for i in range(10, 26, 5):
for j in range(10):
rSeed = 1399 * i + 931 * j
pop = Population(6, 6, i / 3, i / 3, 5, 5, randomSeed=rSeed)
pop.genPopulation(i)
random.shuffle(pop.individuals)
pop.saveState("tests/ip/%d_6_6_%d.pkl" % (i, j))
# Test number of alleles
# 6 loci, 7 mothers, 7 fathers, 5 children, 40 individuals
alleles = [2, 5, 10, 15, 20]
for i in alleles:
for j in range(10):
rSeed = 293 * i + 13 * j
pop = Population(i, 6, 7, 7, 5, 5, randomSeed=rSeed)
pop.genPopulation(40)
random.shuffle(pop.individuals)
if i < 10:
nA = "0%d" % (i)
else:
nA = str(i)
pop.saveState("tests/alleles/40_%s_6_%s.pkl" % (nA, str(j)))
# Test number of loci
# 6 alleles, 7 mothers, 7 fathers, 5 children, 40 individuals
loci = [2, 5, 10, 15, 20]
for i in loci:
for j in range(10):
rSeed = 631 * i + 17 * j
pop = Population(6, i, 7, 7, 5, 5, randomSeed=rSeed)
pop.genPopulation(40)
random.shuffle(pop.individuals)
if i < 10:
nL = "0%d" % (i)
else:
nL = str(i)
pop.saveState("tests/loci/40_6_%s_%d.pkl" % (nL, j))
# Test number of individuals
# 6 alleles, 6 loci, popSize / 3 mothers and fathers, 5 children
popSizes = [10, 50, 100, 200]
for i in popSizes:
for j in range(10):
rSeed = 37 * i + 931 * j
pop = Population(6, 6, i / 3, i / 3, 5, 5, randomSeed=rSeed)
pop.genPopulation(i)
random.shuffle(pop.individuals)
if i < 10:
nI = "00%d" %False
elif i < 100:
nI = "0%d" % (i)
else:
nI = str(i)
pop.saveState("tests/indivs/%s_6_6_%d.pkl" % (nI, j))
# Test family size
# 80 individuals, 6 alleles, 6 loci, 7 mothers and fathers
famSizes = [1, 5, 10, 20]
for i in famSizes:
for j in range(10):
rSeed = 31 * i + 1931 * j
pop = Population(6, 6, 20, 20, i, i, randomSeed=rSeed)
pop.genPopulation(80)
random.shuffle(pop.individuals)
if i < 10:
nI = "0%d" % (i)
else:
nI = str(i)
pop.saveState("tests/famsize/80_6_6_%s_%d.pkl" % (nI, j))
# Test included families
# 40 individuals, 6 alleles, 6 loci, 7 mothers and fathers
for i in range(10):
rSeed = 329019 * i
pop = Population(6, 6, 8, 8, 5, 5, randomSeed=rSeed)
pop.genPopulation(40)
random.shuffle(pop.individuals)
pop.saveState("tests/big/40_6_6_%d.pkl" % (i))
popSizes = [500, 1000, 2000]
for i in popSizes:
for j in range(10):
rSeed = 371 * i + 1931 * j
pop = Population(6, 10, i / 20, i / 20, 20, 20, randomSeed=rSeed)
pop.genPopulation(i)
random.shuffle(pop.individuals)
nI = ''
if i < 1000:
nI = "0%d" % (i)
else:
#.........这里部分代码省略.........