Parallel PopGen Package
Simulation Models: Migration Group

Functions that model migration rates over time (conservative model of migration) More...

Classes

struct  Sim_Model::migration_constant_equal
 functor: migration flows at rate m from pop i to pop j =/= i and 1-(num_pop-1)*m for i == j More...
 
struct  Sim_Model::migration_constant_directional< Functor_m1 >
 functor: migration flows at rate m from pop1 to pop2 and function rest for all other migration rates More...
 
struct  Sim_Model::migration_piecewise< Functor_m1, Functor_m2 >
 functor: migration function changes from m1 to m2 at generation inflection_point More...
 

Detailed Description

Functions that model migration rates over time (conservative model of migration)

In the conservative model of migration, migration rate from population i to population j is expressed as the fraction of population j originally from i:

e.g. in a 2 population model, a migration rate of mij = 0.1 ==> 10% of population j is originally from population i
and the frequency, \(x_{mig,j}\), in the next generation of an allele is \(x_{mig,j} = 0.1*x_i + 0.9*x_j\)

Thus, in general, the following must be true: \(\sum_{i=1}^n\) mij = 1 (program will throw error elsewise). However the sum of migration rates FROM a population need not sum to anything in particular. This is also the set of functions that are used to specify a single population splitting into (two or more) populations.

Writing your own Migration functions

These can be functions or functors (or soon, with C++11 support, lambdas). However, the migration function must be of the form:

__host__ __device__ float your_function(int population_FROM, int population_TO, int generation){ ... return migration_rate; }

This returns the rate of migration from population population_FROM to population population_TO at generation generation. The __host__ and __device__ flags are to ensure the nvcc compiler knows the function must be compiled for both the host (CPU) and device (GPU). Because of these flags, the function must be defined in CUDA source file (*.cu) or declared/defined header file (*.h, *.hpp, *.cuh, etc...) which is included in a CUDA source file. Since this code will be compiled on the GPU, do not use dynamically allocated arrays in your function (e.g. float * f = new float[5]) unless you know CUDA. And even then avoid them as they will slow the code down (parameters have to be pulled from the GPU's global memory (vRAM), which is slow). Statically allocated arrays (e.g. float f[5]) are fine.