Nemo  2.4.0
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 ( )
1347 : LifeCycleEvent ("disperse",""), doMigration(0), doPatchMigration(0)
1348 {
1349 
1352 
1353  LCE_Disperse_base::addParameters("dispersal", updater);
1354 }
virtual bool setParameters()
Definition: LCEdisperse.h:167
void(LCE_Disperse_ConstDisp::* doPatchMigration)(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.h:150
void(LCE_Disperse_ConstDisp::* doMigration)(void)
Definition: LCEdisperse.h:149
void addParameters(string prefix, ParamUpdaterBase *updater)
Definition: LCEdisperse.cc:61
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:97
Implementation of the ParamUpdaterBase interface.
Definition: param.h:362

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
155 {}

Member Function Documentation

◆ clone()

virtual LifeCycleEvent* LCE_Disperse_ConstDisp::clone ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_SeedDisp.

169 {return new LCE_Disperse_ConstDisp();}
LCE_Disperse_ConstDisp()
Definition: LCEdisperse.cc:1346

References LCE_Disperse_ConstDisp().

◆ execute()

void LCE_Disperse_ConstDisp::execute ( )
virtual

Implements LifeCycleEvent.

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

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

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 ( )
1453 {
1455  Migrate();
1456 }
void Migrate()
Definition: LCEdisperse.cc:1426
bool setIsland_PropagulePool_Matrix()
Definition: LCEdisperse.cc:580

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

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

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

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.

167 {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)
1359 {
1360 
1361  if(!LCE_Disperse_base::setBaseParameters(prefix)) return false;
1362 
1363  switch ( getDispersalModel() ) {
1364  case 0: //dispersal matrix given in input
1365  case 1:
1366  case 3:
1367  case 4:
1369  break;
1370  case 2:
1372  break;
1373  default:
1374  return error("\nDispersal model '%i' not yet implemented\n",getDispersalModel());
1375  }
1376 
1377  switch ((int)get_parameter_value(prefix + "_border_model")) {
1378  case -1:
1379  case 1:
1380  case 2:
1382  break;
1383  case 3:
1385  break;
1386  default:
1387  return error("\nDispersal border model '%i' not yet implemented\n",
1388  (int)get_parameter_value(prefix + "_border_model"));
1389  }
1390 
1391  if(isByNumber())
1393 
1394  return true;
1395 }
void MigratePatch_AbsorbingBorder(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1525
void Migrate_propagule()
Definition: LCEdisperse.cc:1452
void MigratePatchByNumber(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1486
void MigratePatch(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1460
bool setBaseParameters(string prefix)
Definition: LCEdisperse.cc:87
unsigned int getDispersalModel()
Definition: LCEdisperse.h:114
bool isByNumber()
Definition: LCEdisperse.h:113
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:142
int error(const char *str,...)
Definition: output.cc:78

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.0 by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR