Nemo  2.2.0
Public Member Functions | Public Attributes | Private Attributes
Patch Class Reference

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

#include <metapop.h>

List of all members.

Public Member Functions

 Patch ()
 ~Patch ()
Patchinit (unsigned int nbfem, unsigned int nbmal, unsigned int id)
unsigned int size (age_t AGE)
 Returns the size of the container of the appropriate age class(es) for both sexes.
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.
unsigned int size (sex_t SEX, age_idx AGE)
 Returns the size of the container for the appropriate sex and age class.
unsigned int size (age_idx AGE)
 Returns the size of the container for the appropriate age class for both sexes.
Individualget (sex_t SEX, age_idx AGE, unsigned int at)
 Returns a pointer to the individual sitting at the index passed.
void set (sex_t SEX, age_idx AGE, unsigned int at, Individual *ind)
 Modifies the appropriate container with value of the pointer given.
void add (sex_t SEX, age_idx AGE, Individual *ind)
 Adds an individual to the appropriate container, increments its size, eventually resizing it.
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.
Individualremove (sex_t SEX, age_idx AGE, unsigned int at)
 Removes the individual sitting at the given index in the appropriate container.
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.
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.
void clear (sex_t SEX, age_idx AGE)
 Sets the size of the appropriate container to zero.
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.
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.
void flush (Metapop *pop)
 Removes all individual pointers of all sex and age classes and flush them into the recycling pool.
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)
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.
void setNewGeneration (age_idx AGE, Metapop *pop)
 Fills the patch container corresponding to the age class index passed, for both sexes.
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 getPatchOffsprgSatLevel ()
double getPatchAdultsSatLevel ()

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.
unsigned int _K
 Carrying capacity for males and females.
unsigned int _KFem
 Sex specific carrying capacity.
unsigned int _KMal
bool _isExtinct
 Extinction flag.
unsigned int _age
 age since last extinction.
unsigned int _nb_age_class
 Number of age classes present.
unsigned int _sizes [2][3]
 Containers size counters, sex X age.
unsigned int _capacities [2][3]
 Total size of the containers, amount of allocated memory.
deque< Individual * > _containers [2][3]
 Individuals containers, sex X age.

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).

Definition at line 388 of file metapop.h.


Constructor & Destructor Documentation

Patch::Patch ( ) [inline]

Definition at line 415 of file metapop.h.

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

          : _ID(0), _K(1), _KFem(1), _KMal(1), _isExtinct(0), _age(0), _nb_age_class(3) 
  { for(unsigned int i = 0; i < _nb_age_class; i++) {
    _sizes[MAL][i] = 0;
    _sizes[FEM][i] = 0;
    _capacities[MAL][i] = 0;
    _capacities[FEM][i] = 0;}
  }
Patch::~Patch ( )

Definition at line 120 of file patch.cc.

{
//#ifdef _DEBUG_
//  message("Patch::~Patch\n");
//#endif
  
  for (unsigned int i = 0; i < 2; ++i)
    for(unsigned int j = 0; j < _nb_age_class; ++j)
      for(unsigned int k = 0; k < _sizes[i][j] ; ++k)
        delete _containers[i][j][k];
}

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

Definition at line 504 of file metapop.h.

References _capacities, _containers, _K, and _sizes.

Referenced by copy2patch(), LCE_Breed_Selection_Disperse::do_breed(), LCE_Breed_Disperse::do_breed_disperse(), LCE_Breed_Selection::execute(), LCE_Breed::execute(), TTNeutralGenesFH::FHread(), TTDeletMutBitstrFH::FHread(), Metapop::fillPatchFromSource(), LCE_Resize::fillPatchNoBackup(), LCE_Resize::fillPatchWithBackup(), move(), LCE_Resize::regulateAgeClassWithBackup(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().

  {
    
    if( _sizes[SEX][AGE] + 1 > _capacities[SEX][AGE] ) {
      _containers[SEX][AGE].resize( _capacities[SEX][AGE] + _K );
      _capacities[SEX][AGE] += _K;
    }
    
    _containers[SEX][AGE][ _sizes[SEX][AGE]++ ] = ind;
  }
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.

Definition at line 516 of file metapop.h.

References _capacities, _containers, and _sizes.

  { _containers[SEX][AGE].assign(n,0);
   _sizes[SEX][AGE] = 0;
   _capacities[SEX][AGE] = n;
  }
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 shure no pointers remained in the container.

See also:
flush()
Parameters:
SEXthe sex class
AGEthe index of the age class

Definition at line 587 of file metapop.h.

References _sizes.

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

{ _sizes[SEX][AGE] = 0;}
void Patch::clear ( ) [inline]

Definition at line 588 of file metapop.h.

References _sizes.

Referenced by swap().

{ for(int i = 0; i < 3; i++) {_sizes[0][i] = 0;_sizes[1][i] = 0;}}
void Patch::copy2patch ( sex_t  from_sex,
sex_t  to_sex,
age_idx  from_age,
age_idx  to_age,
Patch to_patch 
) [inline]

Definition at line 644 of file metapop.h.

References _containers, _sizes, and add().

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

  {
    for (unsigned int i = 0; i < _sizes[from_sex][from_age]; ++i)
      to_patch->add(to_sex, to_age, _containers[from_sex][from_age][i] );
  }
void Patch::copy2patch ( sex_t  SEX,
age_idx  AGE,
Patch patch 
) [inline]

Definition at line 650 of file metapop.h.

References _sizes, and add().

  {
    for (unsigned int i = 0; i < _sizes[SEX][AGE]; ++i)
      patch->add(SEX, AGE, get(SEX, AGE, i) );
  }
void Patch::copy2patch ( age_idx  AGE,
Patch patch 
) [inline]

Definition at line 656 of file metapop.h.

References copy2patch(), FEM, and MAL.

  {
    copy2patch(FEM, AGE, patch);
    copy2patch(MAL, AGE, patch);
  }
void Patch::copy2patch ( Patch patch) [inline]

Definition at line 662 of file metapop.h.

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

  {
    for (unsigned int i = 0; i < _nb_age_class; ++i){
      copy2patch(FEM, static_cast<age_idx> (i), patch);
      copy2patch(MAL, static_cast<age_idx> (i), patch);
    }
  }
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

Definition at line 598 of file metapop.h.

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

  {
    for (unsigned int i = 0; i < _sizes[SEX][AGE]; ++i) {
      pop->recycle(_containers[SEX][AGE][i]);
      _containers[SEX][AGE][i] = 0;
    }
    _sizes[SEX][AGE] = 0;
  }
void Patch::flush ( age_idx  AGE,
Metapop pop 
) [inline]

Definition at line 607 of file metapop.h.

References FEM, flush(), and MAL.

Referenced by flush().

  { flush(FEM, AGE, pop); flush(MAL, AGE, pop); }
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()

Definition at line 615 of file metapop.h.

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

  {
    unsigned int mask = 1;
    
    for(unsigned int i = 0; i < _nb_age_class; i++) {
      if( (mask & AGE) != 0) {
        flush(MAL, static_cast<age_idx>(i), pop);
        flush(FEM, static_cast<age_idx>(i), pop);
      }
      mask <<= 1;
    }
  }
void Patch::flush ( Metapop pop) [inline]

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

Definition at line 629 of file metapop.h.

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

  {
    for(unsigned int i = 0; i < _nb_age_class; i++) {
      flush(MAL, static_cast<age_idx>(i), pop);
      flush(FEM, static_cast<age_idx>(i), pop);
    }
  }
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

Definition at line 487 of file metapop.h.

References _containers.

Referenced by LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Breed_Selection::execute(), LCE_Breed::execute(), TTDeletMutBitstrFH::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(), TTWolbachiaSH::getMeanFemaleInfection_perPatch(), LCE_Selection_base::getMeanFitness(), TTWolbachiaSH::getMeanMaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgInfection(), TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch(), LCE_Selection_base::getMeanPatchFitness(), LCE_SelectionSH::getPatchFitness(), LCE_Breed_Wolbachia::hasInfectedFemale(), LCE_Breed_Wolbachia::inoculate_wolbachia(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Breed_base::partialMonoginy(), LCE_Breed_base::partialSelfing(), LCE_Breed_base::random_hermaphrodite(), LCE_Breed_base::RandomMating(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Resize::regulateAgeClassWithBackup(), TTWolbachiaSH::setInfectionStats(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_Wolbachia::wolbachia_model_2(), TTNeutralGenesFH::write_FSTAT(), and TTNeutralGenesFH::write_varcompWC().

  { return _containers[SEX][AGE][at]; }
unsigned int Patch::get_age ( ) [inline]

Definition at line 441 of file metapop.h.

References _age.

{return _age;}
bool Patch::get_isExtinct ( ) [inline]
unsigned int Patch::get_K ( ) [inline]

Definition at line 436 of file metapop.h.

References _K.

{return _K;}
unsigned int Patch::get_K ( sex_t  SEX) [inline]

Definition at line 437 of file metapop.h.

References _KFem, and _KMal.

{return (SEX ? _KFem : _KMal);}
unsigned int Patch::get_KFem ( ) [inline]
unsigned int Patch::get_KMal ( ) [inline]
unsigned int Patch::getAdultsNumber ( ) [inline]

Definition at line 443 of file metapop.h.

References ADLTx, and size().

{return size(ADLTx);}
void Patch::getCopy ( sex_t  SEX,
age_idx  AGE,
deque< Individual * > &  to 
) [inline]

Definition at line 637 of file metapop.h.

References _containers, and _sizes.

  {
    for (unsigned int i = 0; i < _sizes[SEX][AGE]; ++i) {
      to.push_back(_containers[SEX][AGE][i]);
    }
  }
unsigned int Patch::getID ( ) [inline]

Definition at line 435 of file metapop.h.

References _ID.

Referenced by LCE_Resize::fillPatchNoBackup(), and LCE_Resize::removeDesignatedPatch().

{return _ID;}
double Patch::getPatchAdultsSatLevel ( ) [inline]

Definition at line 445 of file metapop.h.

References _K, ADLTx, and size().

{return (double)size(ADLTx)/_K;}
double Patch::getPatchOffsprgSatLevel ( ) [inline]

Definition at line 444 of file metapop.h.

References _K, OFFSx, and size().

{return (double)size(OFFSx)/_K;}
Patch * Patch::init ( unsigned int  nbfem,
unsigned int  nbmal,
unsigned int  id 
)

Definition at line 38 of file patch.cc.

Referenced by LCE_Resize::execute().

{
  _ID = id;
  _KFem = nbfem;
  _KMal = nbmal;
  _K = _KFem + _KMal;
  _isExtinct = false;
  _age = 0;
  
  reset_counters();
 
  reset_containers();
  
  return this;
}
bool Patch::isEmpty ( ) [inline]

Definition at line 442 of file metapop.h.

References ALL, and size().

{return (size(ALL) == 0);}
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

Definition at line 551 of file metapop.h.

References _containers, and add().

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

  {
    add( SEX, to, _containers[SEX][from][at] );
    remove( SEX, from, at );
  }
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

Definition at line 528 of file metapop.h.

References _containers, _sizes, and error().

Referenced by LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Resize::fillPatchWithBackup(), LCE_Disperse_EvolDisp::fixdisp(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Resize::regulateAgeClassNoBackup(), and LCE_Resize::regulateAgeClassWithBackup().

  {
    if(_sizes[SEX][AGE] == 0) {
      error("Patch::remove:: container already empty!!");
      return NULL;
    }
    unsigned int last = _sizes[SEX][AGE] - 1;
    Individual* ind = _containers[SEX][AGE][at];
    _containers[SEX][AGE][at] = _containers[SEX][AGE][ last ];
    _containers[SEX][AGE][ last ] = 0;
    _sizes[SEX][AGE]--;
    return ind;
  }
void Patch::reset_containers ( )

Definition at line 66 of file patch.cc.

References FEM, and MAL.

{  
  for(unsigned int i=0; i < _nb_age_class; i++) {
    _containers[MAL][i].assign( _KMal, 0 );
    _containers[FEM][i].assign( _KFem, 0 );
    _sizes[MAL][i] = 0;
    _sizes[FEM][i] = 0;
    _capacities[MAL][i] = _KMal;
    _capacities[FEM][i] = _KFem;
  }
}
void Patch::reset_counters ( )

Definition at line 56 of file patch.cc.

Referenced by LCE_Disperse_base::reset_counters().

{
  nbEmigrant = 0;
  nbImigrant = 0;
  nbPhilopat = 0;
  nbKolonisers = 0;
}
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

Definition at line 496 of file metapop.h.

References _containers.

  { _containers[SEX][AGE][at] = ind; }
void Patch::set_age ( unsigned int  a) [inline]

Definition at line 431 of file metapop.h.

References _age.

{_age = a;}
void Patch::set_isExtinct ( bool  status) [inline]

Definition at line 430 of file metapop.h.

References _isExtinct.

{_isExtinct = status;}
void Patch::set_K ( unsigned int  k) [inline]

Definition at line 427 of file metapop.h.

References _K.

{_K = k;}
void Patch::set_KFem ( unsigned int  k) [inline]

Definition at line 428 of file metapop.h.

References _KFem.

Referenced by LCE_Resize::updatePatchCapacities().

{_KFem = k;}
void Patch::set_KMal ( unsigned int  k) [inline]

Definition at line 429 of file metapop.h.

References _KMal.

Referenced by LCE_Resize::updatePatchCapacities().

{_KMal = k;}
void Patch::setID ( unsigned int  i) [inline]

Definition at line 426 of file metapop.h.

References _ID.

{_ID = i;}
void Patch::setNewGeneration ( age_t  AGE,
Metapop pop 
)

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

Definition at line 80 of file patch.cc.

{
  unsigned int mask = 1;

  for(unsigned int i = 0; i < _nb_age_class; i++) {
    if( (mask & AGE) != 0) setNewGeneration(static_cast<age_idx>(i), pop);
    mask<<=1;
  }
}
void Patch::setNewGeneration ( age_idx  AGE,
Metapop pop 
)

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

Definition at line 92 of file patch.cc.

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

{  
  Individual *new_ind;

  //--------------------------------------------------------------------
  //if too much females in the Patch, flush them into the RecyclingPOOL
  if(size(FEM, AGE) > 0) flush(FEM, AGE, pop);
  
  for(unsigned int i = 0; i < _KFem; i++) {
    new_ind = pop->makeNewIndividual(0,0,FEM,_ID);
    new_ind->create_first_gen();
    add(FEM, AGE, new_ind);
  }
  
  //--------------------------------------------------------------------
  //males: same as for the females....
  if(size(MAL, AGE) > 0) flush(MAL, AGE, pop);
  
  for(unsigned int i = 0; i < _KMal; i++) {
    new_ind = pop->makeNewIndividual(0,0,MAL,_ID);
    new_ind->create_first_gen();
    add(MAL, AGE, new_ind);
  }
  
}
void Patch::show_up ( )

Definition at line 134 of file patch.cc.

References FEM, MAL, and message().

{
  message("Patch %i:\n  age: %i; K: %i, K_fem: %i; K_mal: %i\n",_ID, _age, _K, _KFem, _KMal);
  for(unsigned int j = 0; j < _nb_age_class; ++j)
    message("   age class %i: females: %i; males: %i\n", j, _sizes[FEM][j], _sizes[MAL][j]);
}
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

Definition at line 451 of file metapop.h.

References FEM, MAL, and size().

Referenced by 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::do_breed_disperse(), LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Breed_Selection::execute(), LCE_Disperse_EvolDisp::execute(), LCE_Breed::execute(), TTDeletMutBitstrFH::FHwrite(), Metapop::fillPatchFromSource(), LCE_Resize::fillPatchNoBackup(), LCE_Resize::fillPatchWithBackup(), LCE_Disperse_EvolDisp::fixdisp(), LCE_Breed_base::fullMonoginy(), LCE_Breed_base::fullPolyginy_manyMales(), LCE_Breed_Disperse::get_parent(), getAdultsNumber(), TTWolbachiaSH::getMeanFemaleInfection_perPatch(), LCE_Selection_base::getMeanFitness(), TTWolbachiaSH::getMeanMaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgInfection(), TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch(), LCE_Selection_base::getMeanPatchFitness(), getPatchAdultsSatLevel(), LCE_SelectionSH::getPatchFitness(), getPatchOffsprgSatLevel(), LCE_Breed_Wolbachia::hasInfectedFemale(), LCE_Breed_Wolbachia::inoculate_wolbachia(), isEmpty(), LCE_Breed_Disperse::mate_selfing(), LCE_Disperse_ConstDisp::Migrate(), LCE_Disperse_ConstDisp::MigratePatch(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Breed_base::partialMonoginy(), LCE_Breed_base::partialSelfing(), LCE_Breed_base::random_hermaphrodite(), LCE_Breed_base::RandomMating(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Resize::regulateAgeClassWithBackup(), TTWolbachiaSH::setInfectionStats(), Metapop::size(), size(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_Wolbachia::wolbachia_model_2(), TTNeutralGenesFH::write_FSTAT(), and TTNeutralGenesFH::write_varcompWC().

  { return size(MAL,AGE) + size(FEM,AGE); }
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

Definition at line 458 of file metapop.h.

References _nb_age_class, and _sizes.

  { 
    unsigned int mask = 1, s = 0;
    for(unsigned int i = 0; i < _nb_age_class; i++) {
      if( (mask & AGE) != 0) s +=  _sizes[SEX][i];
      mask <<= 1;
    }
    return s;
  }
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

Definition at line 472 of file metapop.h.

References _sizes.

  { return _sizes[SEX][AGE]; }
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

Definition at line 478 of file metapop.h.

References _sizes.

  { return _sizes[0][AGE] + _sizes[1][AGE]; }
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

Definition at line 564 of file metapop.h.

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

Referenced by LCE_Disperse_base::swapPostDisp().

  {
    if( _sizes[SEX][from] > _capacities[SEX][to] ) {
      _containers[SEX][to].resize( _sizes[SEX][from] );
      _capacities[SEX][to] = _sizes[SEX][from];
    }
    
    for(unsigned int i = 0; i < _sizes[SEX][from]; ++i)
      _containers[SEX][to][i] = _containers[SEX][from][i];
    
    _sizes[SEX][to] = _sizes[SEX][from];
    clear(SEX, from);
  }

Member Data Documentation

unsigned int Patch::_age [private]

age since last extinction.

Definition at line 399 of file metapop.h.

Referenced by get_age(), and set_age().

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

Total size of the containers, amount of allocated memory.

Definition at line 405 of file metapop.h.

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

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

Individuals containers, sex X age.

Definition at line 407 of file metapop.h.

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

unsigned int Patch::_ID [private]

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

Definition at line 391 of file metapop.h.

Referenced by getID(), and setID().

bool Patch::_isExtinct [private]

Extinction flag.

Definition at line 397 of file metapop.h.

Referenced by get_isExtinct(), and set_isExtinct().

unsigned int Patch::_K [private]

Carrying capacity for males and females.

Definition at line 393 of file metapop.h.

Referenced by add(), get_K(), getPatchAdultsSatLevel(), getPatchOffsprgSatLevel(), and set_K().

unsigned int Patch::_KFem [private]

Sex specific carrying capacity.

Definition at line 395 of file metapop.h.

Referenced by get_K(), get_KFem(), and set_KFem().

unsigned int Patch::_KMal [private]

Definition at line 395 of file metapop.h.

Referenced by get_K(), get_KMal(), and set_KMal().

unsigned int Patch::_nb_age_class [private]

Number of age classes present.

Definition at line 401 of file metapop.h.

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

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

Containers size counters, sex X age.

Definition at line 403 of file metapop.h.

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

unsigned short Patch::nbEmigrant
unsigned short Patch::nbImigrant
unsigned short Patch::nbPhilopat

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

Generated for Nemo v2.2.0 by  doxygen 1.7.5.1 -- Nemo is hosted by  SourceForge.net Logo