tekka
pbf::Population Class Reference

Main class that implements simulation. More...

#include <population.hpp>

Public Member Functions

 Population (const Parameters &)
 Constructor.
void run ()
 The main loop of simulation.
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<int_fast32_t, std::discrete_distribution<int_fast32_t>>
 Alias for readability.

Private Member Functions

void reproduce ()
 Call reproduce_impl() via reproduce_lognormal() or reproduce_logistic() depending on Parameters::med_recruitment. 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. All the SubPopulation::adults are evaluated regardless of age. Currently, the breeding places are hardcoded to subpopulations 0 and 1.
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 (const int_fast32_t loc, std::vector< int_fast32_t > litter_sizes)
 Call survive_juvenile() and append survived ones to SubPopulation::juveniles. "Juveniles" are sampled from first-year individuals died in the final season.
std::vector< int_fast32_t > litter_sizes_logistic (const std::vector< ShPtrIndividual > &females, int_fast32_t popsize)
 Calculate stochastic litter sizes proportional to female weight.
std::vector< double > survive_juvenile (std::vector< int_fast32_t > &litter_sizes, std::array< std::vector< int_fast32_t >, 4 > &demography_y, const int_fast32_t sample_size)
 Evaluate and record survival of juveniles.
int_fast32_t sample_size_juvenile (int_fast32_t loc) const
 Return sample size of juveniles at location loc in current year_.
void survive (int_fast32_t season)
 Evaluate survival using death_rate(). "Adults" are sampled from individuals died in the final season.
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.
int_fast32_t destination (int_fast32_t age, int_fast32_t loc)
 Generate random number for new location.
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() based on Parameters::migration_matrices.
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.

Member Function Documentation

◆ run()

void pbf::Population::run ( )

The main loop of simulation.

  1. reproduce() includes sampling from dead juveniles.
  2. for each season:
  3. migrate()

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