Parallel PopGen Package
Simulation Models: Preserve and Sampling Group

Functions that control at when to flag currently segregating mutations as preserved and when to sample the mutation frequencies. More...

Classes

struct  Sim_Model::bool_off
 functor: turns sampling and preserving off (for every generation except the final one which is always sampled) More...
 
struct  Sim_Model::bool_on
 functor: turns sampling and preserving on (for every generation except the final one which is always sampled) More...
 
struct  Sim_Model::bool_pulse< Functor_default, Functor_action >
 functor: returns the result of function f_default except at generation pulse returns the result of function f_action More...
 
struct  Sim_Model::bool_piecewise< Functor_first, Functor_second >
 functor: returns the result of function f1 until generation inflection_point, then returns the result of function f2 More...
 

Detailed Description

Functions that control at when to flag currently segregating mutations as preserved and when to sample the mutation frequencies.

When the preserve function returns true for a given generation, the simulation will compact out any lost or fixed mutations that are not already flagged preserved - provided that GO_Fish::allele_trajectories::sim_constants::compact_interval > 0. (Though if compact_interval == 0, then there is no reason to employ the preserve function.) The remaining mutations will then be flagged as preserved so that compact will not remove them from the simulation.

Sampling a simulation writes out the mutation frequencies from the GPU's memory vRAM to the CPU's RAM for storage and later analysis. Sampling a simulation at a time point other than the final generation (the final generation is always sampled) will also trigger the preserve flag (and thus compact if compact_interval > 0). Thus, those mutations sampled at generation t will be preserved in all samples after generation t in order to ease frequency comparisons and track allele frequencies.


Writing your own Preserving and Sampling Functions

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

bool your_function(int generation){ ... return true/false; }

This returns true or false (preserve or not preserve, sample or do not sample) at generation generation. Adding a __host__ flag is optional, but if done, 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. If no flag added, function can be defined in a regular C/C++ source file (e.g. *.c, *.cpp). Note: run_sim is required to be in a CUDA source file to be compiled.