Nemo  2.4.0b
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
LCE_Disperse_ConstDisp Class Reference

Dispersal event with constant dispersal rates. More...

#include <LCEdisperse.h>

+ Inheritance diagram for LCE_Disperse_ConstDisp:
+ Collaboration diagram for LCE_Disperse_ConstDisp:

Public Member Functions

 LCE_Disperse_ConstDisp ()
 
virtual ~LCE_Disperse_ConstDisp ()
 
bool setParameters (string prefix)
 
void Migrate ()
 
void Migrate_propagule ()
 
void MigratePatch (sex_t SEX, unsigned int LocalPatch)
 
void MigratePatch_AbsorbingBorder (sex_t SEX, unsigned int LocalPatch)
 
void MigratePatchByNumber (sex_t SEX, unsigned int LocalPatch)
 
Implementations
virtual bool setParameters ()
 
virtual void execute ()
 
virtual LifeCycleEventclone ()
 
- Public Member Functions inherited from LCE_Disperse_base
 LCE_Disperse_base ()
 
virtual ~LCE_Disperse_base ()
 Deallocates the disp matrix. More...
 
bool setBaseParameters (string prefix)
 
void setParamPrefix (string pref)
 
void addParameters (string prefix, ParamUpdaterBase *updater)
 
void setIndentityDispMatrix (TMatrix *mat)
 
unsigned int getMigrationPatchForward (sex_t SEX, unsigned int LocalPatch)
 
unsigned int getMigrationPatchBackward (sex_t SEX, unsigned int LocalPatch)
 
unsigned int getMigrationIndex (vector< double > &rates)
 
unsigned int getMigrationIndexGSLdiscrete (gsl_ran_discrete_t *rates)
 
void setPropaguleTargets ()
 
void swapPostDisp ()
 
void reset_counters ()
 
void set_isForward (bool val)
 
bool checkForwardDispersalMatrix (TMatrix *mat)
 
bool checkBackwardDispersalMatrix (TMatrix *mat)
 
void allocateDispMatrix (sex_t sex, unsigned int dim)
 
bool updateDispMatrix ()
 
bool setDispMatrix ()
 
bool setReducedMatricesBySex (sex_t SEX, Param &connectivity, Param &rate)
 
bool setReducedDispMatrix ()
 The reduced dispersal matrix contains the indices of the patches to which each patch is connected. More...
 
bool setIsland_MigrantPool_Matrix ()
 
bool setIsland_PropagulePool_Matrix ()
 
bool setSteppingStone1DMatrix ()
 
bool setLatticeMatrix ()
 Sets the dispersal matrices for the Lattice dispersal model. More...
 
bool setBasicLatticeMatrix (int rows, int cols, double phi_mal, double phi_fem, double disp_mal, double disp_fem)
 
bool setLatticeTorrusMatrix (int rows, int cols, double disp_mal, double disp_fem, TMatrix *grid)
 
bool setLatticeAbsorbingMatrix ()
 
bool setLatticeReflectingMatrix (int rows, int cols, TMatrix *grid)
 
bool isForward ()
 
bool isByNumber ()
 
unsigned int getDispersalModel ()
 
double getPropaguleProb ()
 
unsigned int getPropaguleTarget (unsigned int home)
 
vector< double > getConnectedPatches (sex_t SEX, unsigned int local_patch)
 
vector< double > getConnectedRates (sex_t SEX, unsigned int local_patch)
 
double getReducedDispersalRate (sex_t SEX, unsigned int row, unsigned int col)
 
unsigned int getReducedDispersalPatchID (sex_t SEX, unsigned int row, unsigned int col)
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
virtual age_t removeAgeClass ()
 
virtual age_t addAgeClass ()
 
virtual age_t requiredAgeClass ()
 
- Public Member Functions inherited from LifeCycleEvent
 LifeCycleEvent (const char *name, const char *trait_link)
 Cstor. More...
 
virtual ~LifeCycleEvent ()
 
virtual void init (Metapop *popPtr)
 Sets the pointer to the current Metapop and the trait link if applicable. More...
 
virtual bool attach_trait (string trait)
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 
virtual void set_event_name (std::string &name)
 Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set. More...
 
virtual void set_event_name (const char *name)
 
virtual string & get_event_name ()
 Accessor to the LCE's name. More...
 
virtual int get_rank ()
 Accessor to the LCE rank in the life cycle. More...
 
virtual void set_pop_ptr (Metapop *popPtr)
 Accessors for the population pointer. More...
 
virtual Metapopget_pop_ptr ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 

Private Attributes

void(LCE_Disperse_ConstDisp::* doMigration )(void)
 
void(LCE_Disperse_ConstDisp::* doPatchMigration )(sex_t SEX, unsigned int local_patch)
 

Additional Inherited Members

- Protected Attributes inherited from LCE_Disperse_base
unsigned int _npatch
 Number of patches in the population. More...
 
vector< vector< double > > _reducedDispMat [2]
 Matrix containing the indexes of the patches connected to each patch. More...
 
vector< vector< double > > _reducedDispMatProba [2]
 Matrix containing the probability to migrate to/from the connected patches. More...
 
- Protected Attributes inherited from LifeCycleEvent
std::string _event_name
 The param name to be read in the init file. More...
 
Metapop_popPtr
 The ptr to the current Metapop. More...
 
std::string _LCELinkedTraitType
 The name of the linked trait. More...
 
int _LCELinkedTraitIndex
 The index in the individual's trait table of the linked trait. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Detailed Description

Dispersal event with constant dispersal rates.

Sets and uses the dispersal matrices according to the dispersal model chosen. Dispersal models implemented so far are:

  • 1: Island Model with migrant pool
  • 2: Island Model with propagule pool
  • 3: Stepping stone model in 1 dimension (ring population)
  • 4: Lattice model (stepping stone in 2D)

Constructor & Destructor Documentation

◆ LCE_Disperse_ConstDisp()

LCE_Disperse_ConstDisp::LCE_Disperse_ConstDisp ( )
1348 : LifeCycleEvent ("disperse",""), doMigration(0), doPatchMigration(0)
1349 {
1350 
1353 
1354  LCE_Disperse_base::addParameters("dispersal", updater);
1355 }
virtual bool setParameters()
Definition: LCEdisperse.h:168
void(LCE_Disperse_ConstDisp::* doPatchMigration)(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.h:151
void(LCE_Disperse_ConstDisp::* doMigration)(void)
Definition: LCEdisperse.h:150
void addParameters(string prefix, ParamUpdaterBase *updater)
Definition: LCEdisperse.cc:62
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:98
Implementation of the ParamUpdaterBase interface.
Definition: param.h:363

References LCE_Disperse_base::addParameters(), and setParameters().

Referenced by clone().

◆ ~LCE_Disperse_ConstDisp()

virtual LCE_Disperse_ConstDisp::~LCE_Disperse_ConstDisp ( )
inlinevirtual
156 {}

Member Function Documentation

◆ clone()

virtual LifeCycleEvent* LCE_Disperse_ConstDisp::clone ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_SeedDisp.

170 {return new LCE_Disperse_ConstDisp();}
LCE_Disperse_ConstDisp()
Definition: LCEdisperse.cc:1347

References LCE_Disperse_ConstDisp().

◆ execute()

void LCE_Disperse_ConstDisp::execute ( )
virtual

Implements LifeCycleEvent.

1401 {
1402 #ifdef _DEBUG_
1403  message("LCE_Disperse_ConstDisp::execute (Patch nb: %i offsprg nb: %i adlt nb: %i "
1405  fflush(stdout);
1406 #endif
1407  //check whether the number of patches changed during simulation:
1408  if(_npatch != _popPtr->getPatchNbr()) {
1410  if(!updateDispMatrix()) fatal("bailing out\n");
1411  }
1412 
1413  reset_counters();
1414 
1415  (this->*doMigration)();
1416 
1417 #ifdef _DEBUG_
1418  unsigned int c = 0;
1419  for(unsigned int i = 0; i < _npatch; i++)
1420  c += _popPtr->getPatch(i)->nbEmigrant;
1421  message("emigrants nb: %i)\n",c);
1422 #endif
1423 }
void reset_counters()
Definition: LCEdisperse.cc:390
bool updateDispMatrix()
Definition: LCEdisperse.cc:365
unsigned int _npatch
Number of patches in the population.
Definition: LCEdisperse.h:64
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:312
unsigned int getPatchNbr()
Definition: metapop.h:276
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
unsigned short nbEmigrant
Definition: metapop.h:454
void fatal(const char *str,...)
Definition: output.cc:96
void message(const char *message,...)
Definition: output.cc:40
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50

References LCE_Disperse_base::_npatch, LifeCycleEvent::_popPtr, ADULTS, doMigration, fatal(), Metapop::getPatch(), Metapop::getPatchNbr(), message(), Patch::nbEmigrant, OFFSPRG, LCE_Disperse_base::reset_counters(), Metapop::size(), and LCE_Disperse_base::updateDispMatrix().

◆ Migrate()

void LCE_Disperse_ConstDisp::Migrate ( )
1428 {
1429  Patch *patch;
1430 
1431  for(unsigned int i = 0; i < _npatch; i++) {
1432 
1433  patch = _popPtr->getPatch(i);
1434 
1435  (this->*doPatchMigration)(FEM, i);
1436 
1437  (this->*doPatchMigration)(MAL, i);
1438 
1439  //set coloniser counter
1440  if(patch->get_isExtinct())
1441  patch->nbKolonisers = patch->size(PDISPx);
1442  else
1443  patch->nbKolonisers = -1; //value used in stat_demo to check for colonization
1444 
1445  }//end for nb_patch
1446 
1447  //put back the individuals into the offspring container
1448  swapPostDisp();
1449 }
void swapPostDisp()
Definition: LCEdisperse.cc:377
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:432
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:498
short nbKolonisers
Definition: metapop.h:455
bool get_isExtinct()
Definition: metapop.h:486
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37
@ PDISPx
Definition: types.h:42

References LCE_Disperse_base::_npatch, LifeCycleEvent::_popPtr, doPatchMigration, FEM, Patch::get_isExtinct(), Metapop::getPatch(), MAL, Patch::nbKolonisers, PDISPx, Patch::size(), and LCE_Disperse_base::swapPostDisp().

Referenced by Migrate_propagule(), and setParameters().

◆ Migrate_propagule()

void LCE_Disperse_ConstDisp::Migrate_propagule ( )
1454 {
1456  Migrate();
1457 }
void Migrate()
Definition: LCEdisperse.cc:1427
bool setIsland_PropagulePool_Matrix()
Definition: LCEdisperse.cc:581

References Migrate(), and LCE_Disperse_base::setIsland_PropagulePool_Matrix().

Referenced by setParameters().

◆ MigratePatch()

void LCE_Disperse_ConstDisp::MigratePatch ( sex_t  SEX,
unsigned int  LocalPatch 
)
1462 {
1463  Patch* patch = _popPtr->getPatch(LocalPatch);
1464  unsigned int AimedPatch;
1465  unsigned int Limit = _npatch -1;
1466 
1467  unsigned int count =1;
1468  while( patch->size(SEX, OFFSx) != 0 ) {
1469 
1470  do{
1471  AimedPatch = getMigrationPatchForward(SEX, LocalPatch);
1472  }while ( AimedPatch > Limit );
1473 
1474  _popPtr->move(SEX, OFFSx, LocalPatch, PDISPx, AimedPatch, 0);
1475 
1476  if(LocalPatch != AimedPatch) {
1477  patch->nbEmigrant++;
1478  _popPtr->getPatch(AimedPatch)->nbImigrant++;
1479  } else
1480  patch->nbPhilopat++;
1481 
1482  }//end while
1483 }
unsigned int getMigrationPatchForward(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1236
void move(sex_t SEX, age_idx from_age, unsigned int from_deme, age_idx to_age, unsigned int to_deme, unsigned int at)
Moves an individual from a deme to an other one, both demes sizes are modified.
Definition: metapop.h:837
unsigned short nbPhilopat
Definition: metapop.h:454
unsigned short nbImigrant
Definition: metapop.h:454
@ OFFSx
Definition: types.h:42

References LCE_Disperse_base::_npatch, LifeCycleEvent::_popPtr, LCE_Disperse_base::getMigrationPatchForward(), Metapop::getPatch(), Metapop::move(), Patch::nbEmigrant, Patch::nbImigrant, Patch::nbPhilopat, OFFSx, PDISPx, and Patch::size().

Referenced by setParameters().

◆ MigratePatch_AbsorbingBorder()

void LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder ( sex_t  SEX,
unsigned int  LocalPatch 
)
1525 {
1526  Patch* patch = _popPtr->getPatch(LocalPatch);
1527  unsigned int AimedPatch;
1528 
1529  while( patch->size(SEX, OFFSx) != 0 ) {
1530 
1531  do{
1532  AimedPatch = getMigrationPatchForward(SEX, LocalPatch);
1533  }while ( AimedPatch > _npatch );
1534 
1535  if(AimedPatch == _npatch) {
1536  _popPtr->recycle( patch->get(SEX, OFFSx, 0) );
1537  patch->remove(SEX, OFFSx, 0);
1538  } else
1539  _popPtr->move(SEX, OFFSx, LocalPatch, PDISPx, AimedPatch, 0);
1540 
1541  if(LocalPatch != AimedPatch) {
1542  patch->nbEmigrant++;
1543  if(AimedPatch < _npatch)
1544  _popPtr->getPatch(AimedPatch)->nbImigrant++;
1545  } else
1546  patch->nbPhilopat++;
1547 
1548  }//end while
1549 }
void recycle(Individual *ind)
Put an individual in the recycling pool.
Definition: indfactory.h:62
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:588
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:534

References LCE_Disperse_base::_npatch, LifeCycleEvent::_popPtr, Patch::get(), LCE_Disperse_base::getMigrationPatchForward(), Metapop::getPatch(), Metapop::move(), Patch::nbEmigrant, Patch::nbImigrant, Patch::nbPhilopat, OFFSx, PDISPx, IndFactory::recycle(), Patch::remove(), and Patch::size().

Referenced by setParameters().

◆ MigratePatchByNumber()

void LCE_Disperse_ConstDisp::MigratePatchByNumber ( sex_t  SEX,
unsigned int  LocalPatch 
)
1488 {
1489  Patch* patch = _popPtr->getPatch(LocalPatch);
1490  unsigned int AimedPatch, at;
1491  unsigned int Limit = _npatch -1;
1492 
1493  // cycle through the connected patches
1494  for(unsigned int i = 0; i < _reducedDispMat[SEX][LocalPatch].size(); ++i) {
1495 
1496  AimedPatch = _reducedDispMat[SEX][LocalPatch][i];
1497 
1498  // move as many individual as we can until either the specified number is reached or the patch is empty
1499  for(unsigned int m = _reducedDispMatProba[SEX][LocalPatch][i]; m > 0 && patch->size(SEX, OFFSx) > 0; --m) {
1500 
1501  // take an individual at random:
1502  at = RAND::Uniform(patch->size(SEX, OFFSx));
1503 
1504  _popPtr->move(SEX, OFFSx, LocalPatch, PDISPx, AimedPatch, at);
1505 
1506  if(LocalPatch != AimedPatch) {
1507 
1508  patch->nbEmigrant++;
1509 
1510  _popPtr->getPatch(AimedPatch)->nbImigrant++;
1511 
1512  } else
1513 
1514  patch->nbPhilopat++;
1515  }//end for num migrants
1516 
1517  }//end for num connected patches
1518 
1519  // there might be individuals still in the patch, we keep them there for now
1520 }
vector< vector< double > > _reducedDispMatProba[2]
Matrix containing the probability to migrate to/from the connected patches.
Definition: LCEdisperse.h:69
vector< vector< double > > _reducedDispMat[2]
Matrix containing the indexes of the patches connected to each patch.
Definition: LCEdisperse.h:67
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:124

References LCE_Disperse_base::_npatch, LifeCycleEvent::_popPtr, LCE_Disperse_base::_reducedDispMat, LCE_Disperse_base::_reducedDispMatProba, Metapop::getPatch(), Metapop::move(), Patch::nbEmigrant, Patch::nbImigrant, Patch::nbPhilopat, OFFSx, PDISPx, Patch::size(), and RAND::Uniform().

Referenced by setParameters().

◆ setParameters() [1/2]

virtual bool LCE_Disperse_ConstDisp::setParameters ( )
inlinevirtual

Implements SimComponent.

Reimplemented in LCE_SeedDisp.

168 {return setParameters("dispersal");}

References setParameters().

Referenced by LCE_Disperse_ConstDisp(), setParameters(), and LCE_SeedDisp::setParameters().

◆ setParameters() [2/2]

bool LCE_Disperse_ConstDisp::setParameters ( string  prefix)
1360 {
1361 
1362  if(!LCE_Disperse_base::setBaseParameters(prefix)) return false;
1363 
1364  switch ( getDispersalModel() ) {
1365  case 0: //dispersal matrix given in input
1366  case 1:
1367  case 3:
1368  case 4:
1370  break;
1371  case 2:
1373  break;
1374  default:
1375  return error("\nDispersal model '%i' not yet implemented\n",getDispersalModel());
1376  }
1377 
1378  switch ((int)get_parameter_value(prefix + "_border_model")) {
1379  case -1:
1380  case 1:
1381  case 2:
1383  break;
1384  case 3:
1386  break;
1387  default:
1388  return error("\nDispersal border model '%i' not yet implemented\n",
1389  (int)get_parameter_value(prefix + "_border_model"));
1390  }
1391 
1392  if(isByNumber())
1394 
1395  return true;
1396 }
void MigratePatch_AbsorbingBorder(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1524
void Migrate_propagule()
Definition: LCEdisperse.cc:1453
void MigratePatchByNumber(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1487
void MigratePatch(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1461
bool setBaseParameters(string prefix)
Definition: LCEdisperse.cc:88
unsigned int getDispersalModel()
Definition: LCEdisperse.h:115
bool isByNumber()
Definition: LCEdisperse.h:114
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
int error(const char *str,...)
Definition: output.cc:77

References doMigration, doPatchMigration, error(), SimComponent::get_parameter_value(), LCE_Disperse_base::getDispersalModel(), LCE_Disperse_base::isByNumber(), Migrate(), Migrate_propagule(), MigratePatch(), MigratePatch_AbsorbingBorder(), MigratePatchByNumber(), and LCE_Disperse_base::setBaseParameters().

Member Data Documentation

◆ doMigration

void(LCE_Disperse_ConstDisp::* LCE_Disperse_ConstDisp::doMigration) (void)
private

Referenced by execute(), and setParameters().

◆ doPatchMigration

void(LCE_Disperse_ConstDisp::* LCE_Disperse_ConstDisp::doPatchMigration) (sex_t SEX, unsigned int local_patch)
private

Referenced by Migrate(), and setParameters().


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

Generated for Nemo v2.4.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR