Nemo  2.3.46
LCE_SelectionFH Class Reference

#include <LCEselection.h>

+ Inheritance diagram for LCE_SelectionFH:
+ Collaboration diagram for LCE_SelectionFH:

Public Member Functions

 LCE_SelectionFH (LCE_Selection_base *event)
 
virtual ~LCE_SelectionFH ()
 
virtual void FHwrite ()
 
virtual void FHread (string &filename)
 
void print (ofstream &FH, sex_t SEX, age_idx AGE, unsigned int i, Patch *patch, unsigned int ntraits)
 
- Public Member Functions inherited from EventFileHandler< LCE_Selection_base >
 EventFileHandler (LCE_Selection_base *event, const char *ext)
 
virtual ~EventFileHandler ()
 
virtual void set (bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path, LCE_Selection_base *event)
 
- Public Member Functions inherited from FileHandler
 FileHandler (const char *ext)
 
virtual ~FileHandler ()
 
virtual void init ()
 Called by notifier during simulation setup, performs file checking. More...
 
virtual bool ifExist ()
 Checks if any file associated with the current file name already exists on disk. More...
 
virtual void set (bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path)
 Sets the hanlder parameters. More...
 
virtual void set_multi (bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path)
 
virtual void update ()
 Updates the inner replicate and generation counters and calls FHwrite if needed by the the periodicity of the file. More...
 
Metapopget_pop_ptr ()
 Returns the pointer to the current metapop through the FileServices interface. More...
 
void set_pop_ptr (Metapop *pop_ptr)
 
FileServicesget_service ()
 Returns pointer to the FileServices. More...
 
void set_service (FileServices *srv)
 
std::string & get_path ()
 
void set_path ()
 
std::string & get_extension ()
 
void set_extension (const char *ext)
 
std::string & get_filename ()
 Builds and returns the current file name depending on the periodicity of the file. More...
 
bool get_isInputHandler ()
 
void set_isInputHandler (bool val)
 
bool get_isReplicatePeriodic ()
 
void set_isReplicatePeriodic (bool val)
 
unsigned int get_ReplicateOccurrence ()
 
void set_ReplicateOccurrence (unsigned int val)
 
bool get_isGenerationPeriodic ()
 
void set_isGenerationPeriodic (bool val)
 
unsigned int get_GenerationOccurrence ()
 
void set_GenerationOccurrence (unsigned int val)
 
unsigned int get_ExecRank ()
 unused yet... More...
 
void set_ExecRank (int val)
 
TMatrixget_OccMatrix ()
 
void set_OccMatrix (TMatrix *occ)
 
bool get_isMasterExec ()
 
void set_isMasterExec (bool is)
 
- Public Member Functions inherited from Handler
virtual ~Handler ()
 

Additional Inherited Members

- Protected Attributes inherited from EventFileHandler< LCE_Selection_base >
LCE_Selection_base_FHLinkedEvent
 
- Protected Attributes inherited from FileHandler
Metapop_pop
 Pointer to the current metapop, set during initialization within the init function. More...
 

Constructor & Destructor Documentation

LCE_SelectionFH::LCE_SelectionFH ( LCE_Selection_base event)
inline
virtual LCE_SelectionFH::~LCE_SelectionFH ( )
inlinevirtual
348 {}

Member Function Documentation

virtual void LCE_SelectionFH::FHread ( string &  filename)
inlinevirtual
void LCE_SelectionFH::FHwrite ( )
virtual

Implements EventFileHandler< LCE_Selection_base >.

References EventFileHandler< LCE_Selection_base >::_FHLinkedEvent, FileHandler::_pop, LCE_Selection_base::_TraitIndices, ADLTx, fatal(), FEM, FileHandler::get_filename(), Metapop::getPatch(), Metapop::getPatchNbr(), tstring::int2str(), MAL, OFFSx, print(), and Patch::size().

1301 {
1302  unsigned int num_traits = _FHLinkedEvent->_TraitIndices.size();
1303 
1304  std::string filename = get_filename();
1305 
1306  std::ofstream FILE (filename.c_str(), ios::out);
1307 
1308  if(!FILE) fatal("could not open \"%s\" output file!!\n",filename.c_str());
1309 
1310  FILE<<"pop";
1311 
1312  for (unsigned int i = 0; i < num_traits; ++i) {
1313  FILE<<" trait"<< tstring::int2str(i+1);
1314  }
1315 
1316  FILE<< " age isMigrant"<<endl;
1317 
1318 
1319  Patch* patch;
1320 
1321  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i ) {
1322 
1323  patch = _pop->getPatch(i);
1324 
1325  if (patch->size(FEM, OFFSx) != 0) print(FILE, FEM, OFFSx, i, patch, num_traits);
1326  if (patch->size(MAL, OFFSx) != 0) print(FILE, MAL, OFFSx, i, patch, num_traits);
1327 
1328  if (patch->size(FEM, ADLTx) != 0) print(FILE, FEM, ADLTx, i, patch, num_traits);
1329  if (patch->size(MAL, ADLTx) != 0) print(FILE, MAL, ADLTx, i, patch, num_traits);
1330 
1331  }
1332 
1333 
1334  FILE.close();
1335 }
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
std::string & get_filename()
Builds and returns the current file name depending on the periodicity of the file.
Definition: filehandler.cc:148
void fatal(const char *str,...)
Definition: output.cc:90
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
void print(ofstream &FH, sex_t SEX, age_idx AGE, unsigned int i, Patch *patch, unsigned int ntraits)
Definition: LCEselection.cc:1339
vector< unsigned int > _TraitIndices
The indices of the traits under selection.
Definition: LCEselection.h:108
Definition: types.h:42
static string int2str(const int i)
Writes an integer value into a string.
Definition: tstring.h:95
Definition: types.h:37
Definition: types.h:42
LCE_Selection_base * _FHLinkedEvent
Definition: filehandler.h:249
Definition: types.h:37
Metapop * _pop
Pointer to the current metapop, set during initialization within the init function.
Definition: filehandler.h:103
void LCE_SelectionFH::print ( ofstream &  FH,
sex_t  SEX,
age_idx  AGE,
unsigned int  i,
Patch patch,
unsigned int  ntraits 
)

References EventFileHandler< LCE_Selection_base >::_FHLinkedEvent, LCE_Selection_base::_getRawFitness, LCE_Selection_base::_TraitIndices, Patch::get(), Individual::getAge(), Individual::getHome(), and Patch::size().

Referenced by FHwrite().

1340 {
1341  Individual* ind = 0;
1342 
1343  for (unsigned int i = 0; i < patch->size(SEX, AGE); ++i) {
1344 
1345  ind = patch->get(SEX, AGE, i);
1346 
1347  FH<<p+1;
1348 
1349  for(unsigned int j = 0; j < ntraits; ++j)
1351 
1352  FH<<" "<<ind->getAge()<< " "<< (p == ind->getHome() ? 0 : 1) <<endl;
1353  }
1354 }
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
vector< unsigned int > _TraitIndices
The indices of the traits under selection.
Definition: LCEselection.h:108
unsigned short getAge()
Definition: individual.h:123
vector< double(LCE_Selection_base::*)(Individual *, unsigned int, unsigned int) > _getRawFitness
A vector containing pointers to fitness function related to each trait under selection.
Definition: LCEselection.h:116
unsigned short getHome()
Definition: individual.h:128
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:523
LCE_Selection_base * _FHLinkedEvent
Definition: filehandler.h:249
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49

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

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR