Nemo  2.3.56
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)
 
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)
 
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 ( )
1265: LifeCycleEvent ("disperse",""), doMigration(0), doPatchMigration(0)
1266{
1267
1270
1271 LCE_Disperse_base::addParameters("dispersal", updater);
1272}
virtual bool setParameters()
Definition: LCEdisperse.h:154
void(LCE_Disperse_ConstDisp::* doPatchMigration)(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.h:137
void(LCE_Disperse_ConstDisp::* doMigration)(void)
Definition: LCEdisperse.h:136
void addParameters(string prefix, ParamUpdaterBase *updater)
Definition: LCEdisperse.cc:62
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
Implementation of the ParamUpdaterBase interface.
Definition: param.h:363

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

Member Function Documentation

◆ clone()

virtual LifeCycleEvent * LCE_Disperse_ConstDisp::clone ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_SeedDisp.

156{return new LCE_Disperse_ConstDisp();}
LCE_Disperse_ConstDisp()
Definition: LCEdisperse.cc:1264

References LCE_Disperse_ConstDisp().

◆ execute()

void LCE_Disperse_ConstDisp::execute ( )
virtual

Implements LifeCycleEvent.

1318{
1319#ifdef _DEBUG_
1320 message("LCE_Disperse_ConstDisp::execute (Patch nb: %i offsprg nb: %i adlt nb: %i "
1322#endif
1323 //check whether the number of patches changed during simulation:
1324 if(_npatch != _popPtr->getPatchNbr()) {
1326 if(!updateDispMatrix()) fatal("bailing out\n");
1327 }
1328
1330
1331 (this->*doMigration)();
1332
1333#ifdef _DEBUG_
1334 unsigned int c = 0;
1335 for(unsigned int i = 0; i < _npatch; i++)
1336 c += _popPtr->getPatch(i)->nbEmigrant;
1337 message("emigrants nb: %i)\n",c);
1338#endif
1339}
void reset_counters()
Definition: LCEdisperse.cc:387
bool updateDispMatrix()
Definition: LCEdisperse.cc:362
unsigned int _npatch
Number of patches in the population.
Definition: LCEdisperse.h:60
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:310
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:452
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 ( )
1344{
1345 Patch *patch;
1346
1347 for(unsigned int i = 0; i < _npatch; i++) {
1348
1349 patch = _popPtr->getPatch(i);
1350
1351 (this->*doPatchMigration)(FEM, i);
1352
1353 (this->*doPatchMigration)(MAL, i);
1354
1355 //set coloniser counter
1356 if(patch->get_isExtinct())
1357 patch->nbKolonisers = patch->size(PDISPx);
1358 else
1359 patch->nbKolonisers = -1; //value used in stat_demo to check for colonization
1360
1361 }//end for nb_patch
1362
1363 //put back the individuals into the offspring container
1364 swapPostDisp();
1365}
void swapPostDisp()
Definition: LCEdisperse.cc:374
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: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().

+ Here is the caller graph for this function:

◆ Migrate_propagule()

void LCE_Disperse_ConstDisp::Migrate_propagule ( )
1370{
1372 Migrate();
1373}
void Migrate()
Definition: LCEdisperse.cc:1343
bool setIsland_PropagulePool_Matrix()
Definition: LCEdisperse.cc:567

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 
)
1378{
1379 Patch* patch = _popPtr->getPatch(LocalPatch);
1380 unsigned int AimedPatch;
1381 unsigned int Limit = _npatch -1;
1382
1383 while( patch->size(SEX, OFFSx) != 0 ) {
1384
1385 do{
1386 AimedPatch = getMigrationPatchForward(SEX, LocalPatch);
1387 }while ( AimedPatch > Limit );
1388
1389 _popPtr->move(SEX, OFFSx, LocalPatch, PDISPx, AimedPatch, 0);
1390
1391 if(LocalPatch != AimedPatch) {
1392 patch->nbEmigrant++;
1393 _popPtr->getPatch(AimedPatch)->nbImigrant++;
1394 } else
1395 patch->nbPhilopat++;
1396
1397 }//end while
1398}
unsigned int getMigrationPatchForward(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1222
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:795
unsigned short nbPhilopat
Definition: metapop.h:452
unsigned short nbImigrant
Definition: metapop.h:452
@ 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().

+ Here is the caller graph for this function:

◆ MigratePatch_AbsorbingBorder()

void LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder ( sex_t  SEX,
unsigned int  LocalPatch 
)
1440{
1441 Patch* patch = _popPtr->getPatch(LocalPatch);
1442 unsigned int AimedPatch;
1443
1444 while( patch->size(SEX, OFFSx) != 0 ) {
1445
1446 do{
1447 AimedPatch = getMigrationPatchForward(SEX, LocalPatch);
1448 }while ( AimedPatch > _npatch );
1449
1450 if(AimedPatch == _npatch) {
1451 _popPtr->recycle( patch->get(SEX, OFFSx, 0) );
1452 patch->remove(SEX, OFFSx, 0);
1453 } else
1454 _popPtr->move(SEX, OFFSx, LocalPatch, PDISPx, AimedPatch, 0);
1455
1456 if(LocalPatch != AimedPatch) {
1457 patch->nbEmigrant++;
1458 if(AimedPatch < _npatch)
1459 _popPtr->getPatch(AimedPatch)->nbImigrant++;
1460 } else
1461 patch->nbPhilopat++;
1462
1463 }//end while
1464}
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:573
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 
)
1403{
1404 Patch* patch = _popPtr->getPatch(LocalPatch);
1405 unsigned int AimedPatch, at;
1406 unsigned int Limit = _npatch -1;
1407
1408 // cycle through the connected patches
1409 for(unsigned int i = 0; i < _reducedDispMat[SEX][LocalPatch].size(); ++i) {
1410
1411 AimedPatch = _reducedDispMat[SEX][LocalPatch][i];
1412
1413 // move as many individual as we can until either the specified number is reached or the patch is empty
1414 for(unsigned int m = _reducedDispMatProba[SEX][LocalPatch][i]; m > 0 && patch->size(SEX, OFFSx) > 0; --m) {
1415
1416 // take an individual at random:
1417 at = RAND::Uniform(patch->size(SEX, OFFSx));
1418
1419 _popPtr->move(SEX, OFFSx, LocalPatch, PDISPx, AimedPatch, at);
1420
1421 if(LocalPatch != AimedPatch) {
1422
1423 patch->nbEmigrant++;
1424
1425 _popPtr->getPatch(AimedPatch)->nbImigrant++;
1426
1427 } else
1428
1429 patch->nbPhilopat++;
1430 }//end for num migrants
1431
1432 }//end for num connected patches
1433
1434 // there might be individuals still in the patch, we keep them there for now
1435}
vector< vector< double > > _reducedDispMatProba[2]
Matrix containing the probability to migrate to/from the connected patches.
Definition: LCEdisperse.h:65
vector< vector< double > > _reducedDispMat[2]
Matrix containing the indexes of the patches connected to each patch.
Definition: LCEdisperse.h:63
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:125

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

+ Here is the caller graph for this function:

◆ setParameters() [1/2]

virtual bool LCE_Disperse_ConstDisp::setParameters ( )
inlinevirtual

Implements SimComponent.

Reimplemented in LCE_SeedDisp.

154{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)
1277{
1278
1279 if(!LCE_Disperse_base::setBaseParameters(prefix)) return false;
1280
1281 switch ( getDispersalModel() ) {
1282 case 0: //dispersal matrix given in input
1283 case 1:
1284 case 3:
1285 case 4:
1287 break;
1288 case 2:
1290 break;
1291 default:
1292 return error("\nDispersal model '%i' not yet implemented\n",getDispersalModel());
1293 }
1294
1295 switch ((int)get_parameter_value(prefix + "_border_model")) {
1296 case -1:
1297 case 1:
1298 case 2:
1300 break;
1301 case 3:
1303 break;
1304 default:
1305 return error("\nDispersal border model '%i' not yet implemented\n",
1306 (int)get_parameter_value(prefix + "_border_model"));
1307 }
1308
1309 if(isByNumber())
1311
1312 return true;
1313}
void MigratePatch_AbsorbingBorder(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1439
void Migrate_propagule()
Definition: LCEdisperse.cc:1369
void MigratePatchByNumber(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1402
void MigratePatch(sex_t SEX, unsigned int LocalPatch)
Definition: LCEdisperse.cc:1377
bool setBaseParameters(string prefix)
Definition: LCEdisperse.cc:88
unsigned int getDispersalModel()
Definition: LCEdisperse.h:107
bool isByNumber()
Definition: LCEdisperse.h:106
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.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR