Evolutionary Diversification in Anolis Lizards
patch.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 #ifndef PATCH_HPP_
6 #define PATCH_HPP_
7 
8 #include <iosfwd>
9 #include <vector>
10 #include <map>
11 #include <memory>
12 
13 namespace wtl {class sfmt19937_64;}
14 
16 namespace edal {
17 
18 class Individual;
19 
20 class Patch {
21  public:
22  using URBG = wtl::sfmt19937_64;
23 
25  Patch(unsigned int seed);
26 
28  Patch(Patch&&) noexcept;
29 
31  ~Patch();
32 
34 
37  void assign(size_t n, const Individual& founder);
38 
40 
42  void emplace_back(Individual&& ind) {members_.emplace_back(std::move(ind));}
43 
45  size_t size() const {return members_.size();}
46 
48  bool empty() const {return members_.empty();}
49 
51  std::map<Individual, size_t> summarize() const;
52 
54 
65  std::vector<Individual> mate_and_reproduce() const;
66 
74  std::vector<std::pair<unsigned, unsigned int>>
75  make_destinations(size_t n, size_t row, size_t col, size_t num_rows, size_t num_cols) const;
76 
78 
80  void viability_selection();
81 
83  private:
84 
86 
92  std::vector<double> effective_num_competitors() const;
93 
95  void change_sex_half(size_t n);
96 
98  // data member
100  std::vector<Individual> members_;
101 
102  std::unique_ptr<URBG> engine_;
103 };
104 
106 extern std::ostream& operator<< (std::ostream& ost, const Patch& patch);
107 
108 } // namespace edal
109 
110 #endif /* PATCH_HPP_ */
std::vector< Individual > mate_and_reproduce() const
All females mate with someone according to mating probability.
Definition: patch.cpp:35
sexual, diploid, additive, unlinked, diallelic
Definition: individual.hpp:125
void change_sex_half(size_t n)
Change sex of second half members.
Definition: patch.cpp:28
void viability_selection()
Some individuals die depending on Individual::survival_probability()
Definition: patch.cpp:118
size_t size() const
Definition: patch.hpp:45
std::vector< double > effective_num_competitors() const
Calculate from .
Definition: patch.cpp:105
std::vector< Individual > members_
Individuals.
Definition: patch.hpp:100
~Patch()
destructor in cpp for incomplete type
Definition: patch.hpp:20
bool empty() const
Definition: patch.hpp:48
std::vector< std::pair< unsigned, unsigned int > > make_destinations(size_t n, size_t row, size_t col, size_t num_rows, size_t num_cols) const
Change row/col with probability = Individual::MIGRATION_RATE_.
Definition: patch.cpp:91
Definition: individual.hpp:15
Definition: individual.cpp:15
void assign(size_t n, const Individual &founder)
Fill this patch with the same number of females and males.
Definition: patch.cpp:23
void emplace_back(Individual &&ind)
Add an individual to this patch.
Definition: patch.hpp:42
std::map< Individual, size_t > summarize() const
Count genotypes.
Definition: patch.cpp:136
Patch(unsigned int seed)
Construct an empty patch.
Definition: patch.cpp:17