Nemo  2.4.2
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 ( )
1346 : LifeCycleEvent ("disperse",""), doMigration(0), doPatchMigration(0)
1347 {
1348 
1351 
1352  LCE_Disperse_base::addParameters("dispersal", updater);
1353 }
virtual bool setParameters()
Definition: LCEdisperse.h:166
void(LCE_Disperse_ConstDisp::* doPatchMigration)(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.h:149
void(LCE_Disperse_ConstDisp::* doMigration)(void)
Definition: LCEdisperse.h:148
void addParameters(string prefix, ParamUpdaterBase *updater)
Definition: LCEdisperse.cc:60
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:96
Implementation of the ParamUpdaterBase interface.
Definition: param.h:371

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

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~LCE_Disperse_ConstDisp()

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

Member Function Documentation

◆ clone()

virtual LifeCycleEvent* LCE_Disperse_ConstDisp::clone ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_SeedDisp.

168 {return new LCE_Disperse_ConstDisp();}
LCE_Disperse_ConstDisp()
Definition: LCEdisperse.cc:1345

References LCE_Disperse_ConstDisp().

◆ execute()

void LCE_Disperse_ConstDisp::execute ( )
virtual

Implements LifeCycleEvent.

1399 {
1400 #ifdef _DEBUG_
1401  message("LCE_Disperse_ConstDisp::execute (Patch nb: %i offsprg nb: %i adlt nb: %i "
1403  fflush(stdout);
1404 #endif
1405  //check whether the number of patches changed during simulation:
1406  if(_npatch != _popPtr->getPatchNbr()) {
1408  if(!updateDispMatrix()) fatal("bailing out\n");
1409  }
1410 
1411  reset_counters();
1412 
1413  (this->*doMigration)();
1414 
1415 #ifdef _DEBUG_
1416  unsigned int c = 0;
1417  for(unsigned int i = 0; i < _npatch; i++)
1418  c += _popPtr->getPatch(i)->nbEmigrant;
1419  message("emigrants nb: %i)\n",c);
1420 #endif
1421 }
void reset_counters()
Definition: LCEdisperse.cc:388
bool updateDispMatrix()
Definition: LCEdisperse.cc:363
unsigned int _npatch
Number of patches in the population.
Definition: LCEdisperse.h:62
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:79
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:310
unsigned int getPatchNbr()
Definition: metapop.h:274
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:255
unsigned short nbEmigrant
Definition: metapop.h:452
void fatal(const char *str,...)
Definition: output.cc:98
void message(const char *message,...)
Definition: output.cc:38
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:52
#define OFFSPRG
Offspring age class flag.
Definition: types.h:48

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 ( )
1426 {
1427  Patch *patch;
1428 
1429  for(unsigned int i = 0; i < _npatch; i++) {
1430 
1431  patch = _popPtr->getPatch(i);
1432 
1433  (this->*doPatchMigration)(FEM, i);
1434 
1435  (this->*doPatchMigration)(MAL, i);
1436 
1437  //set coloniser counter
1438  if(patch->get_isExtinct())
1439  patch->nbKolonisers = patch->size(PDISPx);
1440  else
1441  patch->nbKolonisers = -1; //value used in stat_demo to check for colonization
1442 
1443  }//end for nb_patch
1444 
1445  //put back the individuals into the offspring container
1446  swapPostDisp();
1447 }
void swapPostDisp()
Definition: LCEdisperse.cc:375
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
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
short nbKolonisers
Definition: metapop.h:453
bool get_isExtinct()
Definition: metapop.h:484
@ FEM
Definition: types.h:35
@ MAL
Definition: types.h:35
@ PDISPx
Definition: types.h:40

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

+ Here is the caller graph for this function:

◆ Migrate_propagule()

void LCE_Disperse_ConstDisp::Migrate_propagule ( )
1452 {
1454  Migrate();
1455 }
void Migrate()
Definition: LCEdisperse.cc:1425
bool setIsland_PropagulePool_Matrix()
Definition: LCEdisperse.cc:579

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

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ MigratePatch()

void LCE_Disperse_ConstDisp::MigratePatch ( sex_t  SEX,
unsigned int  LocalPatch 
)
1460 {
1461  Patch* patch = _popPtr->getPatch(LocalPatch);
1462  unsigned int AimedPatch;
1463  unsigned int Limit = _npatch -1;
1464 
1465  unsigned int count =1;
1466  while( patch->size(SEX, OFFSx) != 0 ) {
1467 
1468  do{
1469  AimedPatch = getMigrationPatchForward(SEX, LocalPatch);
1470  }while ( AimedPatch > Limit );
1471 
1472  _popPtr->move(SEX, OFFSx, LocalPatch, PDISPx, AimedPatch, 0);
1473 
1474  if(LocalPatch != AimedPatch) {
1475  patch->nbEmigrant++;
1476  _popPtr->getPatch(AimedPatch)->nbImigrant++;
1477  } else
1478  patch->nbPhilopat++;
1479 
1480  }//end while
1481 }
unsigned int getMigrationPatchForward(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1234
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:452
unsigned short nbImigrant
Definition: metapop.h:452
@ OFFSx
Definition: types.h:40

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

+ Here is the caller graph for this function:

◆ 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:60
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:586
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 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().

+ Here is the caller graph for this function:

◆ MigratePatchByNumber()

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

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

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ setParameters() [1/2]

virtual bool LCE_Disperse_ConstDisp::setParameters ( )
inlinevirtual

Implements SimComponent.

Reimplemented in LCE_SeedDisp.

166 {return setParameters("dispersal");}

References setParameters().

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

+ Here is the caller graph for this function:

◆ setParameters() [2/2]

bool LCE_Disperse_ConstDisp::setParameters ( string  prefix)
1358 {
1359 
1360  if(!LCE_Disperse_base::setBaseParameters(prefix)) return false;
1361 
1362  switch ( getDispersalModel() ) {
1363  case 0: //dispersal matrix given in input
1364  case 1:
1365  case 3:
1366  case 4:
1368  break;
1369  case 2:
1371  break;
1372  default:
1373  return error("\nDispersal model '%i' not yet implemented\n",getDispersalModel());
1374  }
1375 
1376  switch ((int)get_parameter_value(prefix + "_border_model")) {
1377  case -1:
1378  case 1:
1379  case 2:
1381  break;
1382  case 3:
1384  break;
1385  default:
1386  return error("\nDispersal border model '%i' not yet implemented\n",
1387  (int)get_parameter_value(prefix + "_border_model"));
1388  }
1389 
1390  if(isByNumber())
1392 
1393  return true;
1394 }
void MigratePatch_AbsorbingBorder(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1524
void Migrate_propagule()
Definition: LCEdisperse.cc:1451
void MigratePatchByNumber(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1485
void MigratePatch(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1459
bool setBaseParameters(string prefix)
Definition: LCEdisperse.cc:86
unsigned int getDispersalModel()
Definition: LCEdisperse.h:113
bool isByNumber()
Definition: LCEdisperse.h:112
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:141
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.2 by  doxygen 1.9.1

Catalogued on GSR