Nemo  2.3.46
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 ( )
inline

References _nb_age_class, FEM, and MAL.

448  : _ID(0), _K(1), _KFem(1), _KMal(1), _isExtinct(0), _age(0), _nb_age_class(3)
449  { for(unsigned int i = 0; i < _nb_age_class; i++) {
450  _sizes[MAL][i] = 0;
451  _sizes[FEM][i] = 0;
452  _capacities[MAL][i] = 0;
453  _capacities[FEM][i] = 0;}
454  }
unsigned int _ID
Patch ID is equal to its position in the metapop patch array.
Definition: metapop.h:424
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:434
unsigned int _age
age since last extinction.
Definition: metapop.h:432
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
unsigned int _KFem
Sex specific carrying capacity.
Definition: metapop.h:428
unsigned int _KMal
Definition: metapop.h:428
unsigned int _K
Carrying capacity for males and females.
Definition: metapop.h:426
unsigned int _capacities[2][3]
Total size of the containers, amount of allocated memory.
Definition: metapop.h:438
Definition: types.h:37
bool _isExtinct
Extinction flag.
Definition: metapop.h:430
Definition: types.h:37
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 }
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:434
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440

Member Function Documentation

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

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::execute(), TTNeutralGenesFH::FHread(), TTDeletMutBitstrFH::FHread(), Metapop::fillPatchFromSource(), LCE_Resize::fillPatchNoBackup(), LCE_Resize::fillPatchWithBackup(), LCE_Cross::generatePedigree(), move(), LCE_Resize::regulateAgeClassWithBackup(), LCE_Cross::sampleAmongPop(), LCE_Cross::sampleWithinPop(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().

541  {
542 
543  if( _sizes[SEX][AGE] + 1 > _capacities[SEX][AGE] ) {
544  _containers[SEX][AGE].resize( _capacities[SEX][AGE] + (_K + 1) );
545  _capacities[SEX][AGE] += (_K + 1); //the +1 is here to avoid seg faults when K=0
546  }
547 
548  _containers[SEX][AGE][ _sizes[SEX][AGE]++ ] = ind;
549  }
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
unsigned int _K
Carrying capacity for males and females.
Definition: metapop.h:426
unsigned int _capacities[2][3]
Total size of the containers, amount of allocated memory.
Definition: metapop.h:438
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.

Referenced by TTNeutralGenesSH::setHs().

553  { _containers[SEX][AGE].assign(n,0);
554  _sizes[SEX][AGE] = 0;
555  _capacities[SEX][AGE] = n;
556  }
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
unsigned int _capacities[2][3]
Total size of the containers, amount of allocated memory.
Definition: metapop.h:438
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

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

623 { _sizes[SEX][AGE] = 0;}
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
void Patch::clear ( )
inline

Referenced by swap().

624 { for(int i = 0; i < 3; i++) {_sizes[0][i] = 0;_sizes[1][i] = 0;}}
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
void Patch::copy2patch ( sex_t  from_sex,
sex_t  to_sex,
age_idx  from_age,
age_idx  to_age,
Patch to_patch 
)
inline

References add().

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

681  {
682  for (unsigned int i = 0; i < _sizes[from_sex][from_age]; ++i)
683  to_patch->add(to_sex, to_age, _containers[from_sex][from_age][i] );
684  }
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
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:540
void Patch::copy2patch ( sex_t  SEX,
age_idx  AGE,
Patch patch 
)
inline

References add().

687  {
688  for (unsigned int i = 0; i < _sizes[SEX][AGE]; ++i)
689  patch->add(SEX, AGE, get(SEX, AGE, i) );
690  }
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
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:540
void Patch::copy2patch ( age_idx  AGE,
Patch patch 
)
inline

References copy2patch(), FEM, and MAL.

693  {
694  copy2patch(FEM, AGE, patch);
695  copy2patch(MAL, AGE, patch);
696  }
void copy2patch(sex_t from_sex, sex_t to_sex, age_idx from_age, age_idx to_age, Patch *to_patch)
Definition: metapop.h:680
Definition: types.h:37
Definition: types.h:37
void Patch::copy2patch ( Patch patch)
inline

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

699  {
700  for (unsigned int i = 0; i < _nb_age_class; ++i){
701  copy2patch(FEM, static_cast<age_idx> (i), patch);
702  copy2patch(MAL, static_cast<age_idx> (i), patch);
703  }
704  }
void copy2patch(sex_t from_sex, sex_t to_sex, age_idx from_age, age_idx to_age, Patch *to_patch)
Definition: metapop.h:680
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:434
Definition: types.h:37
Definition: types.h:37
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

References 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(), and LCE_Disperse_base::reset_counters().

635  {
636  for (unsigned int i = 0; i < _sizes[SEX][AGE]; ++i) {
637  pop->recycle(_containers[SEX][AGE][i]);
638  _containers[SEX][AGE][i] = 0;
639  }
640  _sizes[SEX][AGE] = 0;
641  }
void recycle(Individual *ind)
Put an individual in the recycling pool.
Definition: indfactory.h:62
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
void Patch::flush ( age_idx  AGE,
Metapop pop 
)
inline

References FEM, flush(), and MAL.

644  { 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:634
Definition: types.h:37
Definition: types.h:37
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()

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

652  {
653  unsigned int mask = 1;
654 
655  for(unsigned int i = 0; i < _nb_age_class; i++) {
656  if( (mask & AGE) != 0) {
657  flush(MAL, static_cast<age_idx>(i), pop);
658  flush(FEM, static_cast<age_idx>(i), pop);
659  }
660  mask <<= 1;
661  }
662  }
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:434
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:634
Definition: types.h:37
Definition: types.h:37
void Patch::flush ( Metapop pop)
inline

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

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

666  {
667  for(unsigned int i = 0; i < _nb_age_class; i++) {
668  flush(MAL, static_cast<age_idx>(i), pop);
669  flush(FEM, static_cast<age_idx>(i), pop);
670  }
671  }
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:434
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:634
Definition: types.h:37
Definition: types.h:37
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

Referenced by LCE_Selection_base::addPhenotypicSD(), 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_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Breed::execute(), 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(), 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(), LCE_Breed_Wolbachia::hasInfectedFemale(), LCE_Breed_Wolbachia::inoculate_wolbachia(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Breed_base::partialMonoginy(), LCE_Breed_base::partialSelfing(), TTQuantiFH::print(), LCE_SelectionFH::print(), 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(), TTWolbachiaSH::setInfectionStats(), MPStatHandler::setKinship(), TTDeletMutBitstrSH::setMeanViability(), MPStatHandler::setPedegreeCount(), MPStatHandler::setReproductiveStats(), TTNeutralGenesSH::setSibStats(), TTDeletMutBitstrSH::setViability(), store_quanti_trait_values(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_Wolbachia::wolbachia_model_2(), TTBDMI_FH::write_diplo(), TTNeutralGenesFH::write_FSTAT(), TTNeutralGenesFH::write_GENEPOP(), TTBDMI_FH::write_haplo(), and TTNeutralGenesFH::write_TAB().

524  { return _containers[SEX][AGE][at]; }
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
unsigned int Patch::get_age ( )
inline

References _age.

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

476 {return _age;}
unsigned int _age
age since last extinction.
Definition: metapop.h:432
unsigned int Patch::get_K ( sex_t  SEX)
inline
471 {return (SEX ? _KFem : _KMal);}
unsigned int _KFem
Sex specific carrying capacity.
Definition: metapop.h:428
unsigned int _KMal
Definition: metapop.h:428
unsigned int Patch::get_KFem ( )
inline

References _KFem.

Referenced by LCE_Aging::execute(), LCE_Resize::fillPatchNoBackup(), LCE_Resize::fillPatchWithBackup(), LCE_Resize::regulateAgeClassNoBackup(), and LCE_Resize::regulateAgeClassWithBackup().

472 {return _KFem;}
unsigned int _KFem
Sex specific carrying capacity.
Definition: metapop.h:428
unsigned int Patch::get_KMal ( )
inline
unsigned int Patch::getAdultsNumber ( )
inline

References ADLTx, and size().

478 {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:487
Definition: types.h:42
void Patch::getCopy ( sex_t  SEX,
age_idx  AGE,
deque< Individual * > &  to 
)
inline

Referenced by LCE_Cross::execute().

674  {
675  for (unsigned int i = 0; i < _sizes[SEX][AGE]; ++i) {
676  to.push_back(_containers[SEX][AGE][i]);
677  }
678  }
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
double Patch::getDensity ( age_idx  age)
inline

References _K, and size().

479 {return (double)size(age)/_K;}
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
unsigned int _K
Carrying capacity for males and females.
Definition: metapop.h:426
Patch * Patch::init ( unsigned int  nbfem,
unsigned int  nbmal,
unsigned int  id 
)

Referenced by LCE_Resize::execute().

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 }
unsigned int _ID
Patch ID is equal to its position in the metapop patch array.
Definition: metapop.h:424
unsigned int _age
age since last extinction.
Definition: metapop.h:432
unsigned int _KFem
Sex specific carrying capacity.
Definition: metapop.h:428
void reset_containers()
Definition: patch.cc:66
unsigned int _KMal
Definition: metapop.h:428
unsigned int _K
Carrying capacity for males and females.
Definition: metapop.h:426
bool _isExtinct
Extinction flag.
Definition: metapop.h:430
void reset_counters()
Definition: patch.cc:56
bool Patch::isEmpty ( )
inline

References ALL, and size().

477 {return (size(ALL) == 0);}
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
#define ALL
All ages age class flag.
Definition: types.h:56
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

References add().

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

588  {
589  add( SEX, to, _containers[SEX][from][at] );
590  remove( SEX, from, at );
591  }
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
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:540
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

References 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(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Resize::regulateAgeClassWithBackup(), and LCE_Regulation::regulatePatch().

565  {
566  if(_sizes[SEX][AGE] == 0) {
567  error("Patch::remove:: container already empty!!");
568  return NULL;
569  }
570  unsigned int last = _sizes[SEX][AGE] - 1;
571  Individual* ind = _containers[SEX][AGE][at];
572  _containers[SEX][AGE][at] = _containers[SEX][AGE][ last ];
573  _containers[SEX][AGE][ last ] = 0;
574  _sizes[SEX][AGE]--;
575  return ind;
576  }
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
int error(const char *str,...)
Definition: output.cc:73
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
void Patch::reset_containers ( )

References FEM, and MAL.

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 }
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:434
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
unsigned int _KFem
Sex specific carrying capacity.
Definition: metapop.h:428
unsigned int _KMal
Definition: metapop.h:428
unsigned int _capacities[2][3]
Total size of the containers, amount of allocated memory.
Definition: metapop.h:438
Definition: types.h:37
Definition: types.h:37
void Patch::reset_counters ( )

Referenced by LCE_Disperse_base::reset_counters().

57 {
58  nbEmigrant = 0;
59  nbImigrant = 0;
60  nbPhilopat = 0;
61  nbKolonisers = 0;
62 }
unsigned short nbImigrant
Definition: metapop.h:444
unsigned short nbPhilopat
Definition: metapop.h:444
short nbKolonisers
Definition: metapop.h:445
unsigned short nbEmigrant
Definition: metapop.h:444
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
533  { _containers[SEX][AGE][at] = ind; }
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
void Patch::set_age ( unsigned int  a)
inline

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

464 {_age = a;}
unsigned int _age
age since last extinction.
Definition: metapop.h:432
void Patch::set_isExtinct ( bool  status)
inline

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

463 {_isExtinct = status;}
bool _isExtinct
Extinction flag.
Definition: metapop.h:430
void Patch::set_K ( unsigned int  k)
inline
460 {_K = k;}
unsigned int _K
Carrying capacity for males and females.
Definition: metapop.h:426
void Patch::set_KFem ( unsigned int  k)
inline

Referenced by LCE_Resize::updatePatchCapacities().

461 {_KFem = k;}
unsigned int _KFem
Sex specific carrying capacity.
Definition: metapop.h:428
void Patch::set_KMal ( unsigned int  k)
inline

Referenced by LCE_Resize::updatePatchCapacities().

462 {_KMal = k;}
unsigned int _KMal
Definition: metapop.h:428
void Patch::setID ( unsigned int  i)
inline
459 {_ID = i;}
unsigned int _ID
Patch ID is equal to its position in the metapop patch array.
Definition: metapop.h:424
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 }
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:434
void setNewGeneration(age_t AGE, Metapop *pop)
Fills the patch containers corresponding to the age flags passed, for both sexes. ...
Definition: patch.cc:80
void Patch::setNewGeneration ( age_idx  AGE,
Metapop pop 
)

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

References Individual::create_first_gen(), FEM, IndFactory::makeNewIndividual(), and MAL.

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 }
unsigned int _ID
Patch ID is equal to its position in the metapop patch array.
Definition: metapop.h:424
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:634
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
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
unsigned int _KFem
Sex specific carrying capacity.
Definition: metapop.h:428
unsigned int _KMal
Definition: metapop.h:428
Definition: types.h:37
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
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:540
Definition: types.h:37
void Patch::show_up ( )

References FEM, MAL, and message().

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
unsigned int _ID
Patch ID is equal to its position in the metapop patch array.
Definition: metapop.h:424
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:434
unsigned int _age
age since last extinction.
Definition: metapop.h:432
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
unsigned int _KFem
Sex specific carrying capacity.
Definition: metapop.h:428
unsigned int _KMal
Definition: metapop.h:428
unsigned int _K
Carrying capacity for males and females.
Definition: metapop.h:426
Definition: types.h:37
Definition: types.h:37
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

References FEM, and MAL.

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_Patch_Extinction::do_remove(), LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Aging::execute(), LCE_Patch_Extinction::execute(), LCE_Cross::execute(), LCE_Disperse_EvolDisp::execute(), LCE_Breed::execute(), TTDeletMutBitstrFH::FHwrite(), TTQFreqExtractor::FHwrite(), LCE_SelectionFH::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(), 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(), LCE_SelectionSH::getVarPatchFitness(), LCE_Breed_Wolbachia::hasInfectedFemale(), LCE_Breed_Wolbachia::inoculate_wolbachia(), isEmpty(), LCE_Breed_Disperse::logisticGrowth(), LCE_Breed_Disperse::mate_selfing(), LCE_Disperse_ConstDisp::Migrate(), LCE_Disperse_ConstDisp::MigratePatch(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Breed_Disperse::numFemOffspring(), LCE_Breed_Disperse::numMalOffspring_random(), LCE_Breed_base::partialMonoginy(), LCE_Breed_base::partialSelfing(), TTQuantiFH::print(), LCE_SelectionFH::print(), 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(), TTWolbachiaSH::setInfectionStats(), MPStatHandler::setKinship(), TTDeletMutBitstrSH::setMeanViability(), MPStatHandler::setPedegreeCount(), MPStatHandler::setReproductiveStats(), TTNeutralGenesSH::setSibStats(), TTBDMI_SH::setStats(), TTDeletMutBitstrSH::setViability(), Metapop::size(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_Wolbachia::wolbachia_model_2(), TTBDMI_FH::write_diplo(), TTNeutralGenesFH::write_FSTAT(), TTNeutralGenesFH::write_GENEPOP(), TTBDMI_FH::write_haplo(), and TTNeutralGenesFH::write_TAB().

488  { return size(MAL,AGE) + size(FEM,AGE); }
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Definition: types.h:37
Definition: types.h:37
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

References _nb_age_class.

495  {
496  unsigned int mask = 1, s = 0;
497  for(unsigned int i = 0; i < _nb_age_class; i++) {
498  if( (mask & AGE) != 0) s += _sizes[SEX][i];
499  mask <<= 1;
500  }
501  return s;
502  }
unsigned int _nb_age_class
Number of age classes present.
Definition: metapop.h:434
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
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
509  { return _sizes[SEX][AGE]; }
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
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
515  { return _sizes[0][AGE] + _sizes[1][AGE]; }
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
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

References clear().

Referenced by LCE_Disperse_base::swapPostDisp().

601  {
602  if( _sizes[SEX][from] > _capacities[SEX][to] ) {
603  _containers[SEX][to].resize( _sizes[SEX][from] );
604  _capacities[SEX][to] = _sizes[SEX][from];
605  }
606 
607  for(unsigned int i = 0; i < _sizes[SEX][from]; ++i)
608  _containers[SEX][to][i] = _containers[SEX][from][i];
609 
610  _sizes[SEX][to] = _sizes[SEX][from];
611  clear(SEX, from);
612  }
void clear()
Definition: metapop.h:624
unsigned int _sizes[2][3]
Containers size counters, sex X age.
Definition: metapop.h:436
deque< Individual * > _containers[2][3]
Individuals containers, sex X age.
Definition: metapop.h:440
unsigned int _capacities[2][3]
Total size of the containers, amount of allocated memory.
Definition: metapop.h:438

Member Data Documentation

unsigned int Patch::_age
private

age since last extinction.

Referenced by get_age().

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

Total size of the containers, amount of allocated memory.

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

Individuals containers, sex X age.

unsigned int Patch::_ID
private

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

Referenced by getID().

bool Patch::_isExtinct
private

Extinction flag.

Referenced by get_isExtinct().

unsigned int Patch::_K
private

Carrying capacity for males and females.

Referenced by get_K(), and getDensity().

unsigned int Patch::_KFem
private

Sex specific carrying capacity.

Referenced by get_KFem().

unsigned int Patch::_KMal
private

Referenced by get_KMal().

unsigned int Patch::_nb_age_class
private

Number of age classes present.

Referenced by copy2patch(), flush(), Patch(), and size().

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

Containers size counters, sex X age.


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

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR