Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
Patch Class Reference

Second class in the metapopulation design structure, between the Metapop and Individual classes. More...

#include <metapop.h>

+ Collaboration diagram for Patch:

Public Member Functions

 Patch ()
 
 ~Patch ()
 
Patchinit (unsigned int nbfem, unsigned int nbmal, unsigned int id)
 
void reset_counters ()
 
void reset_containers ()
 
void setNewGeneration (age_t AGE, Metapop *pop)
 Fills the patch containers corresponding to the age flags passed, for both sexes. More...
 
void setNewGeneration (age_idx AGE, Metapop *pop)
 Fills the patch container corresponding to the age class index passed, for both sexes. More...
 
void show_up ()
 
Setters
void setID (unsigned int i)
 
void set_K (unsigned int k)
 
void set_KFem (unsigned int k)
 
void set_KMal (unsigned int k)
 
void set_isExtinct (bool status)
 
void set_age (unsigned int a)
 
Getters
unsigned int getID ()
 
unsigned int get_K ()
 
unsigned int get_K (sex_t SEX)
 
unsigned int get_KFem ()
 
unsigned int get_KMal ()
 
bool get_isExtinct ()
 
unsigned int get_age ()
 
bool isEmpty ()
 
unsigned int getAdultsNumber ()
 
double getDensity (age_idx age)
 
State getter and modifier functions
unsigned int size (age_t AGE)
 Returns the size of the container of the appropriate age class(es) for both sexes. More...
 
unsigned int size (sex_t SEX, age_t AGE)
 Returns the size of the container for the appropriate sex and age classes present in the age flag. More...
 
unsigned int size (sex_t SEX, age_idx AGE)
 Returns the size of the container for the appropriate sex and age class. More...
 
unsigned int size (age_idx AGE)
 Returns the size of the container for the appropriate age class for both sexes. More...
 
Individualget (sex_t SEX, age_idx AGE, unsigned int at)
 Returns a pointer to the individual sitting at the index passed. More...
 
void set (sex_t SEX, age_idx AGE, unsigned int at, Individual *ind)
 Modifies the appropriate container with value of the pointer given. More...
 
void add (sex_t SEX, age_idx AGE, Individual *ind)
 Adds an individual to the appropriate container, increments its size, eventually resizing it. More...
 
void assign (sex_t SEX, age_idx AGE, unsigned int n)
 Assigns a new container of given size for the sex and age class passed, sets all values to NULL. More...
 
Individualremove (sex_t SEX, age_idx AGE, unsigned int at)
 Removes the individual sitting at the given index in the appropriate container. More...
 
void move (sex_t SEX, age_idx from, age_idx to, unsigned int at)
 Moves an individual from an age class to an other one. More...
 
void swap (sex_t SEX, age_idx from, age_idx to)
 Copies all elements in the 'from' age-class container to the 'to' age-class container of the same sex. More...
 
void clear (sex_t SEX, age_idx AGE)
 Sets the size of the appropriate container to zero. More...
 
void clear ()
 
void flush (sex_t SEX, age_idx AGE, Metapop *pop)
 Removes all individual pointers of the appropriate sex and age class and flush them into the recycling pool. More...
 
void flush (age_idx AGE, Metapop *pop)
 
void flush (age_t AGE, Metapop *pop)
 Removes all individual pointers of the appropriate sex and age class and flush them into the recycling pool. More...
 
void flush (Metapop *pop)
 Removes all individual pointers of all sex and age classes and flush them into the recycling pool. More...
 
void getCopy (sex_t SEX, age_idx AGE, deque< Individual * > &to)
 
void copy2patch (sex_t from_sex, sex_t to_sex, age_idx from_age, age_idx to_age, Patch *to_patch)
 
void copy2patch (sex_t SEX, age_idx AGE, Patch *patch)
 
void copy2patch (age_idx AGE, Patch *patch)
 
void copy2patch (Patch *patch)
 

Public Attributes

unsigned short nbEmigrant
 
unsigned short nbImigrant
 
unsigned short nbPhilopat
 
short nbKolonisers
 

Private Attributes

unsigned int _ID
 Patch ID is equal to its position in the metapop patch array. More...
 
unsigned int _K
 Carrying capacity for males and females. More...
 
unsigned int _KFem
 Sex specific carrying capacity. More...
 
unsigned int _KMal
 
bool _isExtinct
 Extinction flag. More...
 
unsigned int _age
 age since last extinction. More...
 
unsigned int _nb_age_class
 Number of age classes present. More...
 
unsigned int _sizes [2][3]
 Containers size counters, sex X age. More...
 
unsigned int _capacities [2][3]
 Total size of the containers, amount of allocated memory. More...
 
deque< Individual * > _containers [2][3]
 Individuals containers, sex X age. More...
 

Detailed Description

Second class in the metapopulation design structure, between the Metapop and Individual classes.

The Patch class is an abstraction of a sub-population or patch concept (also called a deme) in a metapopulation context. It contains the individual containers for the different age classes. Three main age classes are currently implemented, the offspring, post-dispersal and adult classes (see the age_t enum) which are all subdivided into male and female individuals. These containers are accessed using the interface defined here or through the Metapop class interface. The different LCEs will use these interfaces to handle the individuals. They are also responsible to change the age flag of the population (see Metapop).

The individuals are accessed using their age index value and not the age flag value (e.g., using the Patch::get() method). These indexes are defined in the age_idx enum (see type.h) and differ from the age class flag values. For instance the adults' containers have the index 2 (ADLTx = 2) whereas their age flag is 4 (ADULTS = 4). This might be confusing but it saves a lot of checks at runtime! It also allows to give a flag containing several class bits set instead of a unique index value when needed (see the Patch::size() and Metapop::size() suite of functions).

Constructor & Destructor Documentation

◆ Patch()

Patch::Patch ( )
inline
456 : _ID(0), _K(1), _KFem(1), _KMal(1), _isExtinct(0), _age(0), _nb_age_class(3),
458 { for(unsigned int i = 0; i < _nb_age_class; i++) {
459 _sizes[MAL][i] = 0;
460 _sizes[FEM][i] = 0;
461 _capacities[MAL][i] = 0;
462 _capacities[FEM][i] = 0;}
463 }
unsigned int _KMal
Definition: metapop.h:436
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:444
unsigned short nbEmigrant
Definition: metapop.h:452
unsigned int _age
age since last extinction.
Definition: metapop.h:440
unsigned int _capacities[2][3]
Total size of the containers, amount of allocated memory.
Definition: metapop.h:446
unsigned short nbPhilopat
Definition: metapop.h:452
unsigned int _KFem
Sex specific carrying capacity.
Definition: metapop.h:436
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:442
bool _isExtinct
Extinction flag.
Definition: metapop.h:438
unsigned short nbImigrant
Definition: metapop.h:452
unsigned int _ID
Patch ID is equal to its position in the metapop patch array.
Definition: metapop.h:432
short nbKolonisers
Definition: metapop.h:453
unsigned int _K
Carrying capacity for males and females.
Definition: metapop.h:434
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37

References _capacities, _nb_age_class, _sizes, FEM, and MAL.

◆ ~Patch()

Patch::~Patch ( )
121{
122//#ifdef _DEBUG_
123// message("Patch::~Patch\n");
124//#endif
125
126 for (unsigned int i = 0; i < 2; ++i)
127 for(unsigned int j = 0; j < _nb_age_class; ++j)
128 for(unsigned int k = 0; k < _sizes[i][j] ; ++k)
129 delete _containers[i][j][k];
130}
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:448

References _containers, _nb_age_class, and _sizes.

Member Function Documentation

◆ add()

void Patch::add ( sex_t  SEX,
age_idx  AGE,
Individual ind 
)
inline

Adds an individual to the appropriate container, increments its size, eventually resizing it.

Parameters
SEXthe sex class of the individual
AGEthe index of the age class
indthe pointer to the individual
550 {
551
552 if( _sizes[SEX][AGE] + 1 > _capacities[SEX][AGE] ) {
553 _containers[SEX][AGE].resize( _capacities[SEX][AGE] + (_K + 1) );
554 _capacities[SEX][AGE] += (_K + 1); //the +1 is here to avoid seg faults when K=0
555 }
556
557 _containers[SEX][AGE][ _sizes[SEX][AGE]++ ] = ind;
558 }

References _capacities, _containers, _K, and _sizes.

Referenced by copy2patch(), LCE_Breed_Selection_Disperse::do_breed(), LCE_Breed_Disperse::do_breed_disperse(), LCE_Breed_Selection::do_breed_selection_FecFitness(), LCE_Breed_Selection::do_breed_selection_OffSurvival(), LCE_Breed_Selection::do_breed_selection_WrightFisher_1sex(), LCE_Breed_Selection::do_breed_selection_WrightFisher_2sex(), TTDeletMutBitstrFH::FHread(), TTNeutralGenesFH::FHread(), TTQuantiFH::FHread(), Metapop::fillPatchFromSource(), LCE_Resize::fillPatchNoBackup(), LCE_Resize::fillPatchWithBackup(), LCE_Cross::generatePedigree(), move(), LCE_Breed_base::NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), LCE_Resize::regulateAgeClassWithBackup(), LCE_Cross::sampleAmongPop(), LCE_Cross::sampleWithinPop(), setNewGeneration(), FileServices::subSamplePatch(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_Wolbachia::wolbachia_model_2(), LCE_Breed_base::WrightFisherPopulation(), and LCE_Breed_Quanti::WrightFisherPopulation().

◆ assign()

void Patch::assign ( sex_t  SEX,
age_idx  AGE,
unsigned int  n 
)
inline

Assigns a new container of given size for the sex and age class passed, sets all values to NULL.

562 { _containers[SEX][AGE].assign(n,0);
563 _sizes[SEX][AGE] = 0;
564 _capacities[SEX][AGE] = n;
565 }

References _capacities, _containers, and _sizes.

Referenced by TTNeutralGenesSH::setHs().

+ Here is the caller graph for this function:

◆ clear() [1/2]

void Patch::clear ( )
inline
633{ for(int i = 0; i < 3; i++) {_sizes[0][i] = 0;_sizes[1][i] = 0;}}

References _sizes.

Referenced by swap().

+ Here is the caller graph for this function:

◆ clear() [2/2]

void Patch::clear ( sex_t  SEX,
age_idx  AGE 
)
inline

Sets the size of the appropriate container to zero.

Note: no memory operation is performed, the capacity of the container is thus not affected. The individual pointers are not flushed to the recycling pool, they will be overwritten by subsequent operations. It is thus a good idea to consider using Patch::flush to be sure no pointers remained in the container.

See also
flush()
Parameters
SEXthe sex class
AGEthe index of the age class
632{ _sizes[SEX][AGE] = 0;}

References _sizes.

Referenced by LCE_Resize::buildNewPatchArrayWithBackup(), LCE_Resize::execute(), FileServices::getSampledPop(), and LCE_Resize::removeDesignatedPatch().

+ Here is the caller graph for this function:

◆ copy2patch() [1/4]

void Patch::copy2patch ( age_idx  AGE,
Patch patch 
)
inline
702 {
703 copy2patch(FEM, AGE, patch);
704 copy2patch(MAL, AGE, patch);
705 }
void copy2patch(sex_t from_sex, sex_t to_sex, age_idx from_age, age_idx to_age, Patch *to_patch)
Definition: metapop.h:689

References copy2patch(), FEM, and MAL.

◆ copy2patch() [2/4]

void Patch::copy2patch ( Patch patch)
inline
708 {
709 for (unsigned int i = 0; i < _nb_age_class; ++i){
710 copy2patch(FEM, static_cast<age_idx> (i), patch);
711 copy2patch(MAL, static_cast<age_idx> (i), patch);
712 }
713 }
age_idx
Array index of the age classes in the patch sizes and containers arrays.
Definition: types.h:41

References _nb_age_class, copy2patch(), FEM, and MAL.

◆ copy2patch() [3/4]

void Patch::copy2patch ( sex_t  from_sex,
sex_t  to_sex,
age_idx  from_age,
age_idx  to_age,
Patch to_patch 
)
inline
690 {
691 for (unsigned int i = 0; i < _sizes[from_sex][from_age]; ++i)
692 to_patch->add(to_sex, to_age, _containers[from_sex][from_age][i] );
693 }
void add(sex_t SEX, age_idx AGE, Individual *ind)
Adds an individual to the appropriate container, increments its size, eventually resizing it.
Definition: metapop.h:549

References _containers, _sizes, and add().

Referenced by LCE_Resize::buildNewPatchArrayWithBackup(), copy2patch(), and LCE_Resize::removeDesignatedPatch().

+ Here is the caller graph for this function:

◆ copy2patch() [4/4]

void Patch::copy2patch ( sex_t  SEX,
age_idx  AGE,
Patch patch 
)
inline
696 {
697 for (unsigned int i = 0; i < _sizes[SEX][AGE]; ++i)
698 patch->add(SEX, AGE, get(SEX, AGE, i) );
699 }
Individual * get(sex_t SEX, age_idx AGE, unsigned int at)
Returns a pointer to the individual sitting at the index passed.
Definition: metapop.h:532

References _sizes, add(), and get().

◆ flush() [1/4]

void Patch::flush ( age_idx  AGE,
Metapop pop 
)
inline
653 { flush(FEM, AGE, pop); flush(MAL, AGE, pop); }
void flush(sex_t SEX, age_idx AGE, Metapop *pop)
Removes all individual pointers of the appropriate sex and age class and flush them into the recyclin...
Definition: metapop.h:643

References FEM, flush(), and MAL.

◆ flush() [2/4]

void Patch::flush ( age_t  AGE,
Metapop pop 
)
inline

Removes all individual pointers of the appropriate sex and age class and flush them into the recycling pool.

Parameters
AGEan unsigned int containing the flags of the age classes to flush
popthe pointer to the metapop for access to the recycling pool
See also
flush()
661 {
662 unsigned int mask = 1;
663
664 for(unsigned int i = 0; i < _nb_age_class; i++) {
665 if( (mask & AGE) != 0) {
666 flush(MAL, static_cast<age_idx>(i), pop);
667 flush(FEM, static_cast<age_idx>(i), pop);
668 }
669 mask <<= 1;
670 }
671 }

References _nb_age_class, FEM, flush(), and MAL.

◆ flush() [3/4]

void Patch::flush ( Metapop pop)
inline

Removes all individual pointers of all sex and age classes and flush them into the recycling pool.

675 {
676 for(unsigned int i = 0; i < _nb_age_class; i++) {
677 flush(MAL, static_cast<age_idx>(i), pop);
678 flush(FEM, static_cast<age_idx>(i), pop);
679 }
680 }

References _nb_age_class, FEM, flush(), and MAL.

◆ flush() [4/4]

void Patch::flush ( sex_t  SEX,
age_idx  AGE,
Metapop pop 
)
inline

Removes all individual pointers of the appropriate sex and age class and flush them into the recycling pool.

Container sizes are reset to null values. Note: not memory operation is performed, the total amount of memory allocated is left untouched.

Parameters
SEXthe sex class of the individual
AGEthe index of the age class
popthe pointer to the metapop for access to the recycling pool
644 {
645 for (unsigned int i = 0; i < _sizes[SEX][AGE]; ++i) {
646 pop->recycle(_containers[SEX][AGE][i]);
647 _containers[SEX][AGE][i] = 0;
648 }
649 _sizes[SEX][AGE] = 0;
650 }
void recycle(Individual *ind)
Put an individual in the recycling pool.
Definition: indfactory.h:62

References _containers, _sizes, and IndFactory::recycle().

Referenced by LCE_Breed_Selection_Disperse::breed_selection_disperse(), LCE_Breed_base::checkCloning(), LCE_Breed_base::checkSelfing(), LCE_Breed_Disperse::do_breed_disperse(), LCE_Patch_Extinction::do_flush(), LCE_Aging::execute(), flush(), LCE_Disperse_base::reset_counters(), and setNewGeneration().

+ Here is the caller graph for this function:

◆ get()

Individual * Patch::get ( sex_t  SEX,
age_idx  AGE,
unsigned int  at 
)
inline

Returns a pointer to the individual sitting at the index passed.

Note: the get operations are unchecked! It's up to the user to check for overflows.

Parameters
SEXthe sex class of the individual
AGEthe index of the age class
atthe index of the individual in the container
533 { return _containers[SEX][AGE][at]; }

References _containers.

Referenced by LCE_Selection_base::addPhenotypicSD(), copy2patch(), TTBDMI_SH::countAllele_diplo(), TTBDMI_SH::countAllele_haplo(), MPFileHandler::createAndPrintSample(), LCE_Breed_Selection::do_breed_selection_FecFitness(), LCE_Breed_Selection::do_breed_selection_OffSurvival(), LCE_Breed_Selection::do_breed_selection_WrightFisher_1sex(), LCE_Breed_Selection::do_breed_selection_WrightFisher_2sex(), LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), TTDeletMutBitstrFH::FHwrite(), TTQFreqExtractor::FHwrite(), Metapop::fillPatchFromSource(), LCE_Resize::fillPatchWithBackup(), LCE_Disperse_EvolDisp::fixdisp(), LCE_Breed_base::fullMonoginy(), LCE_Breed_base::fullPolyginy(), LCE_Breed_base::fullPolyginy_manyMales(), Metapop::get(), LCE_Breed_Disperse::get_parent(), TTNeutralGenesSH::getDxyPerPatch(), LCE_Selection_base::getMaxPatchFitness(), MPStatHandler::getMeanAssignedFecundity(), TTDispersalSH::getMeanDispRate(), TTDispersalSH::getMeanDispRateInPatch(), TTDeletMutBitstrSH::getMeanFecWithPatchMate(), TTWolbachiaSH::getMeanFemaleInfection_perPatch(), TTDispersalSH::getMeanFemDispRate(), LCE_Selection_base::getMeanFitness(), TTDispersalSH::getMeanMalDispRate(), TTWolbachiaSH::getMeanMaleInfection_perPatch(), MPStatHandler::getMeanMatings(), TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgInfection(), TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch(), LCE_Selection_base::getMeanPatchFitness(), TTDispersalSH::getOffsprgMeanDispRate(), TTDeletMutBitstrSH::getPatchLoad(), TTQuantiSH::getSNPalleleFreqInPatch(), TTQuantiSH::getVaNoDominance(), TTQuantiSH::getVaWithDominance(), LCE_Breed_Wolbachia::hasInfectedFemale(), LCE_Breed_Wolbachia::inoculate_wolbachia(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Breed_base::NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), LCE_Breed_base::partialMonoginy(), LCE_Breed_base::partialSelfing(), LCE_SelectionFH::print(), TTQuantiFH::print(), TTQuantiFH::print_PLINK_FAM(), TTNeutralGenesFH::print_PLINK_PED(), TTQuantiFH::print_PLINK_PED(), MPFileHandler::printNoSample(), LCE_Breed_base::random_hermaphrodite(), LCE_Breed_base::RandomMating(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Resize::regulateAgeClassWithBackup(), LCE_Cross::sampleAmongPop(), TTNeutralGenesSH::setAdults_Theta(), TTNeutralGenesSH::setAlleleTables(), TTNeutralGenesSH::setCoaMatrix(), LCE_SelectionSH::setDataTable(), TTDeletMutBitstrSH::setDeletStats(), TTNeutralGenesSH::setHeteroTable(), TTNeutralGenesSH::setHo(), TTNeutralGenesSH::setHo2(), LCE_QuantiModifier::setIndPhenotype(), LCE_Breed_Quanti::setIndPhenotype(), TTWolbachiaSH::setInfectionStats(), MPStatHandler::setKinship(), TTDeletMutBitstrSH::setMeanViability(), MPStatHandler::setPedegreeCount(), MPStatHandler::setReproductiveStats(), LCE_Breed_Selection::setReproScaledFitness_sum(), TTNeutralGenesSH::setSibStats(), TTDeletMutBitstrSH::setViability(), store_quanti_trait_values(), FileServices::subSamplePatch(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_Wolbachia::wolbachia_model_2(), LCE_Breed_base::WrightFisherPopulation(), LCE_Breed_Quanti::WrightFisherPopulation(), TTBDMI_FH::write_diplo(), TTBDMI_FH::write_haplo(), TTNeutralGenesFH::write_patch_FSTAT(), TTNeutralGenesFH::write_patch_GENEPOP(), and TTNeutralGenesFH::write_patch_TAB().

◆ get_age()

unsigned int Patch::get_age ( )
inline
485{return _age;}

References _age.

Referenced by LCE_Aging::execute(), MPStatHandler::getMeanPatchAge(), and MPStatHandler::getPatchAge().

+ Here is the caller graph for this function:

◆ get_isExtinct()

◆ get_K() [1/2]

◆ get_K() [2/2]

unsigned int Patch::get_K ( sex_t  SEX)
inline
480{return (SEX ? _KFem : _KMal);}

References _KFem, and _KMal.

◆ get_KFem()

unsigned int Patch::get_KFem ( )
inline

◆ get_KMal()

unsigned int Patch::get_KMal ( )
inline

◆ getAdultsNumber()

unsigned int Patch::getAdultsNumber ( )
inline
487{return size(ADLTx);}
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:496
@ ADLTx
Definition: types.h:42

References ADLTx, and size().

◆ getCopy()

void Patch::getCopy ( sex_t  SEX,
age_idx  AGE,
deque< Individual * > &  to 
)
inline
683 {
684 for (unsigned int i = 0; i < _sizes[SEX][AGE]; ++i) {
685 to.push_back(_containers[SEX][AGE][i]);
686 }
687 }

References _containers, and _sizes.

Referenced by LCE_Cross::execute().

+ Here is the caller graph for this function:

◆ getDensity()

double Patch::getDensity ( age_idx  age)
inline
488{return (double)size(age)/_K;}

References _K, and size().

Referenced by MPStatHandler::getMeanPatchDensity(), and MPStatHandler::getMeanPatchDensityVariance().

+ Here is the caller graph for this function:

◆ getID()

◆ init()

Patch * Patch::init ( unsigned int  nbfem,
unsigned int  nbmal,
unsigned int  id 
)
39{
40 _ID = id;
41 _KFem = nbfem;
42 _KMal = nbmal;
43 _K = _KFem + _KMal;
44 _isExtinct = false;
45 _age = 0;
46
48
50
51 return this;
52}
void reset_containers()
Definition: patch.cc:66
void reset_counters()
Definition: patch.cc:56

References _age, _ID, _isExtinct, _K, _KFem, _KMal, reset_containers(), and reset_counters().

Referenced by LCE_Resize::execute().

+ Here is the caller graph for this function:

◆ isEmpty()

bool Patch::isEmpty ( )
inline
486{return (size(ALL) == 0);}
#define ALL
All ages age class flag.
Definition: types.h:56

References ALL, and size().

Referenced by MPStatHandler::setObsrvdExtinctionRate().

+ Here is the caller graph for this function:

◆ move()

void Patch::move ( sex_t  SEX,
age_idx  from,
age_idx  to,
unsigned int  at 
)
inline

Moves an individual from an age class to an other one.

Note: both containers are transformed by this operation. The 'from' container size is reduced by one while the 'to' container size is increased by one.

Parameters
SEXthe sex class of the individual
fromthe original age class of the individual
tothe destination age class of the individual
atthe index of the individual in the container
597 {
598 add( SEX, to, _containers[SEX][from][at] );
599 remove( SEX, from, at );
600 }
Individual * remove(sex_t SEX, age_idx AGE, unsigned int at)
Removes the individual sitting at the given index in the appropriate container.
Definition: metapop.h:573

References _containers, add(), and remove().

Referenced by LCE_Disperse_EvolDisp::evoldisp(), LCE_Aging::execute(), and LCE_Disperse_EvolDisp::fixdisp().

+ Here is the caller graph for this function:

◆ remove()

Individual * Patch::remove ( sex_t  SEX,
age_idx  AGE,
unsigned int  at 
)
inline

Removes the individual sitting at the given index in the appropriate container.

Parameters
SEXthe sex class of the individual
AGEthe index of the age class
atthe index of the individual in the container
Returns
pointer to the individual that has been removed
574 {
575 if(_sizes[SEX][AGE] == 0) {
576 error("Patch::remove:: container already empty!!");
577 return NULL;
578 }
579 unsigned int last = _sizes[SEX][AGE] - 1;
580 Individual* ind = _containers[SEX][AGE][at];
581 _containers[SEX][AGE][at] = _containers[SEX][AGE][ last ];
582 _containers[SEX][AGE][ last ] = 0;
583 _sizes[SEX][AGE]--;
584 return ind;
585 }
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
int error(const char *str,...)
Definition: output.cc:77

References _containers, _sizes, and error().

Referenced by LCE_Patch_Extinction::do_remove(), LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Resize::fillPatchWithBackup(), LCE_Disperse_EvolDisp::fixdisp(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), move(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Resize::regulateAgeClassWithBackup(), and LCE_Regulation::regulatePatch().

+ Here is the caller graph for this function:

◆ reset_containers()

void Patch::reset_containers ( )
67{
68 for(unsigned int i=0; i < _nb_age_class; i++) {
69 _containers[MAL][i].assign( _KMal, 0 );
70 _containers[FEM][i].assign( _KFem, 0 );
71 _sizes[MAL][i] = 0;
72 _sizes[FEM][i] = 0;
73 _capacities[MAL][i] = _KMal;
74 _capacities[FEM][i] = _KFem;
75 }
76}

References _capacities, _containers, _KFem, _KMal, _nb_age_class, _sizes, FEM, and MAL.

Referenced by init().

+ Here is the caller graph for this function:

◆ reset_counters()

void Patch::reset_counters ( )
57{
58 nbEmigrant = 0;
59 nbImigrant = 0;
60 nbPhilopat = 0;
61 nbKolonisers = 0;
62}

References nbEmigrant, nbImigrant, nbKolonisers, and nbPhilopat.

Referenced by init(), and LCE_Disperse_base::reset_counters().

+ Here is the caller graph for this function:

◆ set()

void Patch::set ( sex_t  SEX,
age_idx  AGE,
unsigned int  at,
Individual ind 
)
inline

Modifies the appropriate container with value of the pointer given.

Parameters
SEXthe sex class of the individual
AGEthe index of the age class
atthe index of the individual in the container
indthe pointer to the individual
542 { _containers[SEX][AGE][at] = ind; }

References _containers.

◆ set_age()

void Patch::set_age ( unsigned int  a)
inline
473{_age = a;}

References _age.

Referenced by LCE_Patch_Extinction::do_flush(), and LCE_Aging::execute().

+ Here is the caller graph for this function:

◆ set_isExtinct()

void Patch::set_isExtinct ( bool  status)
inline
472{_isExtinct = status;}

References _isExtinct.

Referenced by LCE_Patch_Extinction::do_flush(), and LCE_Aging::execute().

+ Here is the caller graph for this function:

◆ set_K()

void Patch::set_K ( unsigned int  k)
inline
469{_K = k;}

References _K.

Referenced by FileServices::getSampledPop().

+ Here is the caller graph for this function:

◆ set_KFem()

void Patch::set_KFem ( unsigned int  k)
inline
470{_KFem = k;}

References _KFem.

Referenced by FileServices::getSampledPop(), and LCE_Resize::updatePatchCapacities().

+ Here is the caller graph for this function:

◆ set_KMal()

void Patch::set_KMal ( unsigned int  k)
inline
471{_KMal = k;}

References _KMal.

Referenced by FileServices::getSampledPop(), and LCE_Resize::updatePatchCapacities().

+ Here is the caller graph for this function:

◆ setID()

void Patch::setID ( unsigned int  i)
inline
468{_ID = i;}

References _ID.

Referenced by FileServices::getSampledPop().

+ Here is the caller graph for this function:

◆ setNewGeneration() [1/2]

void Patch::setNewGeneration ( age_idx  AGE,
Metapop pop 
)

Fills the patch container corresponding to the age class index passed, for both sexes.

93{
94 Individual *new_ind;
95
96 //--------------------------------------------------------------------
97 //if too much females in the Patch, flush them into the RecyclingPOOL
98 if(size(FEM, AGE) > 0) flush(FEM, AGE, pop);
99
100 for(unsigned int i = 0; i < _KFem; i++) {
101 new_ind = pop->makeNewIndividual(0,0,FEM,_ID);
102 new_ind->create_first_gen();
103 add(FEM, AGE, new_ind);
104 }
105
106 //--------------------------------------------------------------------
107 //males: same as for the females....
108 if(size(MAL, AGE) > 0) flush(MAL, AGE, pop);
109
110 for(unsigned int i = 0; i < _KMal; i++) {
111 new_ind = pop->makeNewIndividual(0,0,MAL,_ID);
112 new_ind->create_first_gen();
113 add(MAL, AGE, new_ind);
114 }
115
116}
Individual * makeNewIndividual(Individual *mother, Individual *father, sex_t sex, unsigned short homepatch)
Creates an individual with pointers to parents, sex and home ID set but no genetic data.
Definition: indfactory.cc:152
Individual * create_first_gen()
Creates an individual's genotypes and phenotypes for first generation.
Definition: individual.h:348

References _ID, _KFem, _KMal, add(), Individual::create_first_gen(), FEM, flush(), IndFactory::makeNewIndividual(), MAL, and size().

◆ setNewGeneration() [2/2]

void Patch::setNewGeneration ( age_t  AGE,
Metapop pop 
)

Fills the patch containers corresponding to the age flags passed, for both sexes.

81{
82 unsigned int mask = 1;
83
84 for(unsigned int i = 0; i < _nb_age_class; i++) {
85 if( (mask & AGE) != 0) setNewGeneration(static_cast<age_idx>(i), pop);
86 mask<<=1;
87 }
88}
void setNewGeneration(age_t AGE, Metapop *pop)
Fills the patch containers corresponding to the age flags passed, for both sexes.
Definition: patch.cc:80

References _nb_age_class, and setNewGeneration().

Referenced by setNewGeneration().

+ Here is the caller graph for this function:

◆ show_up()

void Patch::show_up ( )
135{
136 message("Patch %i:\n age: %i; K: %i, K_fem: %i; K_mal: %i\n",_ID, _age, _K, _KFem, _KMal);
137 for(unsigned int j = 0; j < _nb_age_class; ++j)
138 message(" age class %i: females: %i; males: %i\n", j, _sizes[FEM][j], _sizes[MAL][j]);
139}
void message(const char *message,...)
Definition: output.cc:40

References _age, _ID, _K, _KFem, _KMal, _nb_age_class, _sizes, FEM, MAL, and message().

◆ size() [1/4]

unsigned int Patch::size ( age_idx  AGE)
inline

Returns the size of the container for the appropriate age class for both sexes.

Parameters
AGEthe index of the age class
524 { return _sizes[0][AGE] + _sizes[1][AGE]; }

References _sizes.

◆ size() [2/4]

unsigned int Patch::size ( age_t  AGE)
inline

Returns the size of the container of the appropriate age class(es) for both sexes.

Parameters
AGEthe flag value of the age class
497 { return size(MAL,AGE) + size(FEM,AGE); }

References FEM, MAL, and size().

Referenced by LCE_Selection_base::addPhenotypicSD(), LCE_Breed_Selection_Disperse::breed_selection_disperse(), LCE_Breed_base::checkCloning(), LCE_Breed_base::checkNoSelfing(), LCE_Breed_base::checkPolygyny(), LCE_Breed_base::checkSelfing(), LCE_Breed_Disperse::conditionalLogisticGrowth(), LCE_Breed_Disperse::conditionalStochasticLogisticGrowth(), TTBDMI_SH::countAllele_diplo(), TTBDMI_SH::countAllele_haplo(), MPFileHandler::createAndPrintSample(), LCE_Breed_Disperse::do_breed_disperse(), LCE_Breed_Selection::do_breed_selection_FecFitness(), LCE_Breed_Selection::do_breed_selection_OffSurvival(), LCE_Breed_Selection::do_breed_selection_WrightFisher_1sex(), LCE_Breed_Selection::do_breed_selection_WrightFisher_2sex(), LCE_Patch_Extinction::do_remove(), LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Disperse_EvolDisp::execute(), LCE_Aging::execute(), LCE_Patch_Extinction::execute(), LCE_Cross::execute(), LCE_SelectionFH::FHwrite(), TTDeletMutBitstrFH::FHwrite(), TTQFreqExtractor::FHwrite(), Metapop::fillPatchFromSource(), LCE_Resize::fillPatchNoBackup(), LCE_Resize::fillPatchWithBackup(), LCE_Disperse_EvolDisp::fixdisp(), LCE_Breed_base::fullMonoginy(), LCE_Breed_base::fullPolyginy_manyMales(), LCE_Patch_Extinction::get_harvest_size(), LCE_Breed_Disperse::get_parent(), getAdultsNumber(), getDensity(), TTNeutralGenesSH::getDxyPerPatch(), TTDeletMutBitstrSH::getLoad(), LCE_Selection_base::getMaxPatchFitness(), MPStatHandler::getMeanAssignedFecundity(), TTDispersalSH::getMeanDispRate(), TTDispersalSH::getMeanDispRateInPatch(), TTDeletMutBitstrSH::getMeanFecWithPatchMate(), TTWolbachiaSH::getMeanFemaleInfection_perPatch(), TTDispersalSH::getMeanFemDispRate(), LCE_Selection_base::getMeanFitness(), TTDispersalSH::getMeanMalDispRate(), TTWolbachiaSH::getMeanMaleInfection_perPatch(), MPStatHandler::getMeanMatings(), TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgInfection(), TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch(), LCE_Selection_base::getMeanPatchFitness(), LCE_SelectionSH::getMeanPatchFitness(), TTDispersalSH::getOffsprgMeanDispRate(), TTDeletMutBitstrSH::getPatchLoad(), TTQuantiSH::getSNPalleleFreqInPatch(), TTQuantiSH::getVaNoDominance(), LCE_SelectionSH::getVarPatchFitness(), TTQuantiSH::getVaWithDominance(), LCE_Breed_Wolbachia::hasInfectedFemale(), isEmpty(), LCE_Breed_Disperse::logisticGrowth(), LCE_Breed_Disperse::mate_selfing(), LCE_Disperse_ConstDisp::Migrate(), LCE_Disperse_ConstDisp::MigratePatch(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Disperse_ConstDisp::MigratePatchByNumber(), LCE_Breed_base::NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), LCE_Breed_Disperse::numFemOffspring(), LCE_Breed_Disperse::numMalOffspring_random(), LCE_Breed_base::partialMonoginy(), LCE_Breed_base::partialSelfing(), LCE_SelectionFH::print(), TTQuantiFH::print(), TTQuantiFH::print_PLINK_FAM(), TTNeutralGenesFH::print_PLINK_PED(), TTQuantiFH::print_PLINK_PED(), MPFileHandler::printNoSample(), LCE_Breed_base::random_hermaphrodite(), LCE_Breed_base::RandomMating(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Resize::regulateAgeClassWithBackup(), LCE_Regulation::regulatePatch(), LCE_Cross::sampleAmongPop(), LCE_Cross::sampleWithinPop(), LCE_Selection_base::set_std_rate_of_change(), TTNeutralGenesSH::setAdults_Theta(), TTNeutralGenesSH::setAlleleTables(), TTNeutralGenesSH::setCoaMatrix(), LCE_SelectionSH::setDataTable(), TTQuantiSH::setDataTables(), TTDeletMutBitstrSH::setDeletStats(), TTDeletMutBitstrSH::setFst(), TTNeutralGenesSH::setHeteroTable(), TTNeutralGenesSH::setHeterozygosity(), TTNeutralGenesSH::setHo(), TTNeutralGenesSH::setHo2(), TTNeutralGenesSH::setHs(), TTNeutralGenesSH::setHs2(), LCE_QuantiModifier::setIndPhenotype(), LCE_Breed_Quanti::setIndPhenotype(), TTWolbachiaSH::setInfectionStats(), MPStatHandler::setKinship(), TTDeletMutBitstrSH::setMeanViability(), setNewGeneration(), MPStatHandler::setPedegreeCount(), MPStatHandler::setReproductiveStats(), TTNeutralGenesSH::setSibStats(), TTBDMI_SH::setStats(), TTDeletMutBitstrSH::setViability(), size(), Metapop::size(), FileServices::subSamplePatch(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_Wolbachia::wolbachia_model_2(), LCE_Breed_base::WrightFisherPopulation(), LCE_Breed_Quanti::WrightFisherPopulation(), TTBDMI_FH::write_diplo(), TTBDMI_FH::write_haplo(), TTNeutralGenesFH::write_patch_FSTAT(), TTNeutralGenesFH::write_patch_GENEPOP(), and TTNeutralGenesFH::write_patch_TAB().

◆ size() [3/4]

unsigned int Patch::size ( sex_t  SEX,
age_idx  AGE 
)
inline

Returns the size of the container for the appropriate sex and age class.

Parameters
SEXthe sex class
AGEthe index of the age class
518 { return _sizes[SEX][AGE]; }

References _sizes.

◆ size() [4/4]

unsigned int Patch::size ( sex_t  SEX,
age_t  AGE 
)
inline

Returns the size of the container for the appropriate sex and age classes present in the age flag.

Parameters
SEXthe sex class
AGEthe flag value of the age class
504 {
505 unsigned int mask = 1, s = 0;
506 for(unsigned int i = 0; i < _nb_age_class; i++) {
507 if( (mask & AGE) != 0) s += _sizes[SEX][i];
508 mask <<= 1;
509 }
510 return s;
511 }

References _nb_age_class, and _sizes.

◆ swap()

void Patch::swap ( sex_t  SEX,
age_idx  from,
age_idx  to 
)
inline

Copies all elements in the 'from' age-class container to the 'to' age-class container of the same sex.

The previous elements of the 'to' container are overwritten, it is thus worth considering using flush() before swaping to avoid memory leaks! The size of the 'from' container is set to 0.

Parameters
SEXthe sex class of the individual
fromthe original age class of the individual
tothe destination age class of the individual
610 {
611 if( _sizes[SEX][from] > _capacities[SEX][to] ) {
612 _containers[SEX][to].resize( _sizes[SEX][from] );
613 _capacities[SEX][to] = _sizes[SEX][from];
614 }
615
616 for(unsigned int i = 0; i < _sizes[SEX][from]; ++i)
617 _containers[SEX][to][i] = _containers[SEX][from][i];
618
619 _sizes[SEX][to] = _sizes[SEX][from];
620 clear(SEX, from);
621 }
void clear()
Definition: metapop.h:633

References _capacities, _containers, _sizes, and clear().

Referenced by LCE_Disperse_base::swapPostDisp().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _age

unsigned int Patch::_age
private

age since last extinction.

Referenced by get_age(), init(), set_age(), and show_up().

◆ _capacities

unsigned int Patch::_capacities[2][3]
private

Total size of the containers, amount of allocated memory.

Referenced by add(), assign(), Patch(), reset_containers(), and swap().

◆ _containers

deque<Individual*> Patch::_containers[2][3]
private

Individuals containers, sex X age.

Referenced by add(), assign(), copy2patch(), flush(), get(), getCopy(), move(), remove(), reset_containers(), set(), swap(), and ~Patch().

◆ _ID

unsigned int Patch::_ID
private

Patch ID is equal to its position in the metapop patch array.

Referenced by getID(), init(), setID(), setNewGeneration(), and show_up().

◆ _isExtinct

bool Patch::_isExtinct
private

Extinction flag.

Referenced by get_isExtinct(), init(), and set_isExtinct().

◆ _K

unsigned int Patch::_K
private

Carrying capacity for males and females.

Referenced by add(), get_K(), getDensity(), init(), set_K(), and show_up().

◆ _KFem

unsigned int Patch::_KFem
private

Sex specific carrying capacity.

Referenced by get_K(), get_KFem(), init(), reset_containers(), set_KFem(), setNewGeneration(), and show_up().

◆ _KMal

unsigned int Patch::_KMal
private

◆ _nb_age_class

unsigned int Patch::_nb_age_class
private

Number of age classes present.

Referenced by copy2patch(), flush(), Patch(), reset_containers(), setNewGeneration(), show_up(), size(), and ~Patch().

◆ _sizes

unsigned int Patch::_sizes[2][3]
private

Containers size counters, sex X age.

Referenced by add(), assign(), clear(), copy2patch(), flush(), getCopy(), Patch(), remove(), reset_containers(), show_up(), size(), swap(), and ~Patch().

◆ nbEmigrant

◆ nbImigrant

◆ nbKolonisers

◆ nbPhilopat


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

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR