Quetzal-CoaTL
The Coalescence Template Library
Loading...
Searching...
No Matches
quetzal::demography::HistoryBase< Space, DemographicPolicy, MemoryPolicy > Class Template Reference

#include <quetzal/demography/HistoryBase.hpp>

Detailed Description

template<typename Space, typename DemographicPolicy, typename MemoryPolicy>
class quetzal::demography::HistoryBase< Space, DemographicPolicy, MemoryPolicy >

Base class for simulating and recording spatial population history, encpasulating backward migration logic.

It makes use of the CRTP design pattern, meaning that this class has to be specialized to define History classes offering customized behaviors, like details of the demograhic algorithms (mass_based or individual_based) or storage aspects.

Template Parameters
SpaceDemes identifiers.
DemographicPolicyPolicy Used for populations dynamics simulation algorithms, see demographic_policy
MemoryPolicyPolicy used for storage and access to demographic quantities, see memory_policy

Public Types

using coord_type = Space
 
using time_type = unsigned int
 
using memory_policy = MemoryPolicy
 
using demographic_policy = DemographicPolicy
 
using value_type = typename demographic_policy::value_type
 
using flow_type = typename memory_policy::template flow_type< coord_type, time_type, value_type >
 
using pop_sizes_type = typename memory_policy::template pop_sizes_type< coord_type, time_type, value_type >
 
using discrete_distribution_type = quetzal::utils::random::DiscreteDistribution< coord_type >
 

Public Member Functions

 HistoryBase (coord_type const &x, value_type N, unsigned int nb_generations)
 Constructor initializing the demographic database.
 
auto distribution_area (time_type t) const
 Retrieve demes where N > 0 at time t.
 
auto & pop_size (coord_type const &x, time_type const &t)
 Population size at deme x at time t.
 
auto get_functor_N () const noexcept
 Read-only functor.
 
auto get_pop_size (coord_type const &x, time_type const &t)
 Read-only.
 
void set_pop_size (coord_type const &x, time_type const &t, value_type N)
 Used in derived class History to increment migrants.
 
unsigned int const & nb_generations () const
 Last time recorded in the foward-in-time database history.
 
template<typename Generator >
coord_type backward_kernel (coord_type const &x, time_type t, Generator &gen) const
 Samples a coordinate from the backward-in-time transition matrix.
 

Protected Attributes

std::unique_ptr< flow_type > m_flows
 

Constructor & Destructor Documentation

◆ HistoryBase()

template<typename Space , typename DemographicPolicy , typename MemoryPolicy >
quetzal::demography::HistoryBase< Space, DemographicPolicy, MemoryPolicy >::HistoryBase ( coord_type const &  x,
value_type  N,
unsigned int  nb_generations 
)
inline

Constructor initializing the demographic database.

Parameters
xthe coordinate of introduction
Nthe population size at coordinate x at time 0
nb_generationsthe number of generations history is supposed to last

Member Function Documentation

◆ backward_kernel()

template<typename Space , typename DemographicPolicy , typename MemoryPolicy >
template<typename Generator >
coord_type quetzal::demography::HistoryBase< Space, DemographicPolicy, MemoryPolicy >::backward_kernel ( coord_type const &  x,
time_type  t,
Generator &  gen 
) const
inline

Samples a coordinate from the backward-in-time transition matrix.

The transition matrix is computed from the demographic flows database. The returned coordinate object will basically answer the question: when an individual is found in \(x\) at time \(t\), where could it have been at time \(t-1\) ?

◆ pop_size()

template<typename Space , typename DemographicPolicy , typename MemoryPolicy >
auto & quetzal::demography::HistoryBase< Space, DemographicPolicy, MemoryPolicy >::pop_size ( coord_type const &  x,
time_type const &  t 
)
inline

Population size at deme x at time t.

Returns
a reference to the value, initialized with value_type default constructor
Remarks
operator allows for more expressive mathematical style in client code

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