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

The base class of the dispersal LCEs, all events move offspring to the post-dispersal patch containers. More...

#include <LCEdisperse.h>

+ Inheritance diagram for LCE_Disperse_base:
+ Collaboration diagram for LCE_Disperse_base:

Public Member Functions

 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 ()
 
Dispersal Matrix
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)
 
Accessors
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)
 
Implementations
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 ()
 
virtual void execute ()=0
 Execute the event on the pop. More...
 
virtual LifeCycleEventclone ()=0
 Cloning interface. More...
 
- 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 bool setParameters ()=0
 Default interface needed to initialize the component's variables from its input parameters value. 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...
 

Protected Attributes

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

Private Attributes

int _disp_model
 
double _disp_propagule_prob
 
vector< unsigned int > _PropaguleTargets
 
double _fem_rate
 
double _mal_rate
 
bool _isForward
 
bool _isByNumber
 
TMatrix_DispMatrix [2]
 The sex-specific dispersal matrices, [0] for males, [1] for females, might be used as connectivity matrix as well. More...
 
string _prefix
 Parameter name prefix (dispersal, seed_disp, breed_disp, etc.) More...
 

Friends

class LCE_Disperse_ConstDisp
 
class LCE_Disperse_EvolDisp
 

Detailed Description

The base class of the dispersal LCEs, all events move offspring to the post-dispersal patch containers.

Stores the dispersal matrices and dispersal model parameters and interface.

Constructor & Destructor Documentation

◆ LCE_Disperse_base()

LCE_Disperse_base::LCE_Disperse_base ( )
47 , _fem_rate (-1), _mal_rate(-1), _isForward(1), _isByNumber(0), _npatch(0)
48 {
49  _DispMatrix[0] = NULL;
50  _DispMatrix[1] = NULL;
51 }
TMatrix * _DispMatrix[2]
The sex-specific dispersal matrices, [0] for males, [1] for females, might be used as connectivity ma...
Definition: LCEdisperse.h:54
double _disp_propagule_prob
Definition: LCEdisperse.h:47
bool _isByNumber
Definition: LCEdisperse.h:51
double _fem_rate
Definition: LCEdisperse.h:49
bool _isForward
Definition: LCEdisperse.h:50
int _disp_model
Definition: LCEdisperse.h:46
vector< unsigned int > _PropaguleTargets
Definition: LCEdisperse.h:48
double _mal_rate
Definition: LCEdisperse.h:49
unsigned int _npatch
Number of patches in the population.
Definition: LCEdisperse.h:64
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:98

References _DispMatrix.

◆ ~LCE_Disperse_base()

LCE_Disperse_base::~LCE_Disperse_base ( )
virtual

Deallocates the disp matrix.

54 {
55  if(NULL != _DispMatrix[0])
56  delete _DispMatrix[0];
57 
58  if(NULL != _DispMatrix[1])
59  delete _DispMatrix[1];
60 }

References _DispMatrix.

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_Disperse_base::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_Breed_Selection_Disperse, and LCE_Breed_Disperse.

133 {return NONE;}
#define NONE
No age flag.
Definition: types.h:48

References NONE.

◆ addParameters()

void LCE_Disperse_base::addParameters ( string  prefix,
ParamUpdaterBase updater 
)
63 {
64  add_parameter(prefix + "_model",INT,false,true,1,4,updater);
65  add_parameter(prefix + "_border_model",INT,false,true,1,3,updater);
66  add_parameter(prefix + "_lattice_range",INT,false,true,1,2,updater);
67  add_parameter(prefix + "_lattice_rows",INT,false,false,0,0,updater);
68  add_parameter(prefix + "_lattice_columns",INT,false,false,0,0,updater);
69  add_parameter(prefix + "_propagule_prob",DBL,false,true,0,1,updater);
70  add_parameter(prefix + "_matrix",MAT,false,false,0,0,updater);
71  add_parameter(prefix + "_matrix_fem",STR,false,false,0,0,updater);
72  add_parameter(prefix + "_matrix_mal",STR,false,false,0,0,updater);
73  add_parameter(prefix + "_rate",DBL,false,true,0,1,updater);
74  add_parameter(prefix + "_rate_fem",DBL,false,true,0,1,updater);
75  add_parameter(prefix + "_rate_mal",DBL,false,true,0,1,updater);
76  add_parameter(prefix + "_connectivity_matrix",MAT,false,false,0,0,updater);
77  add_parameter(prefix + "_reduced_matrix",MAT,false,false,0,0,updater);
78  add_parameter(prefix + "_connectivity_matrix_fem",MAT,false,false,0,0,updater);
79  add_parameter(prefix + "_connectivity_matrix_mal",MAT,false,false,0,0,updater);
80  add_parameter(prefix + "_reduced_matrix_fem",MAT,false,false,0,0,updater);
81  add_parameter(prefix + "_reduced_matrix_mal",MAT,false,false,0,0,updater);
82 
83  add_parameter(prefix + "_by_number", BOOL,false,false,0,0,0);
84 }
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
@ DBL
Definition: types.h:78
@ MAT
Definition: types.h:78
@ BOOL
Definition: types.h:78
@ STR
Definition: types.h:78
@ INT
Definition: types.h:78

References SimComponent::add_parameter(), BOOL, DBL, INT, MAT, and STR.

Referenced by LCE_Breed_Disperse::LCE_Breed_Disperse(), LCE_Disperse_ConstDisp::LCE_Disperse_ConstDisp(), LCE_Disperse_EvolDisp::LCE_Disperse_EvolDisp(), and LCE_SeedDisp::LCE_SeedDisp().

◆ allocateDispMatrix()

void LCE_Disperse_base::allocateDispMatrix ( sex_t  sex,
unsigned int  dim 
)
406 {
407  if(_DispMatrix[sex] != NULL)
408  _DispMatrix[sex]->reset(dim,dim);
409  else
410  _DispMatrix[sex] = new TMatrix(dim,dim);
411 }
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:50
void reset(unsigned int rows, unsigned int cols)
Re-allocate the existing matrix with assigned rows and cols dimensions and all elements to 0.
Definition: tmatrix.h:161

References _DispMatrix, and TMatrix::reset().

Referenced by setIsland_MigrantPool_Matrix(), setIsland_PropagulePool_Matrix(), setLatticeMatrix(), and setSteppingStone1DMatrix().

◆ checkBackwardDispersalMatrix()

bool LCE_Disperse_base::checkBackwardDispersalMatrix ( TMatrix mat)
440 {
441  double cntr;
442 
443  for(unsigned int i = 0; i < mat->getNbCols(); ++i) {
444  cntr = 0;
445  for(unsigned int j = 0; j < mat->getNbRows(); ++j) {
446 
447  if(mat->get(i,j) < 0 )
448  return error("elements of the dispersal matrix cannot be negative (row %i, column %i)!\n", i, j);
449 
450  cntr += mat->get(j,i);
451  }
452 
453  if(cntr < 0.999999 || cntr > 1.000001) {
454  error("The elements of column %i of the dispersal matrix do not sum to 1!\n",i+1);
455  error("sum of row %i is: %f\n",i+1, cntr);
456  return false;
457  }
458  }
459  return true;
460 }
unsigned int getNbRows() const
Gives the number of rows.
Definition: tmatrix.h:212
unsigned int getNbCols() const
Gives the number of columns.
Definition: tmatrix.h:215
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:193
int error(const char *str,...)
Definition: output.cc:77

References error(), TMatrix::get(), TMatrix::getNbCols(), and TMatrix::getNbRows().

Referenced by setBaseParameters(), and setDispMatrix().

◆ checkForwardDispersalMatrix()

bool LCE_Disperse_base::checkForwardDispersalMatrix ( TMatrix mat)
416 {
417  double cntr;
418 
419  for(unsigned int i = 0; i < mat->getNbRows(); ++i) {
420  cntr = 0;
421  for(unsigned int j = 0; j < mat->getNbCols(); ++j) {
422 
423  if(mat->get(i,j) < 0 )
424  return error("elements of the dispersal matrix cannot be negative (row %i, column %i)!\n", i, j);
425 
426  cntr += mat->get(i,j);
427  }
428  if(cntr < 0.999999 || cntr > 1.000001) {
429  error("the elements of row %i of the dispersal matrix do not sum to 1!\n",i+1);
430  error("sum of row %i is: %f\n",i+1, cntr);
431  return false;
432  }
433  }
434  return true;
435 }

References error(), TMatrix::get(), TMatrix::getNbCols(), and TMatrix::getNbRows().

Referenced by setBaseParameters(), and setDispMatrix().

◆ getConnectedPatches()

vector< double > LCE_Disperse_base::getConnectedPatches ( sex_t  SEX,
unsigned int  local_patch 
)
1302 {
1303 // vector<double> cpatches = _reducedDispMat[SEX][local_patch];
1304 //
1305 // cpatches.erase(cpatches.begin());
1306 
1307  return _reducedDispMat[SEX][local_patch];
1308 }
vector< vector< double > > _reducedDispMat[2]
Matrix containing the indexes of the patches connected to each patch.
Definition: LCEdisperse.h:67

References _reducedDispMat.

Referenced by LCE_Breed_Selection_Disperse::do_breed(), and LCE_Breed_Disperse::do_breed_disperse_in_empty_patch().

◆ getConnectedRates()

vector< double > LCE_Disperse_base::getConnectedRates ( sex_t  SEX,
unsigned int  local_patch 
)
1313 {
1314 // vector<double> cpatches = _reducedDispMatProba[SEX][local_patch];
1315 
1316 // cpatches.erase(cpatches.begin());
1317 
1318  return _reducedDispMatProba[SEX][local_patch];
1319 }
vector< vector< double > > _reducedDispMatProba[2]
Matrix containing the probability to migrate to/from the connected patches.
Definition: LCEdisperse.h:69

References _reducedDispMatProba.

Referenced by LCE_Breed_Selection_Disperse::do_breed(), LCE_Breed_Disperse::do_breed_disperse_in_empty_patch(), and LCE_Breed_Disperse::do_breed_disperse_in_patch().

◆ getDispersalModel()

◆ getMigrationIndex()

unsigned int LCE_Disperse_base::getMigrationIndex ( vector< double > &  rates)
1276 {
1277  double sum = 0, random = RAND::Uniform();
1278  unsigned int SourcePatch = 0;
1279 
1280  if(random > 0.999999) random = 0.999999;//this to avoid overflows when random == 1
1281 
1282  sum = rates[SourcePatch];
1283 
1284  while (random > sum) {
1285  SourcePatch++;
1286  sum += rates[SourcePatch];
1287  }
1288 
1289  return SourcePatch;
1290 }
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:124

References RAND::Uniform().

◆ getMigrationIndexGSLdiscrete()

unsigned int LCE_Disperse_base::getMigrationIndexGSLdiscrete ( gsl_ran_discrete_t *  rates)
1295 {
1296  return RAND::Discrete(rates);
1297 }
static size_t Discrete(const gsl_ran_discrete_t *g)
Calling the GSL ran_discrete function.
Definition: Uniform.h:813

References RAND::Discrete().

Referenced by LCE_Breed_Disperse::get_parent().

◆ getMigrationPatchBackward()

unsigned int LCE_Disperse_base::getMigrationPatchBackward ( sex_t  SEX,
unsigned int  LocalPatch 
)
1257 {
1258  double sum = 0, random = RAND::Uniform();
1259  unsigned int SourcePatch = 0;
1260 
1261  if(random > 0.999999) random = 0.999999;//this to avoid overflows when random == 1
1262 
1263  sum = _reducedDispMatProba[SEX][LocalPatch][SourcePatch];
1264 
1265  while (random > sum) {
1266  SourcePatch++;
1267  sum += _reducedDispMatProba[SEX][LocalPatch][SourcePatch];
1268  }
1269 
1270  return _reducedDispMat[SEX][LocalPatch][SourcePatch];
1271 }

References _reducedDispMat, _reducedDispMatProba, and RAND::Uniform().

◆ getMigrationPatchForward()

unsigned int LCE_Disperse_base::getMigrationPatchForward ( sex_t  SEX,
unsigned int  LocalPatch 
)
1237 {
1238  double sum = 0, random = RAND::Uniform();
1239  unsigned int AimedPatch = 0;
1240 
1241  if(random > 0.999999) random = 0.999999;//this to avoid overflows when random == 1
1242 
1243  sum = _reducedDispMatProba[SEX][LocalPatch][AimedPatch];
1244 
1245  while (random > sum) {
1246  AimedPatch++;
1247  sum += _reducedDispMatProba[SEX][LocalPatch][AimedPatch];
1248  }
1249 
1250  //return the patch ID stored in the connectivity matrix:
1251  return _reducedDispMat[SEX][LocalPatch][AimedPatch];
1252 }

References _reducedDispMat, _reducedDispMatProba, and RAND::Uniform().

Referenced by LCE_Disperse_ConstDisp::MigratePatch(), and LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder().

◆ getPropaguleProb()

double LCE_Disperse_base::getPropaguleProb ( )
inline

◆ getPropaguleTarget()

unsigned int LCE_Disperse_base::getPropaguleTarget ( unsigned int  home)
inline

◆ getReducedDispersalPatchID()

unsigned int LCE_Disperse_base::getReducedDispersalPatchID ( sex_t  SEX,
unsigned int  row,
unsigned int  col 
)
1334 {
1335  if(col < _reducedDispMat[SEX][row].size())
1336  return _reducedDispMat[SEX][row][col];
1337  else
1338  return -1;
1339 }

References _reducedDispMat.

Referenced by LCE_Breed_Disperse::get_parent().

◆ getReducedDispersalRate()

double LCE_Disperse_base::getReducedDispersalRate ( sex_t  SEX,
unsigned int  row,
unsigned int  col 
)
1324 {
1325  if(col < _reducedDispMatProba[SEX][row].size())
1326  return _reducedDispMatProba[SEX][row][col];
1327  else
1328  return -1.0;
1329 }

References _reducedDispMatProba.

◆ isByNumber()

bool LCE_Disperse_base::isByNumber ( )
inline
114 {return _isByNumber;}

References _isByNumber.

Referenced by LCE_Disperse_ConstDisp::setParameters().

◆ isForward()

bool LCE_Disperse_base::isForward ( )
inline
113 {return _isForward;}

References _isForward.

◆ loadFileServices()

virtual void LCE_Disperse_base::loadFileServices ( FileServices loader)
inlinevirtual

Implements SimComponent.

Reimplemented in LCE_Breed_Selection_Disperse, and LCE_Breed_Disperse.

129 {}

◆ loadStatServices()

virtual void LCE_Disperse_base::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

Reimplemented in LCE_Breed_Selection_Disperse, and LCE_Breed_Disperse.

130 {}

◆ removeAgeClass()

virtual age_t LCE_Disperse_base::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_Breed_Selection_Disperse, and LCE_Breed_Disperse.

132 {return NONE;}

References NONE.

◆ requiredAgeClass()

virtual age_t LCE_Disperse_base::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_Breed_Selection_Disperse, and LCE_Breed_Disperse.

134 {return OFFSPRG;}
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50

References OFFSPRG.

◆ reset_counters()

void LCE_Disperse_base::reset_counters ( )
391 {
392  Patch *patch;
393  for(unsigned int i = 0; i < _npatch; i++) {
394 
395  patch = _popPtr->getPatch(i);
396 
397  patch->reset_counters();
398 
399  patch->flush(PDISPx, _popPtr);
400  }
401 }
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:432
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
void reset_counters()
Definition: patch.cc:56
@ PDISPx
Definition: types.h:42

References _npatch, LifeCycleEvent::_popPtr, Patch::flush(), Metapop::getPatch(), PDISPx, and Patch::reset_counters().

Referenced by LCE_Breed_Disperse::execute(), LCE_Breed_Selection_Disperse::execute(), LCE_Disperse_ConstDisp::execute(), and LCE_Disperse_EvolDisp::execute().

◆ resetParameterFromSource()

virtual bool LCE_Disperse_base::resetParameterFromSource ( std::string  param,
SimComponent cmpt 
)
inlinevirtual

Implements SimComponent.

Reimplemented in LCE_Breed_Selection_Disperse, and LCE_Breed_Disperse.

131 {return false;}

◆ set_isForward()

void LCE_Disperse_base::set_isForward ( bool  val)
inline
85 {_isForward = val;}

References _isForward.

Referenced by LCE_Breed_Disperse::setParameters().

◆ setBaseParameters()

bool LCE_Disperse_base::setBaseParameters ( string  prefix)
89 {
90  _prefix = prefix;
91 
93 
94  _disp_model = (int)_paramSet->getValue(prefix + "_model");
95 
96  _disp_propagule_prob = _paramSet->getValue(prefix + "_propagule_prob");
97 
98  if(get_parameter(prefix + "_by_number")->isSet())
99  _isByNumber = true;
100  else
101  _isByNumber = false;
102 
103  // SET MATRICES FROM INPUT MODELS --------------------------------------------------------
104 
105  if(_DispMatrix[0]) delete _DispMatrix[0];
106  _DispMatrix[0] = NULL;
107 
108  if(_DispMatrix[1]) delete _DispMatrix[1];
109  _DispMatrix[1] = NULL;
110 
111  //skip this if there is only one patch
112 // if(_npatch == 1) {
113 // warning("not setting the dispersal LCE whith only one patch in the population\n");
114 // return false;
115 // }
116 
117  // connectivity matrix is specified in input --------------------------------------------
118 
119  if( (_paramSet->isSet(prefix + "_connectivity_matrix") && _paramSet->isSet(prefix + "_reduced_matrix") ) ||
120  (_paramSet->isSet(prefix + "_connectivity_matrix_mal") && _paramSet->isSet(prefix + "_reduced_matrix_mal") ) ||
121  (_paramSet->isSet(prefix + "_connectivity_matrix_fem") && _paramSet->isSet(prefix + "_reduced_matrix_fem")) )
122  {
123 
124  _disp_model=0;
125 
126  // both sex identical matrices
127  if(_paramSet->isSet(prefix + "_connectivity_matrix") && _paramSet->isSet(prefix + "_reduced_matrix")){
128  if( ! setReducedMatricesBySex(FEM, (*get_parameter(prefix + "_connectivity_matrix")), (*get_parameter(prefix + "_reduced_matrix"))) )
129  return false;
130  if( ! setReducedMatricesBySex(MAL, (*get_parameter(prefix + "_connectivity_matrix")), (*get_parameter(prefix + "_reduced_matrix"))) )
131  return false;
132  }
133 
134  // female specific matrices
135  if(_paramSet->isSet(prefix + "_connectivity_matrix_fem") && _paramSet->isSet(prefix + "_reduced_matrix_fem")){
136  if( ! setReducedMatricesBySex(FEM, (*get_parameter(prefix + "_connectivity_matrix_fem")), (*get_parameter(prefix + "_reduced_matrix_fem"))) )
137  return false;
138  }
139 
140  // male specific matrices
141  if(_paramSet->isSet(prefix + "_connectivity_matrix_mal") && _paramSet->isSet(prefix + "_reduced_matrix_mal")){
142  if( ! setReducedMatricesBySex(MAL, (*get_parameter(prefix + "_connectivity_matrix_mal")), (*get_parameter(prefix + "_reduced_matrix_mal"))) )
143  return false;
144  }
145 
146  if( (_paramSet->isSet(prefix + "_connectivity_matrix_fem") && !_paramSet->isSet(prefix + "_connectivity_matrix_mal") ) ||
147  (_paramSet->isSet(prefix + "_connectivity_matrix_mal") && !_paramSet->isSet(prefix + "_connectivity_matrix_fem") ))
148  return error("both \"%s_connectivity_matrix\" and \"%s_reduced_matrix\" must be set for each sex together\n", prefix.c_str(), prefix.c_str());
149 
150 
151 #ifdef _DEBUG_
152  cout << "=== female reduced dispersal matrix ===\n";
153  for (unsigned int i = 0; i < _npatch; ++i) {
154  cout << " [";
155  for (unsigned int k = 0; k < _reducedDispMat[FEM][i].size(); k++) {
156  cout << _reducedDispMatProba[FEM][i][k] << " [" << _reducedDispMat[FEM][i][k] <<"] ";
157  }
158  cout<<"]\n";
159  }
160 
161  cout << "=== male reduced dispersal matrix ===\n";
162  for (unsigned int i = 0; i < _npatch; ++i) {
163  cout << " [";
164  for (unsigned int k = 0; k < _reducedDispMat[MAL][i].size(); k++) {
165  cout << _reducedDispMatProba[MAL][i][k] << " [" << _reducedDispMat[MAL][i][k] <<"] ";
166  }
167  cout<<"]\n";
168 
169  }
170 #endif
171 
172  }
173  // dispersal matrix is specified in input -----------------------------------------------
174 
175  else if ( (_paramSet->isSet(prefix + "_connectivity_matrix") &&
176  !_paramSet->isSet(prefix + "_reduced_matrix")) ||
177  (!_paramSet->isSet(prefix + "_connectivity_matrix") &&
178  _paramSet->isSet(prefix + "_reduced_matrix")))
179 
180  {
181  return error("both \"%s_connectivity_matrix\" and \"%s_reduced_matrix\" must be set together\n", prefix.c_str(), prefix.c_str());
182  }
183 
184  // connectivity or reduced matrices not given in input
185  else
186 
187  {
188 
189  if(_paramSet->isSet(prefix + "_matrix")) {
190 
191  _DispMatrix[0] = new TMatrix();
192 
193  _paramSet->getMatrix(prefix + "_matrix",_DispMatrix[0]);
194 
195  //same dispersal matrix for males and females
196  _DispMatrix[1] = new TMatrix(*_DispMatrix[0]);
197 
198  } else {
199 
200  if(_paramSet->isSet(prefix + "_matrix_fem")) {
201 
202  _DispMatrix[FEM] = new TMatrix();
203 
204  _paramSet->getMatrix(prefix + "_matrix_fem",_DispMatrix[FEM]);
205 
206  }
207 
208  if(_paramSet->isSet(prefix + "_matrix_mal")) {
209 
210  _DispMatrix[MAL] = new TMatrix();
211 
212  _paramSet->getMatrix(prefix + "_matrix_mal",_DispMatrix[MAL]);
213 
214  }
215  }
216 
217  if( _paramSet->isSet(prefix + "_matrix") ||
218  ( _paramSet->isSet(prefix + "_matrix_fem") && _paramSet->isSet(prefix + "_matrix_mal") ) )
219  {
220 
221  if( ( _paramSet->isSet(prefix + "_rate") ||
222  ( _paramSet->isSet(prefix + "_rate_fem") && _paramSet->isSet(prefix + "_rate_mal")) )
223  || _paramSet->isSet(prefix + "_model") )
224  warning("parameter \"dispersal_matrix\" takes precedence over parameters \"dispersal_rate\" and \"dispersal_model\"\n");
225 
226  _disp_model = 0;
227 
228  if(_DispMatrix[FEM]) {
229 
230  //check if we want the Identity matrix
231  if(_DispMatrix[FEM]->length() == 1 && _DispMatrix[FEM]->get(0,0) == 1)
233 
234  //check dimensions
235  if(_DispMatrix[FEM]->length() != _npatch*_npatch)
236  return error("the size of the female dispersal matrix is not equal to patch_number X patch_number (%i[%i,%i] != %i)!\n",
237  _DispMatrix[FEM]->length(),_DispMatrix[FEM]->getNbRows(),_DispMatrix[FEM]->getNbCols(),_npatch*_npatch);
238 
239  //check that migration rates sum to 1 per row or column
240  if(!_isByNumber) {
241  if(_isForward) {
242  if(!checkForwardDispersalMatrix(_DispMatrix[FEM])) return false;
243  } else {
244  if(!checkBackwardDispersalMatrix(_DispMatrix[FEM])) return false;
245  }
246  }
247  }
248 
249  if(_DispMatrix[MAL]) {
250 
251  //check if we want the Identity matrix
252  if(_DispMatrix[MAL]->length() == 1 && _DispMatrix[MAL]->get(0,0) == 1)
254 
255  //check dimensions
256  if(_DispMatrix[MAL]->length() != _npatch*_npatch)
257  return error("the size of the male dispersal matrix is not equal to patch_number X patch_number (%i[%i,%i] != %i)!\n",
258  _DispMatrix[MAL]->length(),_DispMatrix[MAL]->getNbRows(),_DispMatrix[MAL]->getNbCols(),_npatch*_npatch);
259 
260 
261  //check that migration rates sum to 1 per row or column
262  if(!_isByNumber) {
263  if(_isForward) {
264  if(!checkForwardDispersalMatrix(_DispMatrix[MAL])) return false;
265  } else {
266  if(!checkBackwardDispersalMatrix(_DispMatrix[MAL])) return false;
267  }
268  }
269  }
270 
272 
273  // dispersal rate is given in input ---------------------------------------------------
274  } else {
275 
276  if(!_paramSet->isSet(prefix + "_model")) return error("Dispersal model is not set!\n");
277 
278  if(_paramSet->isSet(prefix + "_rate"))
279 
280  {
281 
282  _fem_rate = _mal_rate = _paramSet->getValue(prefix + "_rate");
283 
284  if(!setDispMatrix()) return false;
285 
286  }
287 
288  else if( _paramSet->isSet(prefix + "_rate_fem") && _paramSet->isSet(prefix + "_rate_mal") )
289 
290  {
291  _fem_rate = _paramSet->getValue(prefix + "_rate_fem");
292 
293  _mal_rate = _paramSet->getValue(prefix + "_rate_mal");
294 
295  if(!setDispMatrix()) return false;
296  }
297 
298  else {
299  return error("Dispersal rate parameters not set!\n");
300  }
301 
302  }
303 
304  }
305  return true;
306 }
bool setReducedDispMatrix()
The reduced dispersal matrix contains the indices of the patches to which each patch is connected.
Definition: LCEdisperse.cc:1109
bool setDispMatrix()
Definition: LCEdisperse.cc:516
bool checkBackwardDispersalMatrix(TMatrix *mat)
Definition: LCEdisperse.cc:439
string _prefix
Parameter name prefix (dispersal, seed_disp, breed_disp, etc.)
Definition: LCEdisperse.h:57
bool setReducedMatricesBySex(sex_t SEX, Param &connectivity, Param &rate)
Definition: LCEdisperse.cc:310
void setIndentityDispMatrix(TMatrix *mat)
Definition: LCEdisperse.cc:356
bool checkForwardDispersalMatrix(TMatrix *mat)
Definition: LCEdisperse.cc:415
unsigned int getPatchNbr()
Definition: metapop.h:276
void getMatrix(string name, TMatrix *mat)
Accessor to the parameters matrix.
Definition: param.h:304
double getValue(string name)
Accessor the parameters value.
Definition: param.h:302
bool isSet()
Accessor to the status flag.
Definition: param.h:288
bool isSet()
Definition: param.h:140
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48
void warning(const char *str,...)
Definition: output.cc:58
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37

References _disp_model, _disp_propagule_prob, _DispMatrix, _fem_rate, _isByNumber, _isForward, _mal_rate, _npatch, SimComponent::_paramSet, LifeCycleEvent::_popPtr, _prefix, _reducedDispMat, _reducedDispMatProba, checkBackwardDispersalMatrix(), checkForwardDispersalMatrix(), error(), FEM, SimComponent::get_parameter(), ParamSet::getMatrix(), Metapop::getPatchNbr(), ParamSet::getValue(), Param::isSet(), ParamSet::isSet(), MAL, setDispMatrix(), setIndentityDispMatrix(), setReducedDispMatrix(), setReducedMatricesBySex(), and warning().

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

◆ setBasicLatticeMatrix()

bool LCE_Disperse_base::setBasicLatticeMatrix ( int  rows,
int  cols,
double  phi_mal,
double  phi_fem,
double  disp_mal,
double  disp_fem 
)
787 {
788  TMatrix* mmat = _DispMatrix[MAL];
789  TMatrix* fmat = _DispMatrix[FEM];
790 
791  //init:
792  fmat->assign(0.0);
793  mmat->assign(0.0);
794 
795  TMatrix grid(rows, cols);
796 
797  int p = 0;
798  for (int i = 0; i < rows; ++i) {
799  for (int j = 0; j < cols ; ++j) {
800  grid.set(i, j, p++);
801  }
802  }
803  assert( p == rows*cols );
804 
805  //diagonal:
806  for (unsigned int i = 0; i < _npatch; ++i){
807  fmat->set(i, i, phi_fem);
808  mmat->set(i, i, phi_mal);
809  }
810 
811  int connect;
812 
813  for (int x = 0; x < rows; ++x) {
814  for (int y = 0; y < cols; ++y) {
815 
816  p = grid.get(x, y);
817 
818  connect = p + 1; //patch to the right
819 
820  if (connect < (x + 1)*cols) { //stay on the same row
821  fmat->set(p, connect, disp_fem);
822  mmat->set(p, connect, disp_mal);
823  }
824 
825  connect = p - 1; //patch to the left
826 
827  if (connect >= x*cols ) {
828  fmat->set(p, connect, disp_fem);
829  mmat->set(p, connect, disp_mal);
830  }
831 
832  connect = p + cols; //patch one row up
833 
834  if (connect < (int)_npatch ) {
835  fmat->set(p, connect, disp_fem);
836  mmat->set(p, connect, disp_mal);
837  }
838 
839  connect = p - cols; //patch one row down
840 
841  if (connect >= 0 ) {
842  fmat->set(p, connect, disp_fem);
843  mmat->set(p, connect, disp_mal);
844  }
845 
846  //diagonal steps:
847  if((unsigned int)get_parameter_value(_prefix + "_lattice_range") == 2) {
848 
849  connect = p + cols; //patches one row up
850 
851  if (connect < (int)_npatch ) { //we are not on the last row
852 
853  if (connect + 1 < (x + 2)*cols) { //do not reach past the right border
854  fmat->set(p, connect + 1, disp_fem);
855  mmat->set(p, connect + 1, disp_mal);
856  }
857 
858  if (connect - 1 >= (x + 1)*cols) { //do not reach past the left border
859  fmat->set(p, connect - 1, disp_fem);
860  mmat->set(p, connect - 1, disp_mal);
861  }
862  }
863 
864  connect = p - cols; //patches one row down
865 
866  if (connect >= 0) { //we are not on the first row
867 
868  if (connect + 1 < (x + 1)*cols) {
869  fmat->set(p, connect + 1, disp_fem);
870  mmat->set(p, connect + 1, disp_mal);
871  }
872 
873  if (connect - 1 >= (x - 1)*cols) {
874  fmat->set(p, connect - 1, disp_fem);
875  mmat->set(p, connect - 1, disp_mal);
876  }
877  }
878  } //lattice range == 2
879 
880  } //y
881  } //x
882 
883  switch((unsigned int)get_parameter_value(_prefix + "_border_model")) {
884  case 1:
885  return setLatticeTorrusMatrix(rows, cols, disp_mal, disp_fem, &grid);
886  case 2:
887  return setLatticeReflectingMatrix(rows, cols, &grid);
888  case 3:
889  return setLatticeAbsorbingMatrix();
890  default:
891  error("parameter \"%s_border_model\" accepts only three values: [1,2,3]\n", _prefix.c_str());
892  break;
893  }
894 
895  return false;
896 }
bool setLatticeTorrusMatrix(int rows, int cols, double disp_mal, double disp_fem, TMatrix *grid)
Definition: LCEdisperse.cc:900
bool setLatticeAbsorbingMatrix()
Definition: LCEdisperse.cc:1051
bool setLatticeReflectingMatrix(int rows, int cols, TMatrix *grid)
Definition: LCEdisperse.cc:1010
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
void set(unsigned int i, unsigned int j, double val)
Sets element at row i and column j to value val.
Definition: tmatrix.h:103
void assign(double val)
Assigns a value to all element of the matrix.
Definition: tmatrix.h:155

References _DispMatrix, _npatch, _prefix, TMatrix::assign(), error(), FEM, TMatrix::get(), SimComponent::get_parameter_value(), MAL, TMatrix::set(), setLatticeAbsorbingMatrix(), setLatticeReflectingMatrix(), and setLatticeTorrusMatrix().

Referenced by setLatticeMatrix().

◆ setDispMatrix()

bool LCE_Disperse_base::setDispMatrix ( )
517 {
518 
519  switch ( getDispersalModel() ) {
520  case 1:
521  if( !setIsland_MigrantPool_Matrix() ) return false;
522  break;
523  case 2:
524  if( !setIsland_PropagulePool_Matrix() ) return false;
525  break;
526  case 3:
527  if( !setSteppingStone1DMatrix() ) return false;
528  break;
529  case 4:
530  if( !setLatticeMatrix() ) return false;
531  break;
532  default:
533  return error("Dispersal model '%i' not yet implemented\n",getDispersalModel());
534  }
535 
536  if(_isForward) {
537  if(!checkForwardDispersalMatrix(_DispMatrix[FEM])) return false;
538  if(!checkForwardDispersalMatrix(_DispMatrix[MAL])) return false;
539  } else {
540  if(!checkBackwardDispersalMatrix(_DispMatrix[FEM])) return false;
541  if(!checkBackwardDispersalMatrix(_DispMatrix[MAL])) return false;
542  }
543 
544  return setReducedDispMatrix();
545 }
bool setSteppingStone1DMatrix()
Definition: LCEdisperse.cc:636
bool setIsland_MigrantPool_Matrix()
Definition: LCEdisperse.cc:549
bool setIsland_PropagulePool_Matrix()
Definition: LCEdisperse.cc:581
bool setLatticeMatrix()
Sets the dispersal matrices for the Lattice dispersal model.
Definition: LCEdisperse.cc:723
unsigned int getDispersalModel()
Definition: LCEdisperse.h:115

References _DispMatrix, _isForward, checkBackwardDispersalMatrix(), checkForwardDispersalMatrix(), error(), FEM, getDispersalModel(), MAL, setIsland_MigrantPool_Matrix(), setIsland_PropagulePool_Matrix(), setLatticeMatrix(), setReducedDispMatrix(), and setSteppingStone1DMatrix().

Referenced by setBaseParameters(), and updateDispMatrix().

◆ setIndentityDispMatrix()

void LCE_Disperse_base::setIndentityDispMatrix ( TMatrix mat)
357 {
358  mat->reset(_npatch, _npatch);
359  mat->assign(0);
360  for(unsigned int i = 0; i < _npatch; ++i) mat->set(i, i, 1);
361 }

References _npatch, TMatrix::assign(), TMatrix::reset(), and TMatrix::set().

Referenced by setBaseParameters().

◆ setIsland_MigrantPool_Matrix()

bool LCE_Disperse_base::setIsland_MigrantPool_Matrix ( )
550 {
551 #ifdef _DEBUG_
552  cout<<"setIsland_MigrantPool_Matrix(_npatch="<<_npatch<<", _mal_rate="
553  <<_mal_rate<<", _fem_rate="<<_fem_rate<<")"<<endl;
554 #endif
557 
558  TMatrix* mmat = _DispMatrix[MAL];
559  TMatrix* fmat = _DispMatrix[FEM];
560  double pmal = 1 - _mal_rate;
561  double pfem = 1 - _fem_rate;
562  double mmal = _mal_rate/(_npatch-1);
563  double mfem = _fem_rate/(_npatch-1);
564 
565  for (unsigned int i=0; i<_npatch; ++i){
566  for (unsigned int j=0; j<_npatch; ++j){
567  mmat->set(i,j, mmal);
568  fmat->set(i,j, mfem);
569  }
570  }
571 
572  for (unsigned int i=0; i<_npatch; ++i){
573  mmat->set(i,i, pmal);
574  fmat->set(i,i, pfem);
575  }
576  return true;
577 }
void allocateDispMatrix(sex_t sex, unsigned int dim)
Definition: LCEdisperse.cc:405

References _DispMatrix, _fem_rate, _mal_rate, _npatch, allocateDispMatrix(), FEM, MAL, and TMatrix::set().

Referenced by setDispMatrix().

◆ setIsland_PropagulePool_Matrix()

bool LCE_Disperse_base::setIsland_PropagulePool_Matrix ( )
582 {
583 #ifdef _DEBUG_
584  cout<<"setIsland_PropagulePool_Matrix(_npatch="<<_npatch<<", _mal_rate="
585  <<_mal_rate<<", _fem_rate="<<_fem_rate<<")"<<endl;
586 #endif
587 
590 
591  if( !_paramSet->isSet(_prefix + "_propagule_prob") ) {
592  error("Missing parameter \"dispersal_propagule_prob\" with dispersal model 2!\n");
593  return false;
594  }
595 
597 
598  double propagulePHI = getPropaguleProb();
599  double c1 = (1 - _fem_rate), c2 = (_fem_rate*propagulePHI),
600  c3 = (_fem_rate*(1.0 - propagulePHI)/(_npatch-2));
601 
602  TMatrix* mmat = _DispMatrix[MAL];
603  TMatrix* fmat = _DispMatrix[FEM];
604 
605  for (unsigned int i=0; i < _npatch; ++i){
606 
607  fmat->set(i, i, c1);
608 
609  for (unsigned int j=i+1; j < _npatch; ++j){
610  fmat->set(i, j, c3);
611  fmat->set(j, i, c3);
612  }
613  fmat->set(i, getPropaguleTarget(i), c2);
614  }
615 
616  c1 = (1 - _mal_rate);
617  c2 = (_mal_rate*propagulePHI);
618  c3 = (_mal_rate*(1.0 - propagulePHI)/(_npatch-2));
619 
620  for (unsigned int i=0; i < _npatch; ++i){
621 
622  mmat->set(i, i, c1);
623 
624  for (unsigned int j=i+1; j< _npatch; ++j) {
625  mmat->set(i, j, c3);
626  mmat->set(j, i, c3);
627  }
628  mmat->set(i, getPropaguleTarget(i), c2);
629  }
630 
631  return true;
632 }
unsigned int getPropaguleTarget(unsigned int home)
Definition: LCEdisperse.h:117
double getPropaguleProb()
Definition: LCEdisperse.h:116
void setPropaguleTargets()
Definition: LCEdisperse.cc:464

References _DispMatrix, _fem_rate, _mal_rate, _npatch, SimComponent::_paramSet, _prefix, allocateDispMatrix(), error(), FEM, getPropaguleProb(), getPropaguleTarget(), ParamSet::isSet(), MAL, TMatrix::set(), and setPropaguleTargets().

Referenced by LCE_Breed_Selection_Disperse::breed_selection_disperse_propagule(), LCE_Breed_Disperse::do_breed_disperse_propagule(), LCE_Disperse_ConstDisp::Migrate_propagule(), and setDispMatrix().

◆ setLatticeAbsorbingMatrix()

bool LCE_Disperse_base::setLatticeAbsorbingMatrix ( )
1052 {
1053  TMatrix* mmat = _DispMatrix[MAL];
1054  TMatrix* fmat = _DispMatrix[FEM];
1055 
1056  fmat->set(_npatch, _npatch, 1.0);
1057  mmat->set(_npatch, _npatch, 1.0);
1058 
1059  double sum;
1060 
1061  if(_isForward) {
1062  //set the absorbing patch probs to 1 - sum(row)
1063  for(unsigned int i = 0; i < _npatch; ++i) {
1064  sum = 0;
1065  for (unsigned int j = 0; j < _npatch; ++j) {
1066  sum += fmat->get(i, j);
1067  }
1068  fmat->set(i, _npatch, 1.0 - sum);
1069  }
1070 
1071  for(unsigned int i = 0; i < _npatch; ++i) {
1072  sum = 0;
1073  for (unsigned int j = 0; j < _npatch; ++j) {
1074  sum += mmat->get(i, j);
1075  }
1076  mmat->set(i, _npatch, 1.0 - sum);
1077  }
1078  //backward migration:
1079  }else {
1080  //the missing immigrant rate from non-existing patches must be added to the "philopatric" rate
1081  for(unsigned int i = 0; i < _npatch; ++i) {
1082  sum = 0;
1083  for (unsigned int j = 0; j < _npatch; ++j) {
1084  sum += fmat->get(j, i);
1085  }
1086  fmat->plus(i, i, 1.0 - sum);
1087  }
1088 
1089  for(unsigned int i = 0; i < _npatch; ++i) {
1090  sum = 0;
1091  for (unsigned int j = 0; j < _npatch; ++j) {
1092  sum += mmat->get(j, i);
1093  }
1094  mmat->plus(i, i, 1.0 - sum);
1095  }
1096  }
1097 
1098  return true;
1099 }
void plus(unsigned int i, unsigned int j, double value)
Adds a value to an element of the matrix.
Definition: tmatrix.h:256

References _DispMatrix, _isForward, _npatch, FEM, TMatrix::get(), MAL, TMatrix::plus(), and TMatrix::set().

Referenced by setBasicLatticeMatrix().

◆ setLatticeMatrix()

bool LCE_Disperse_base::setLatticeMatrix ( )

Sets the dispersal matrices for the Lattice dispersal model.

Each matrix has 'patch number' x 'patch number' cells unless the lattice model is the absorbing boundaries model where we add the sink patch.

The "dispersal_lattice_range" parameter defines the number of neighbouring patches to disperse into. Option 1 sets this number to 4 (left and right, up and down patches) whereas option 2 allows to disperse to the 8 neighbouring patches, including the patches on the diagonals.

724 {
725 #ifdef _DEBUG_
726  message("setLatticeMatrix()\n");
727 #endif
728  if(!_paramSet->isSet(_prefix + "_border_model"))
729  return error("Missing parameter \"dispersal_border_model\" with dispersal model 4!\n");
730 
731  if(!_paramSet->isSet(_prefix + "_lattice_range") )
732  return error("Missing parameter \"dispersal_lattice_range\" with dispersal model 4!\n");
733 
734  int rows, cols;
735 
736  if( !_paramSet->isSet(_prefix + "_lattice_rows") && !_paramSet->isSet(_prefix + "_lattice_columns") ) {
737 
738  rows = cols = (int) sqrt((double)_npatch);
739 
740  if( rows*cols != (int)_npatch )
741  return error("The number of patches is not a square number in the lattice dispersal model\n");
742 
743  } else {
744 
745  rows = _paramSet->getValue(_prefix + "_lattice_rows");
746 
747  cols = _paramSet->getValue(_prefix + "_lattice_columns");
748 
749  if(rows == -1) return error("number of rows of the dispersal lattice is not specified\n");
750  if(cols == -1) return error("number of columns of the dispersal lattice is not specified\n");
751 
752  if( rows*cols != (int)_npatch ){
753  error("The size of the dispersal matrix in the lattice model is not equal to the number of patches,\n");
754  return error("parameters %s_lattice_rows and %s_lattice_columns must be set.\n", _prefix.c_str(), _prefix.c_str());
755  }
756  }
757 
760  if((unsigned int)get_parameter_value(_prefix + "_border_model") == 3) {
763  } else {
766  }
767 
771  unsigned int range = (unsigned int)get_parameter_value(_prefix + "_lattice_range");
772  //philopatry:
773  double pmal = 1 - _mal_rate, pfem = 1 - _fem_rate;
774  //migration:
775  double mmal = _mal_rate/(range == 1 ? 4 : 8), mfem = _fem_rate/(range == 1 ? 4 : 8);
776 
777  setBasicLatticeMatrix(rows, cols, pmal, pfem, mmal, mfem);
778 
779 
780  return true;
781 }
bool setBasicLatticeMatrix(int rows, int cols, double phi_mal, double phi_fem, double disp_mal, double disp_fem)
Definition: LCEdisperse.cc:785
void message(const char *message,...)
Definition: output.cc:40

References _fem_rate, _mal_rate, _npatch, SimComponent::_paramSet, _prefix, allocateDispMatrix(), error(), FEM, SimComponent::get_parameter_value(), ParamSet::getValue(), ParamSet::isSet(), MAL, message(), and setBasicLatticeMatrix().

Referenced by setDispMatrix(), and LCE_Disperse_EvolDisp::setParameters().

◆ setLatticeReflectingMatrix()

bool LCE_Disperse_base::setLatticeReflectingMatrix ( int  rows,
int  cols,
TMatrix grid 
)
1011 {
1012  TMatrix* mmat = _DispMatrix[MAL];
1013  TMatrix* fmat = _DispMatrix[FEM];
1014 
1015  vector<unsigned int> border_cells;
1016 
1017  for (unsigned int i = 0; i < _npatch; ++i) {
1018 
1019  for (int j = 0; j < cols; ++j)
1020  border_cells.push_back( j ); //first row
1021 
1022  for (int j = 1; j < rows - 1; ++j) { //intermediate rows, only the two border cells
1023  border_cells.push_back( j*cols );
1024  border_cells.push_back( (j + 1)*cols - 1 );
1025  }
1026 
1027  for (unsigned int j = cols*(rows-1); j < _npatch; ++j)
1028  border_cells.push_back( j ); //last row
1029 
1030  }
1031 
1032  double sum;
1033  // individuals who can't disperse past the border stay in place:
1034  for (unsigned int i = 0; i < border_cells.size(); ++i) {
1035  //sum of dispersal rates:
1036  sum = fmat->rowSum( border_cells[i] ) - fmat->get(border_cells[i], border_cells[i]);
1037  //difference gives 1 - m:
1038  fmat->set(border_cells[i], border_cells[i], 1 - sum);
1039 
1040  sum = mmat->rowSum( border_cells[i] ) - mmat->get(border_cells[i], border_cells[i]);
1041  mmat->set(border_cells[i], border_cells[i], 1 - sum);
1042  }
1043 
1044  if(!_isForward) { fmat->transpose(); mmat->transpose(); }
1045 
1046  return true;
1047 }
void transpose()
Transpose the matrix, swaps columns for rows.
Definition: tmatrix.h:297
double rowSum(unsigned int row)
Sum all elements in a row.
Definition: tmatrix.h:318

References _DispMatrix, _isForward, _npatch, FEM, TMatrix::get(), MAL, TMatrix::rowSum(), TMatrix::set(), and TMatrix::transpose().

Referenced by setBasicLatticeMatrix().

◆ setLatticeTorrusMatrix()

bool LCE_Disperse_base::setLatticeTorrusMatrix ( int  rows,
int  cols,
double  disp_mal,
double  disp_fem,
TMatrix grid 
)
901 {
902  TMatrix* mmat = _DispMatrix[MAL];
903  TMatrix* fmat = _DispMatrix[FEM];
904 
905  int x, y;
906 
907  x = 0; //first row, connect with upper row
908  for (y = 0; y < cols; ++y) {
909  fmat->set( grid->get(x, y), grid->get( rows-1, y ), disp_fem);
910  mmat->set( grid->get(x, y), grid->get( rows-1, y ), disp_mal);
911  }
912 
913  x = rows - 1; //last row, connect with bottom row
914  for (y = 0; y < cols; ++y) {
915  fmat->set( grid->get(x, y), grid->get( 0, y ), disp_fem);
916  mmat->set( grid->get(x, y), grid->get( 0, y ), disp_mal);
917  }
918 
919  y = 0; //left column, connect with right-most column
920  for (x = 0; x < rows; ++x) {
921  fmat->set( grid->get(x, y), grid->get( x, cols - 1 ), disp_fem);
922  mmat->set( grid->get(x, y), grid->get( x, cols - 1 ), disp_mal);
923  }
924 
925  y = cols - 1; //right-most column, connect with left-most column
926  for (x = 0; x < rows; ++x) {
927  fmat->set( grid->get(x, y), grid->get( x, 0 ), disp_fem);
928  mmat->set( grid->get(x, y), grid->get( x, 0 ), disp_mal);
929  }
930 
931  //connect along diagonals
932 
933  if((int)get_parameter_value(_prefix + "_lattice_range") == 2) {
934 
935 
936  //CORNERS:
937 
938  //first patch on first row, wrap around to top right border (last patch)
939  fmat->set( grid->get(0, 0), grid->get( rows - 1, cols - 1 ), disp_fem);
940  mmat->set( grid->get(0, 0), grid->get( rows - 1, cols - 1 ), disp_mal);
941  //last patch to first patch
942  fmat->set( grid->get( rows - 1, cols - 1 ), grid->get(0, 0), disp_fem);
943  mmat->set( grid->get( rows - 1, cols - 1 ), grid->get(0, 0), disp_mal);
944 
945  //last patch on first row, wrap around to top left border
946  fmat->set( grid->get(0, cols - 1), grid->get( rows - 1, 0 ), disp_fem);
947  mmat->set( grid->get(0, cols - 1), grid->get( rows - 1, 0 ), disp_mal);
948  //third corner to second corner
949  fmat->set( grid->get( rows - 1, 0 ), grid->get(0, cols - 1), disp_fem);
950  mmat->set( grid->get( rows - 1, 0 ), grid->get(0, cols - 1), disp_mal);
951 
952 
953  //BORDERS:
954 
955  x = 0;//we are on the first row
956 
957  for (y = 0; y < cols - 1; ++y) {
958  //diagonal step to the right, move to the other side of the grid
959  fmat->set( grid->get(x, y), grid->get( rows-1, y + 1 ), disp_fem);
960  mmat->set( grid->get(x, y), grid->get( rows-1, y + 1 ), disp_mal);
961  }
962  for (y = 1; y < cols; ++y) {
963  //diagonal step to the left, move to the other side of the grid
964  fmat->set( grid->get(x, y), grid->get( rows-1, y - 1 ), disp_fem);
965  mmat->set( grid->get(x, y), grid->get( rows-1, y - 1 ), disp_mal);
966  }
967 
968  x = rows - 1; //last row
969 
970  for (y = 0; y < cols - 1; ++y) {
971  //diagonal step to the right, move to the first row
972  fmat->set( grid->get(x, y), grid->get( 0, y + 1 ), disp_fem);
973  mmat->set( grid->get(x, y), grid->get( 0, y + 1 ), disp_mal);
974  }
975  for (y = 1; y < cols; ++y) {
976  //diagonal step to the left, move to the first row
977  fmat->set( grid->get(x, y), grid->get( 0, y - 1 ), disp_fem);
978  mmat->set( grid->get(x, y), grid->get( 0, y - 1 ), disp_mal);
979  }
980 
981  //in-between rows, connect first and last columns
982  for (x = 0; x < rows; ++x) {
983 
984  if(x > 0) {
985  //diagonal step down, to previous row
986  y = 0; //first column
987  fmat->set( grid->get(x, y), grid->get( x - 1, cols - 1 ), disp_fem);
988  mmat->set( grid->get(x, y), grid->get( x - 1, cols - 1 ), disp_mal);
989  y = cols - 1; //last column
990  fmat->set( grid->get(x, y), grid->get( x - 1, 0 ), disp_fem);
991  mmat->set( grid->get(x, y), grid->get( x - 1, 0 ), disp_mal);
992  }
993  if(x < rows - 1){
994  //diagonal step up, to next row
995  y = 0;
996  fmat->set( grid->get(x, y), grid->get( x + 1, cols - 1 ), disp_fem);
997  mmat->set( grid->get(x, y), grid->get( x + 1, cols - 1 ), disp_mal);
998  y = cols - 1;
999  fmat->set( grid->get(x, y), grid->get( x + 1, 0 ), disp_fem);
1000  mmat->set( grid->get(x, y), grid->get( x + 1, 0 ), disp_mal);
1001  }
1002  }
1003  }
1004  //the matrix is symmetrical no need to transpose for backward migration
1005  return true;
1006 }

References _DispMatrix, _prefix, FEM, TMatrix::get(), SimComponent::get_parameter_value(), MAL, and TMatrix::set().

Referenced by setBasicLatticeMatrix().

◆ setParamPrefix()

void LCE_Disperse_base::setParamPrefix ( string  pref)
inline
79 {_prefix = pref;}

References _prefix.

◆ setPropaguleTargets()

void LCE_Disperse_base::setPropaguleTargets ( )
465 {
466  unsigned int nb_patch = _popPtr->getPatchNbr();
467  unsigned int tmp_array[nb_patch];
468  unsigned int table_index, target_patch;
469  unsigned int size, last;
470 
471  //shuffling algorithm:
472  do {
473  for(unsigned int i = 0; i < nb_patch; ++i)
474  tmp_array[i] = i;
475 
476  size = nb_patch;
477 
478  for(unsigned int orig_patch = 0; orig_patch < nb_patch-1; ++orig_patch) {
479 
480  do{
481 
482  table_index = RAND::Uniform( size );
483 
484  target_patch = tmp_array[ table_index ];
485 
486  }while(target_patch == orig_patch);
487 
488  size--;
489 
490  last = tmp_array[size];
491 
492  tmp_array[table_index] = last;
493 
494  tmp_array[size] = target_patch;
495  }
496  //do this until the last element left is not the last patch:
497  }while (tmp_array[0] == nb_patch-1);
498 
499  _PropaguleTargets.assign(nb_patch,0);
500 
501  unsigned int reverse_i = nb_patch;
502 
503  //we read the shuffled array in reverse order:
504  for(unsigned int i=0; i < _PropaguleTargets.size(); i++) {
505  _PropaguleTargets[i] = tmp_array[--reverse_i];
506 
507 #ifdef _DEBUG_
508  cout<<" -- Patch "<<i<<" : assigned Patch "<<_PropaguleTargets[i]<<endl;
509 #endif
510 
511  }
512 }

References LifeCycleEvent::_popPtr, _PropaguleTargets, Metapop::getPatchNbr(), and RAND::Uniform().

Referenced by LCE_Disperse_EvolDisp::execute(), and setIsland_PropagulePool_Matrix().

◆ setReducedDispMatrix()

bool LCE_Disperse_base::setReducedDispMatrix ( )

The reduced dispersal matrix contains the indices of the patches to which each patch is connected.

The connected patches are further ordered in descending order of the migration rates. The migration rates are stored in a reduced dispersal matrix. The original dispersal matrices are cleared (de-allocated). This offers a double speed-up compared to the classical method.

1110 {
1111  unsigned int border_model = (unsigned int)get_parameter_value(_prefix + "_border_model");
1112  unsigned int num_patch = (border_model == 3 ? _npatch + 1 : _npatch);
1113 
1114  //multimap automatically orders the key values in ascending order
1115  multimap<double, unsigned int> ordered_rates_fem, ordered_rates_mal;
1116 
1117  typedef multimap<double, unsigned int>::const_iterator CI;
1118 
1119 #ifdef _DEBUG_
1120  message("== Dispersal matrices ==\n");
1121  _DispMatrix[FEM]->show_up();
1122  _DispMatrix[MAL]->show_up();
1123  message("== setting reduced dispersal matrices ==\n");
1124 #endif
1125 
1126  // purge the connectivity and reduced dipsersal matrices
1127  for (unsigned int sex = 0; sex < 2; sex++) {
1128  _reducedDispMat[sex].clear();
1129  _reducedDispMatProba[sex].clear();
1130  }
1131  // build them from full dispersal matrices given in input
1132  for (unsigned int i = 0; i < num_patch; ++i) {
1133 
1134  _reducedDispMat[0].push_back(vector<double>());
1135  _reducedDispMat[1].push_back(vector<double>());
1136 
1137  _reducedDispMatProba[0].push_back(vector<double>());
1138  _reducedDispMatProba[1].push_back(vector<double>());
1139 
1140  ordered_rates_fem.clear();
1141  ordered_rates_mal.clear();
1142 
1143  if(_isForward) {
1144  //make pairs: {disp proba, patch connected}, will be ordered by dispersal probabilities:
1145  for (unsigned int j = 0; j < num_patch; ++j)
1146  if(_DispMatrix[MAL]->get(i, j) != 0) ordered_rates_mal.insert(make_pair(_DispMatrix[MAL]->get(i, j), j));
1147 
1148 
1149  for (unsigned int j = 0; j < num_patch; ++j)
1150  if(_DispMatrix[FEM]->get(i, j) != 0) ordered_rates_fem.insert(make_pair(_DispMatrix[FEM]->get(i, j),j));
1151 
1152 
1153  } else {
1154  //backward migration matrices are read column-wise
1155  for (unsigned int j = 0; j < num_patch; ++j)
1156  if(_DispMatrix[MAL]->get(j, i) != 0) ordered_rates_mal.insert(make_pair(_DispMatrix[MAL]->get(j, i),j));
1157 
1158  for (unsigned int j = 0; j < num_patch; ++j)
1159  if(_DispMatrix[FEM]->get(j, i) != 0) ordered_rates_fem.insert(make_pair(_DispMatrix[FEM]->get(j, i),j));
1160  }
1161 
1162  if(ordered_rates_fem.size() == 1) {
1163 
1164  _reducedDispMat[FEM][i].push_back(ordered_rates_fem.begin()->second);
1165 
1166  _reducedDispMatProba[FEM][i].push_back(ordered_rates_fem.begin()->first);
1167 
1168  } else {
1169 
1170  //store the patch indices in reverse order of the migration rates:
1171  //store the dispersal rates as well in a separate reduced matrix
1172  CI p;
1173 
1174  for (p = --ordered_rates_fem.end(); p != ordered_rates_fem.begin(); --p) {
1175  _reducedDispMat[FEM][i].push_back(p->second);
1176  _reducedDispMatProba[FEM][i].push_back(p->first);
1177  }
1178  _reducedDispMat[FEM][i].push_back(ordered_rates_fem.begin()->second);
1179  _reducedDispMatProba[FEM][i].push_back(ordered_rates_fem.begin()->first);
1180 
1181  }
1182 
1183  //same for the male dispersal matrices
1184  if(ordered_rates_mal.size() == 1) {
1185 
1186  _reducedDispMat[MAL][i].push_back(ordered_rates_mal.begin()->second);
1187 
1188  _reducedDispMatProba[MAL][i].push_back(ordered_rates_mal.begin()->first);
1189 
1190  } else {
1191 
1192  CI p;
1193 
1194  for (p = --ordered_rates_mal.end(); p != ordered_rates_mal.begin(); --p) {
1195  _reducedDispMat[MAL][i].push_back(p->second);
1196  _reducedDispMatProba[MAL][i].push_back(p->first);
1197  }
1198  _reducedDispMat[MAL][i].push_back(ordered_rates_mal.begin()->second);
1199  _reducedDispMatProba[MAL][i].push_back(ordered_rates_mal.begin()->first);
1200 
1201  }
1202  }
1203 
1204  //we can now get rid of the dispersal matrices...
1205  for (unsigned int sex = 0; sex < 2; sex++) {
1206  delete _DispMatrix[sex];
1207  _DispMatrix[sex] = NULL;
1208  }
1209 
1210 #ifdef _DEBUG_
1211  cout << "=== female reduced dispersal matrix ===\n";
1212  for (unsigned int i = 0; i < num_patch; ++i) {
1213  cout << " ["<<i<<": ";
1214  for (unsigned int k = 0; k < _reducedDispMat[FEM][i].size(); k++) {
1215  cout <<"m="<< _reducedDispMatProba[FEM][i][k] << " -> " << _reducedDispMat[FEM][i][k]<<", ";
1216  }
1217  cout<<"]\n";
1218  }
1219 
1220  cout << "=== male reduced dispersal matrix ===\n";
1221  for (unsigned int i = 0; i < num_patch; ++i) {
1222  cout << " ["<<i<<": ";
1223  for (unsigned int k = 0; k < _reducedDispMat[MAL][i].size(); k++) {
1224  cout <<"m="<< _reducedDispMatProba[MAL][i][k] << " -> " << _reducedDispMat[MAL][i][k]<<", ";
1225  }
1226  cout<<"]\n";
1227 
1228  }
1229 #endif
1230 
1231  return true;
1232 }
void show_up()
Definition: tmatrix.h:328

References _DispMatrix, _isForward, _npatch, _prefix, _reducedDispMat, _reducedDispMatProba, FEM, SimComponent::get_parameter_value(), MAL, message(), and TMatrix::show_up().

Referenced by setBaseParameters(), setDispMatrix(), and LCE_Disperse_EvolDisp::setParameters().

◆ setReducedMatricesBySex()

bool LCE_Disperse_base::setReducedMatricesBySex ( sex_t  SEX,
Param connectivity,
Param rate 
)
311 {
312  string sex = (SEX == FEM ? "female" : "male");
313 
314  connectivity.getVariableMatrix(&_reducedDispMat[SEX]);
315 
317 
318  if(_reducedDispMat[SEX].size() != _npatch)
319  return error("The %s connectivity dispersal matrix must have as many rows (%i) as the number of patches in the population (%i)\n", sex.c_str(), _reducedDispMat[SEX].size(), _npatch);
320 
321  if(_reducedDispMatProba[SEX].size() != _npatch)
322  return error("The %s reduced dispersal rate matrix must have as many rows (%i) as the number of patches in the population (%i)\n", sex.c_str(), _reducedDispMatProba[SEX].size(), _npatch);
323 
324  if (_reducedDispMat[SEX].size() != _reducedDispMatProba[SEX].size())
325  return error("The %s connectivity and reduced dispersal matrices don't have same number of rows\n", sex.c_str());
326 
327  // check match between the two matrices
328  for (unsigned int i = 0; i < _reducedDispMat[SEX].size(); ++i) {
329 
330  if (_reducedDispMat[SEX][i].size() != _reducedDispMatProba[SEX][i].size())
331  return error("Row %i of the %s connectivity and reduced dispersal matrices are not of same size\n", i+1, sex.c_str());
332 
333  double row_sum = 0;
334 
335  // we here deduce 1 from the patch ID in the connectivity matrix
336  // this is because IDs are given in range [1 - num patch] in input (in principle)
337  for (unsigned int j = 0; j < _reducedDispMat[SEX][i].size(); ++j) {
338 
339  _reducedDispMat[SEX][i][j]--; //remove 1 to make sure that the indexes start with 0, not 1!!!!
340 
341  if(_reducedDispMatProba[SEX][i][j] < 0 )
342  return error("elements of the reduced dispersal matrix for the %s cannot be negative (row %i, column %i)!\n", (SEX==FEM?"females":"males"), i,j);
343 
344  row_sum += _reducedDispMatProba[SEX][i][j];
345  }
346 
347  if(!_isByNumber && (row_sum < 0.999999 || row_sum > 1.000001))
348  return error("the elements of row %i of the %s reduced dispersal matrix do not sum to 1!\n",i+1, sex.c_str());
349 
350  }
351  return true;
352 }
void getVariableMatrix(vector< vector< double > > *mat)
Definition: param.cc:460

References _isByNumber, _npatch, _reducedDispMat, _reducedDispMatProba, error(), FEM, and Param::getVariableMatrix().

Referenced by setBaseParameters().

◆ setSteppingStone1DMatrix()

bool LCE_Disperse_base::setSteppingStone1DMatrix ( )
637 {
638 #ifdef _DEBUG_
639  message("setSteppingStone1DMatrix()\n");
640 #endif
641  int border_model = (unsigned int)get_parameter_value(_prefix + "_border_model");
642 
643  //check for the border model, the extra patch is the absorbing patch
644  if(border_model == 3) {
647  } else {
650  }
651 
652  TMatrix* mmat = _DispMatrix[MAL];
653  TMatrix* fmat = _DispMatrix[FEM];
654 
655  //philopatry:
656  double pmal = 1 - _mal_rate, pfem = 1 - _fem_rate;
657  //migration:
658  double mmal = _mal_rate/2, mfem = _fem_rate/2;
659 
660  fmat->assign(0);
661  mmat->assign(0);
662 
663  //diagonal:
664  for (unsigned int i = 0; i < _npatch; ++i){
665  fmat->set(i, i, pfem);
666  mmat->set(i, i, pmal);
667  }
668  //around the diagonal
669  for (unsigned int i = 0; i < _npatch-1; ++i){
670  fmat->set(i, i+1, mfem);
671  fmat->set(i+1, i, mfem);
672  mmat->set(i, i+1, mmal);
673  mmat->set(i+1, i, mmal);
674  }
675 
676  if(border_model == 3) {
677  //absorbing boders
678  //emigrants who leave the population are put in the sink patch
679  fmat->set(0, _npatch, mfem);
680  mmat->set(0, _npatch, mmal);
681  fmat->set(_npatch -1, _npatch, mfem);
682  mmat->set(_npatch -1, _npatch, mmal);
683  fmat->set(_npatch, _npatch, 1);
684  mmat->set(_npatch, _npatch, 1);
685 
686  if(!_isForward) {
687  fmat->transpose(); mmat->transpose(); //this creates artificial immigration from sink
688  //need to reset border patches as immigration from sink not allowed:
689  fmat->set(0, 0, pfem + mfem); //the proportion not comming from the sink must be added
690  fmat->set(_npatch, 0, 0); //no immigration from sink
691  fmat->set(_npatch-1, _npatch-1, pfem + mfem);
692  fmat->set(_npatch, _npatch-1, 0);
693 
694  mmat->set(0, 0, pmal + mmal);
695  mmat->set(_npatch, 0, 0);
696  mmat->set(_npatch-1, _npatch-1, pmal + mmal);
697  mmat->set(_npatch, _npatch-1, 0);
698  }
699 
700  } else if (border_model == 2) {
701  //reflective borders,
702  //emigrants that cannot leave stay in place
703  fmat->set(0, 0, pfem+mfem);
704  mmat->set(0, 0, pmal+mmal);
705  fmat->set(_npatch -1, _npatch -1, pfem+mfem);
706  mmat->set(_npatch -1, _npatch -1, pmal+mmal);
707 
708  //no need to transpose for backward migration as the matrix is symmetrical
709 
710  } else { //is a torus by default
711  //the 2 last elements, this is a ring population!
712  fmat->set(0, _npatch -1, mfem);
713  mmat->set(0, _npatch -1, mmal);
714  fmat->set(_npatch -1, 0, mfem);
715  mmat->set(_npatch -1, 0, mmal);
716  }
717  return true;
718 }

References _DispMatrix, _fem_rate, _isForward, _mal_rate, _npatch, _prefix, allocateDispMatrix(), TMatrix::assign(), FEM, SimComponent::get_parameter_value(), MAL, message(), TMatrix::set(), and TMatrix::transpose().

Referenced by setDispMatrix().

◆ swapPostDisp()

void LCE_Disperse_base::swapPostDisp ( )
378 {
379  Patch *patch;
380 
381  for(unsigned int i = 0; i < _npatch; i++) {
382  patch = _popPtr->getPatch(i);
383  patch->move(FEM, PDISPx, OFFSx);
384  patch->move(MAL, PDISPx, OFFSx);
385  }
386 }
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.
Definition: metapop.h:611
@ OFFSx
Definition: types.h:42

References _npatch, LifeCycleEvent::_popPtr, FEM, Metapop::getPatch(), MAL, Patch::move(), OFFSx, and PDISPx.

Referenced by LCE_Disperse_EvolDisp::execute(), and LCE_Disperse_ConstDisp::Migrate().

◆ updateDispMatrix()

bool LCE_Disperse_base::updateDispMatrix ( )
366 {
367  //called by the 'execute' function when a change in patch number is detected
368 
369  if ( getDispersalModel() == 0 )
370  return error("cannot update the dispersal matrix provided in input when the number of population changes.\n");
371 
372  return setDispMatrix();
373 }

References error(), getDispersalModel(), and setDispMatrix().

Referenced by LCE_Breed_Disperse::execute(), LCE_Breed_Selection_Disperse::execute(), and LCE_Disperse_ConstDisp::execute().

Friends And Related Function Documentation

◆ LCE_Disperse_ConstDisp

friend class LCE_Disperse_ConstDisp
friend

◆ LCE_Disperse_EvolDisp

friend class LCE_Disperse_EvolDisp
friend

Member Data Documentation

◆ _disp_model

int LCE_Disperse_base::_disp_model
private

◆ _disp_propagule_prob

double LCE_Disperse_base::_disp_propagule_prob
private

◆ _DispMatrix

◆ _fem_rate

◆ _isByNumber

bool LCE_Disperse_base::_isByNumber
private

◆ _isForward

◆ _mal_rate

◆ _npatch

◆ _prefix

◆ _PropaguleTargets

vector<unsigned int> LCE_Disperse_base::_PropaguleTargets
private

◆ _reducedDispMat

vector< vector<double> > LCE_Disperse_base::_reducedDispMat[2]
protected

◆ _reducedDispMatProba

vector< vector<double> > LCE_Disperse_base::_reducedDispMatProba[2]
protected

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