5 #ifndef INDIVIDUAL_HPP_ 6 #define INDIVIDUAL_HPP_ 15 namespace wtl {
class sfmt19937_64;}
100 constexpr
static double C0 = 1.0;
103 constexpr
static double C1 = 0.5;
130 using URBG = wtl::sfmt19937_64;
154 using Loci = std::bitset<NUM_LOCI_>;
163 const std::vector<Loci>& sperm,
171 Individual(
const std::vector<unsigned long>&);
318 static std::string
header();
421 double fitness(
const double height,
const double diameter)
const;
430 constexpr
size_t n = trait::size;
431 std::vector<double> output(n);
432 for (
size_t i=0; i<n; ++i) {
444 friend double pdf_beta(
const double height,
const double diameter);
445 friend double pdf_normal(
const double height,
const double diameter);
446 friend double pdf_exp(
const double height,
const double diameter);
454 std::pair<std::vector<Loci>, std::vector<Loci> >
genotype_;
477 return lhs.to_ulong() < rhs.to_ulong();
sexual, diploid, additive, unlinked, diallelic
Definition: individual.hpp:125
double mating_probability_debarre(const Individual &male) const
with Debarre 2012
Definition: individual.cpp:273
morphological characters
Definition: individual.hpp:23
double DIAMETER_PREFERENCE
in
Definition: individual.hpp:65
double calc_DI_analytical() const
analytical computation by Mathematica (fast but limited)
Definition: individual.cpp:135
void change_sex()
Change sex_.
Definition: individual.hpp:310
double survival_probability(const double effective_num_competitors) const
Probability of survival .
Definition: individual.cpp:239
double MORPH_COMPETITION
in
Definition: individual.hpp:77
double morphology_overlap(const Individual &other) const
Exponent of : competition on morphology.
Definition: individual.cpp:230
double TOEPAD_SELECTION
in
Definition: individual.hpp:68
friend double pdf_beta(const double height, const double diameter)
Beta distribution function for resource abundance.
Definition: individual.cpp:27
static constexpr unsigned long HALF_BITS
Genotype that produce trait value = 0.5, i.e., 00001111
Definition: individual.hpp:140
friend std::ostream & operator<<(std::ostream &ost, const Individual &ind)
put CSV on ostream
Definition: individual.cpp:348
friend double pdf_normal(const double height, const double diameter)
Distribution of tree height given diameter.
Definition: individual.cpp:52
Definition: individual.hpp:474
size_t CARRYING_CAPACITY
in
Definition: individual.hpp:56
static constexpr size_t NUM_STEPS_
Precision of numerical integration.
Definition: individual.hpp:146
double HEIGHT_PREFERENCE
in
Definition: individual.hpp:62
double effective_carrying_capacity_exp_unnormalized() const
with exponential
Definition: individual.cpp:193
double BETA_PARAM
of Beta distribution in
Definition: individual.hpp:53
double MIGRATION_RATE
Migration rate (i.e., makes the expected # of migrants)
Definition: individual.hpp:94
to calculate genetic divergence
Definition: individual.hpp:36
double MATING_SIGMA
in
Definition: individual.hpp:80
static param_type PARAM_
Parameters shared among instances.
Definition: individual.hpp:466
static std::string possible_phenotypes()
test function
Definition: individual.cpp:442
double ke_
calculated in advance
Definition: individual.hpp:463
double habitat_preference_exp(const double height, const double diameter) const
Exponent of in anolis_v2.
Definition: individual.cpp:116
double calc_DI_numerical() const
numerical computation (slow)
Definition: individual.cpp:149
double MU_LOCUS
Mutation rate per locus per generation.
Definition: individual.hpp:86
Individual()
Default constructor for original individuals.
Definition: individual.hpp:157
double preference_overlap(const Individual &other) const
Exponent of : competition on habitat preference.
Definition: individual.cpp:221
friend double pdf_exp(const double height, const double diameter)
Distribution of twig diameter given height.
Definition: individual.cpp:58
static void write_resource_abundance()
test function
Definition: individual.cpp:432
double mating_probability_TPG2013(const Individual &male) const
with Thibert-Plante and Gavrilets 2013
Definition: individual.cpp:299
double LIMB_SELECTION
in
Definition: individual.hpp:71
static std::map< std::vector< double >, double > KE_CACHE_
Store with ecological traits as keys.
Definition: individual.hpp:149
bool sex_
female=0, male=1
Definition: individual.hpp:460
Definition: individual.hpp:15
double habitat_preference_quadratic(const double height, const double diameter) const
quadratic approximation in anolis_v3
Definition: individual.cpp:123
std::vector< double > phenotype_
All traits are scaled to be between 0 and 1.
Definition: individual.hpp:457
std::ostream & operator<<(std::ostream &ost, const Individual &ind)
put CSV on ostream
Definition: individual.cpp:348
double PREF_COMPETITION
in
Definition: individual.hpp:74
std::string str_detail() const
detailed str() for testing/debugging
Definition: individual.cpp:399
mating compatibility characters
Definition: individual.hpp:31
Parameters for Individual class.
Definition: individual.hpp:47
double calc_Dxi_analytical() const
Calculate quadratic normalizer with analytical solution.
Definition: individual.cpp:156
Definition: individual.cpp:15
double AVG_NUM_OFFSPINRGS
in
Definition: individual.hpp:59
friend double integrate_square(Func &&func)
Integral over .
Definition: individual.cpp:83
static void param(const param_type &p)
Set PARAM_.
Definition: individual.hpp:333
static constexpr double C0
of Normal distribution in v2
Definition: individual.hpp:100
double effective_carrying_capacity_old_exp_unnormalized() const
with old resource distribution and exponential before normalization
Definition: individual.cpp:202
std::vector< double > intermediate_phenotypes() const
aggregation of intermediate phenotype values
Definition: individual.cpp:377
double effective_carrying_capacity_cache() const
Find in KE_CACHE_ or calculate.
Definition: individual.cpp:211
double mating_probability(const Individual &male) const
Definition: individual.cpp:248
for computational convenience
Definition: individual.hpp:39
std::vector< Loci > gametogenesis(URBG &) const
Gametogenesis with free recombination and mutation.
Definition: individual.cpp:324
static const std::vector< std::string > INTERMEDIATE_KEYS_
labels for intermediate phenotypes
Definition: individual.hpp:442
double resource_overlap(const Individual &other) const
for competition
Definition: individual.hpp:229
unsigned long MUTATION_MASK
Flag set to protect specific traits from mutations.
Definition: individual.hpp:91
static std::string possible_geographic()
test function
Definition: individual.cpp:464
static constexpr double NORMAL_SIGMA
of Normal distribution in v2
Definition: individual.hpp:97
Individual(const std::vector< Loci > &egg, const std::vector< Loci > &sperm, const bool is_male=false)
Constructor for sexual reproduction.
Definition: individual.hpp:162
std::bitset< NUM_LOCI_ > Loci
Alias for diallelic loci of a trait.
Definition: individual.hpp:154
habitat preference characters
Definition: individual.hpp:27
double fitness(const double height, const double diameter) const
Exponent of : measure adaptation to habitat.
Definition: individual.cpp:177
static const param_type & param()
Get PARAM_.
Definition: individual.hpp:335
friend double integrate_triangle(Func &&func)
Integral over and .
Definition: individual.cpp:73
static constexpr unsigned long FULL_BITS
Genotype that produce trait value = 1.0, i.e., 11111111
Definition: individual.hpp:137
static std::string header()
The header correspongs to str()
Definition: individual.cpp:356
bool operator<(const Individual &other) const
Operator required to be std::map key.
Definition: individual.hpp:313
static constexpr size_t NUM_LOCI_
The number of loci per trait.
Definition: individual.hpp:134
std::vector< double > calc_phenotype() const
calculates phenotypic values from genotype
Definition: individual.hpp:429
std::pair< std::vector< Loci >, std::vector< Loci > > genotype_
Unlinked diallelic loci with equal effects.
Definition: individual.hpp:454
wtl::sfmt19937_64 URBG
Uniform Random Number Generator.
Definition: individual.hpp:130
double effective_carrying_capacity_quad_unnormalized() const
with quadratic before normalization (v3u)
Definition: individual.cpp:184
double calc_Dxi_numerical() const
Numerical integration of quadratic .
Definition: individual.cpp:171
static constexpr double INV_NUM_LOCI_
Compile-time constant value used in init_phenotype()
Definition: individual.hpp:143
bool is_male() const
Get sex_.
Definition: individual.hpp:307
static constexpr double C1
of Normal distribution in v2
Definition: individual.hpp:103