Skip to content

Commit

Permalink
Merge pull request #16 from rscherrer/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rscherrer committed Apr 26, 2021
2 parents 05406a8 + 40b9f88 commit adccf9b
Show file tree
Hide file tree
Showing 11 changed files with 815 additions and 608 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ The following variables are saved every `tsave` timepoint:
* `genome_freqs`: the allele frequencies for each locus within each ecotype
* `genome_hobs`: the observed heterozygosity for each locus within each ecotype
* `network_corgen`, `network_corbreed`, `network_corfreq`: respectively the pairwise correlations in genetic value, breeding value and allele frequency between the two interacting loci for each edge in all three networks (ordered by trait)
* `network_avgi`, `network_avgj`: the expected epistatic variance in average effect (define that maybe?) of the first and second interacting loci, respectively, for each edge
* `network_avgi`, `network_avgj`: the expected epistatic variance in average effect of the first and second interacting loci, respectively, for each edge. `network_avgi` corresponds to the expected effect of genetic variation at locus i on the variation in the additive effect of allele substitutions at locus j, and vice versa for `network_avgj`. This is mostly for plotting purposes, to detect genes that are expected to modify the additive effects of their interacting partners.
* `individual_ecotype`, `individual_habitat`: the ecotype and habitat of each individual
* `individual_trait`: the value of each trait for each individual
* `individual_midparent`: the midparent phenotype (i.e. the mean between maternal and paternal values) for each trait for each individual
Expand Down
30 changes: 10 additions & 20 deletions src/MetaPop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,6 @@ std::vector<Individual> MetaPop::populate(const Param &p, const GenArch &arch)

}


// Life cycle of the population

void MetaPop::cycle(const Param &p, const GenArch &arch)
{

// Dispersal
if (!isburnin) disperse(p);

// Consumption
consume(p);

// Reproduction
reproduce(p, arch);

// Survival
survive(p);

}

void MetaPop::disperse(const Param &p)
{
// Sample migrants across the population
Expand Down Expand Up @@ -470,6 +450,7 @@ void MetaPop::resetTraits(const size_t &trait, const double &x, const Param &p)
population[i].resetTrait(trait, x, p);
}
}

void MetaPop::resetTraits(const size_t &trait, const size_t &h, const double &x,
const Param &p)
{
Expand All @@ -478,9 +459,18 @@ void MetaPop::resetTraits(const size_t &trait, const size_t &h, const double &x,
population[i].resetTrait(trait, x, p);
}
}

void MetaPop::resetGenders(const bool &sex)
{
for (size_t i = 0u; i < population.size(); ++i) {
population[i].resetGender(sex);
}
}

void MetaPop::resetGenders(const size_t &h, const bool &sex)
{
for (size_t i = 0u; i < population.size(); ++i) {
if (population[i].getHabitat() == h)
population[i].resetGender(sex);
}
}
2 changes: 1 addition & 1 deletion src/MetaPop.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class MetaPop

~MetaPop() {}

void cycle(const Param&, const GenArch&);
void exitburnin();
void complete(); // complete speciation (no more reproduction allowed)
bool isextinct() const;
Expand Down Expand Up @@ -63,6 +62,7 @@ class MetaPop
void resetTraits(const size_t&, const double&, const Param&);
void resetTraits(const size_t&, const size_t&, const double&, const Param&);
void resetGenders(const bool&);
void resetGenders(const size_t&, const bool&);

private:

Expand Down
5 changes: 3 additions & 2 deletions src/Simul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ int simulate(const std::vector<std::string> &args)
if (pars.talkative) std::cout << t << '\n';

// Life cycle of the metapopulation
metapop.disperse(pars);
metapop.consume(pars);

const bool timetosave = t % pars.tsave;
const bool timetosave = t % pars.tsave == 0;

// Analyze the metapopulation if needed
if (pars.datsave && (t >= 0 || pars.burninsave) && timetosave) {
Expand All @@ -89,6 +88,8 @@ int simulate(const std::vector<std::string> &args)
std::cout << "The population went extinct at t = " << t << '\n';
break;
}

metapop.disperse(pars);
}

std::cout << "Simulation ended.\n";
Expand Down
Loading

0 comments on commit adccf9b

Please sign in to comment.