Last active
August 29, 2015 14:17
-
-
Save romunov/c8e64d1f38d54dd687f6 to your computer and use it in GitHub Desktop.
migrating individuals from one VSP to a neighboring SP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this example demostrantes that two individuals are not migrated from VSP [1, 1] to subpopulation 0 | |
import simuPOP as sim | |
import numpy as np | |
pop = sim.Population(size = [100, 100], loci = 3, infoFields = ["age", "migrate_to"]) | |
sim.initInfo(pop = pop, values = np.random.negative_binomial(n = 3, p = 0.4, size = 20), infoFields = "age") | |
sim.initSex(pop, maleProp = 0.5) | |
pop.setVirtualSplitter(sim.ProductSplitter(splitters = [ | |
sim.SexSplitter(), | |
sim.InfoSplitter(field = "age", cutoff = [2, 5]) | |
])) | |
pop.evolve(preOps = sim.Migrator(rate = [[2]], | |
mode = sim.BY_COUNTS, | |
subPops = [(1, 1)], | |
toSubPops = 0 | |
), | |
matingScheme = sim.RandomMating(), | |
postOps = [ | |
sim.Stat(popSize = True, numOfMales = True, vars = 'numOfMales_sp'), | |
# sim.PyEval(r"'%d/%d\t%d/%d\n' % (subPop[0]['numOfMales'], subPopSize[0], ""subPop[1]['numOfMales'], subPopSize[1])") | |
sim.PyEval("subPopSize"), | |
sim.PyOutput("\n") | |
], | |
gen = 5) | |
# solved - it would appear [1, 1] ran out of possible candidates due to | |
# poorly simulated age variable | |
import simuPOP as sim | |
import numpy as np | |
pop = sim.Population(size = [100, 100], loci = 3, infoFields = ["age", "migrate_to"]) | |
sim.initInfo(pop = pop, values = np.random.choice([1, 2, 3, 4, 5], replace = True, size = 200), infoFields = "age") | |
sim.initSex(pop, maleProp = 0.5) | |
pop.setVirtualSplitter(sim.ProductSplitter(splitters = [ | |
sim.SexSplitter(), | |
sim.InfoSplitter(field = "age", cutoff = [2, 4]) | |
])) | |
pop.evolve(preOps = [sim.Migrator(rate = [[2]], | |
mode = sim.BY_COUNTS, | |
subPops = [(1, 1)], | |
toSubPops = 0) | |
], | |
matingScheme = sim.CloneMating(subPops = sim.ALL_AVAIL, weight = -1), | |
postOps = [ | |
sim.Stat(popSize = True, numOfMales = True, vars = 'numOfMales_sp'), | |
sim.PyEval("subPopSize"), | |
sim.PyOutput("\n") | |
], | |
gen = 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment