tekka
pbf::Population Class Reference

Main class that implements simulation. More...

#include <population.hpp>

Public Member Functions

 Population (const Parameters &)
 Constructor.
 
void run ()
 Main iteration.
 
std::ostream & write_sample_family (std::ostream &ost) const
 Construct and write tree from SubPopulation::samples. Serial IDs are assigned to sampled individuals. IDs larger than sample size are assigned to unsampled ancestors.
 
std::ostream & write_demography (std::ostream &) const
 Write SubPopulation::demography.
 
std::ostream & write (std::ostream &) const
 Write subpopulations_ for debugging.
 

Private Types

using PairDestDist = std::pair<uint_fast32_t, std::discrete_distribution<uint_fast32_t>>
 Alias for readability.
 

Private Member Functions

void reproduce ()
 give birth to children
 
void reproduce_lognormal ()
 Reproduce according to constant lognormal distribution. Total recruitment is calculated first, and then split it.
 
void reproduce_logistic ()
 Reproduce according to population size and carrying capacity.
 
void reproduce_impl (SubPopulation &, const std::vector< uint_fast32_t > &litter_sizes)
 Append new individuals to SubPopulation::juveniles. The expected number of children for each adult is proportional to its weight. All the females are evaluated for recruitment, whereas males are stochastically chosen.
 
std::vector< uint_fast32_t > litter_sizes_logistic (const std::vector< ShPtrIndividual > &females, size_t popsize)
 Calculate stochastic litter sizes proportional to female weight.
 
void survive (int_fast32_t season)
 Evaluate survival.
 
double death_rate (const int_fast32_t age, const int_fast32_t season) const
 Finite death rate per quarter year: \( d = 1 - \exp(- M - eF) \).
 
void migrate ()
 Evaluate migration. Merge SubPopulation::juveniles to SubPopulation::adults.
 
uint_fast32_t destination (int_fast32_t age, uint_fast32_t loc)
 Generate random number for new location.
 
void sample (SubPopulation &subpops, size_t n_adults, size_t n_juveniles)
 Move individuals to SubPopulation::samples.
 
size_t sample (std::vector< ShPtrIndividual > &src, std::vector< ShPtrIndividual > &dst, size_t n)
 Implementation of sample().
 
void init_demography (int_fast32_t duration)
 Initialize SubPopulation::demography.
 
void record_demography (int_fast32_t season)
 Record current state to SubPopulation::demography.
 
std::vector< double > weights (const std::vector< ShPtrIndividual > &) const
 For male selection.
 
void propagate_params ()
 Call all the init* functions.
 
void init_migration ()
 Prepare MIGRATION_DESTINATION_.
 
void init_mortality ()
 Prepare NATURAL_MORTALITY_, FISHING_MORTALITY_, FISHING_COEF_.
 
void init_weight ()
 Prepare WEIGHT_FOR_AGE_.
 
bool is_ready () const
 Test if dependent variables are ready.
 

Private Attributes

Parameters params_
 Store the values from command line and json.
 
std::vector< double > NATURAL_MORTALITY_ {}
 elongated version of Parameters::natural_mortality
 
std::vector< double > FISHING_MORTALITY_ {}
 elongated version of Parameters::fishing_mortality
 
std::vector< double > FISHING_COEF_ {}
 elongated version of Parameters::fishing_coef
 
std::vector< double > WEIGHT_FOR_AGE_ {}
 year version of Parameters::weight_for_age
 
std::vector< std::vector< PairDestDist > > MIGRATION_DESTINATION_ {}
 Discrete distributions for migrate()
 
std::vector< SubPopulationsubpopulations_ {}
 Array of SubPopulation.
 
int_fast32_t year_ {0}
 Current time.
 
std::unique_ptr< URBG > engine_ {nullptr}
 Uniform Random Bit Generator.
 

Static Private Attributes

static constexpr int_fast32_t MAX_AGE = 80
 No individual lives longer than this.
 

Friends

std::ostream & operator<< (std::ostream &ost, const Population &pop)
 Shortcut for Population::write(ost)
 

Detailed Description

Main class that implements simulation.


The documentation for this class was generated from the following files: