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

Implementation of the basic breeding and mating procedures, does not link to any trait. More...

#include <LCEbreed.h>

+ Inheritance diagram for LCE_BreedAssortativeMating:
+ Collaboration diagram for LCE_BreedAssortativeMating:

Public Member Functions

 LCE_BreedAssortativeMating ()
 
virtual ~LCE_BreedAssortativeMating ()
 
void ScrambleContainer (const int length, deque< Individual * > &array)
 
Individualbreed_lamprey (Individual *mother, Individual *father, unsigned int LocalPatch)
 
void setPhenotypeAncestryBased (Individual *ind)
 
void setPhenotypeMotherInherited (Individual *ind)
 
Assortative mating functions
bool testAssortativeMatingCouple (const double female_trait_value, const double male_trait_value)
 Test whether male and female match for mating. More...
 
Individualnon_assortative_mating (Patch *patch, Individual *mother, unsigned int motherIndex)
 Proceed with non-assortative mating, choosing a male at random in the patch, conditioned on him being a "virgin". More...
 
Individualassortative_mating (deque< Individual * > &males, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male chosen relative to its phenotypic resemblance with the mother. More...
 
Implementations
virtual bool setParameters ()
 
virtual void execute ()
 
virtual LifeCycleEventclone ()
 
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 LCE_Breed_base
 LCE_Breed_base ()
 
virtual ~LCE_Breed_base ()
 
virtual IndividualgetFatherPtr (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Calls the mating function according to the model chosen using the function pointer, used to get the father from the mother in a patch. More...
 
void NonWrightFisherPopulation ()
 
void WrightFisherPopulation ()
 
Individualbreed (Individual *mother, Individual *father, unsigned int LocalPatch)
 Makes a new individual with the right parents. More...
 
Individualbreed_cloning (Individual *mother, Individual *father, unsigned int LocalPatch)
 Makes a new individual by doing a deep copy of the mother (copies the mother's genes into the offspring). More...
 
IndividualmakeOffspring (Individual *ind)
 Last step of the breeding process, does inheritance and mutation of the parents' genes. More...
 
Individualdo_breed (Individual *mother, Individual *father, unsigned int LocalPatch)
 Calls the breeding function unsing its pointer. More...
 
bool checkMatingCondition (Patch *thePatch)
 Checks if any mating will take place in the patch passed as argument. More...
 
bool checkNoSelfing (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is not selfing or cloning. More...
 
bool checkPolygyny (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is polygynous. More...
 
bool checkSelfing (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is selfing. More...
 
bool checkCloning (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is cloning. More...
 
bool setMatingSystem ()
 
bool setFecundity ()
 
bool setSexRatio ()
 
double getMatingProportion ()
 
double getMeanFecundity (unsigned int patch)
 
int getMatingSystem ()
 
bool doInheritance ()
 
double getPoissonFecundity (double mean)
 
double getFixedFecundity (double mean)
 
double getGaussianFecundity (double mean)
 
double getLogNormalFecundity (double mean)
 
double getFecundity (unsigned int patch)
 
double getFecundity (double mean)
 
sex_t getOffsprgSex ()
 
sex_t getOffsprgSexRandom ()
 
sex_t getOffsprgSexFixed ()
 
sex_t getOffsprgSexSelfing ()
 
sex_t getOffsprgSexCloning ()
 
bool isWrightFisher ()
 
IndividualRandomMating (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male drawn randomly from a patch. More...
 
IndividualfullPolyginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to the alpha male of the patch. More...
 
IndividualfullPolyginy_manyMales (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to one of the first _mating_males males of the patch. More...
 
IndividualpartialPolyginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1, or the first male otherwise. More...
 
IndividualpartialPolyginy_manyMales (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1, or one of the _mating_males first males otherwise. More...
 
IndividualfullMonoginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male with same index as mother (if available) from the focal patch. More...
 
IndividualpartialMonoginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male with same index as mother (if available) from the focal patch. More...
 
IndividualfullSelfing (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns the mother pointer. More...
 
IndividualpartialSelfing (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns the mother pointer or a random female if _mating_proportion != 1. More...
 
Individualrandom_hermaphrodite (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a random female from the patch, will be the same mother with probability 1/N (Wright-Fisher model). More...
 
- 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

double _assortative_value
 
double _assortative_tolerance
 
double assortative_value_with_tolerance
 
std::function< bool(double, double)> _assortative_predicate
 
double _prop_non_assortative
 
Individual *(LCE_Breed_base::* MatingFuncPtr_base )(Patch *, Individual *, unsigned int)
 
Individual *(LCE_Breed_base::* AssortativeMatingFuncPtr )(Patch *, Individual *, unsigned int)
 

Additional Inherited Members

- Protected Attributes inherited from LCE_Breed_base
TMatrix _mean_fecundity
 
Individual *(LCE_Breed_base::* MatingFuncPtr )(Patch *, Individual *, unsigned int)
 
Individual *(LCE_Breed_base::* DoBreedFuncPtr )(Individual *mother, Individual *father, unsigned int LocalPatch)
 
double(LCE_Breed_base::* FecundityFuncPtr )(double mean)
 
bool(LCE_Breed_base::* CheckMatingConditionFuncPtr )(Patch *thePatch)
 
sex_t(LCE_Breed_base::* GetOffsprgSex )()
 
void(LCE_Breed_base::* PopModelFuncPtr )(void)
 
- 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

Implementation of the basic breeding and mating procedures, does not link to any trait.

Individuals mate according to the mating system chosen. The mated adults are not removed from the population. The offspring containers are filled with the new generation. Note that they are first emptied if still containing offspring individuals when starting the breeding process.

The population's age is set to ALL. The mating and realized fecundity counters of the reproducing males and females are updated.

See also
LCE_Breed_base

Constructor & Destructor Documentation

◆ LCE_BreedAssortativeMating()

LCE_BreedAssortativeMating::LCE_BreedAssortativeMating ( )
539  : LifeCycleEvent("breed_assortative",""),
542 {
544 
545  add_parameter("breed_assortative_trait", STR, true, false, 0, 0, updater); //the trait used for the assortment
546  add_parameter("breed_assortative_tolerance", DBL, false, false, 0, 0, updater); //the threshold used for mating
547  add_parameter("breed_assortative_condition", STR, false, false, 0, 0, updater); //the predicate used to test for assortment
548  add_parameter("breed_assortative_value", DBL, false, false, 0, 0, updater); //the value matched by the difference b/n male and female
549 
550  // get_parameter("mating_system")->setIsRequired(false);
551 
552 }
Individual *(LCE_Breed_base::* AssortativeMatingFuncPtr)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:416
double _assortative_value
Definition: LCEbreed.h:402
double _prop_non_assortative
Definition: LCEbreed.h:412
double _assortative_tolerance
Definition: LCEbreed.h:405
Individual *(LCE_Breed_base::* MatingFuncPtr_base)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:414
std::function< bool(double, double)> _assortative_predicate
Definition: LCEbreed.h:410
double assortative_value_with_tolerance
Definition: LCEbreed.h:407
virtual bool setParameters()
Definition: LCEbreed.cc:556
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:98
Implementation of the ParamUpdaterBase interface.
Definition: param.h:363
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
@ DBL
Definition: types.h:78
@ STR
Definition: types.h:78

References SimComponent::add_parameter(), DBL, setParameters(), and STR.

Referenced by clone().

◆ ~LCE_BreedAssortativeMating()

virtual LCE_BreedAssortativeMating::~LCE_BreedAssortativeMating ( )
inlinevirtual
423 { }

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_BreedAssortativeMating::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

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

References OFFSPRG.

◆ assortative_mating()

Individual * LCE_BreedAssortativeMating::assortative_mating ( deque< Individual * > &  males,
Individual mother,
unsigned int  motherIndex 
)

Returns a pointer to a male chosen relative to its phenotypic resemblance with the mother.

721 {
722  Individual* father = NULL;
723 
724  if(males.size() >= motherIndex+1)
725  father = males[motherIndex]; // we model monogamy, the female mates with a single male, if they match
726  else
727  father = males[0]; // start from first males in the array if not enough males
728 
729  unsigned int cnt = 0;
730 
731 // cout<<" "<<motherIndex<<" - LCE_BreedAssortativeMating::assortative_mating\n";
732  double fem_trait_value = ((double*)mother->getTraitValue(_LCELinkedTraitIndex))[0]; //works for quanti trait only
733 // cout<<" female trait value: "<<fem_trait_value<<endl;
734  double mal_trait_value = ((double*)father->getTraitValue(_LCELinkedTraitIndex))[0];
735 // cout<<" male trait value: "<<mal_trait_value<<endl;
736 
737  bool match = testAssortativeMatingCouple(fem_trait_value, mal_trait_value);
738 
739 // cout<<" trait match: "<<std::boolalpha<<match<<" || mated: "<<(father->getTotMatings() != 0)<<endl;
740 
741  // these are Lamprey-specific conditions for strictly monogamous couples.
742  while( (!match || father->getTotMatings() != 0) && cnt < males.size())
743  {
744  // the male doesn't match or the male has already reproduced, we need to change it
745  if(males.size() > motherIndex+1)
746  motherIndex++;
747  else
748  motherIndex = 0; //restart from the beginning
749 
750  father = males[motherIndex];
751 
752  mal_trait_value = ((double*)father->getTraitValue(_LCELinkedTraitIndex))[0];
753 
754  match = testAssortativeMatingCouple(fem_trait_value, mal_trait_value);
755 
756  cnt++;
757  }
758 // cout<<" + match trials: "<<cnt<< "; father: "<<motherIndex <<"("<<father->getID()<<")"<<endl;
759 // cout<<" male trait value: "<<mal_trait_value<<endl;
760 // cout<<" trait match: "<<std::boolalpha<<match<<" || mated: "<<(father->getTotMatings() != 0)<<endl;
761  if( !match || father->getTotMatings() != 0) {
762 // cout<<" @@ FAIL\n";
763  return NULL; // no more matching mating partner available
764  }
765 
766  return father;
767 }
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
unsigned int getTotMatings()
Gives the total number of matings of an individual.
Definition: individual.h:152
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
bool testAssortativeMatingCouple(const double female_trait_value, const double male_trait_value)
Test whether male and female match for mating.
Definition: LCEbreed.cc:771
int _LCELinkedTraitIndex
The index in the individual's trait table of the linked trait.
Definition: lifecycleevent.h:89

References LifeCycleEvent::_LCELinkedTraitIndex, Individual::getTotMatings(), Individual::getTraitValue(), and testAssortativeMatingCouple().

Referenced by execute().

◆ breed_lamprey()

Individual* LCE_BreedAssortativeMating::breed_lamprey ( Individual mother,
Individual father,
unsigned int  LocalPatch 
)

◆ clone()

virtual LifeCycleEvent* LCE_BreedAssortativeMating::clone ( )
inlinevirtual

Implements LifeCycleEvent.

448 {return new LCE_BreedAssortativeMating();}
LCE_BreedAssortativeMating()
Definition: LCEbreed.cc:539

References LCE_BreedAssortativeMating().

◆ execute()

void LCE_BreedAssortativeMating::execute ( )
virtual

Implements LifeCycleEvent.

644 {
645  Patch* patch;
646  Individual* mother;
647  Individual* father;
648  Individual* NewOffsprg;
649  deque<Individual*> randmales;
650  unsigned int nbBaby;
651  double fec, fec_factor;
652 
653 #ifdef _DEBUG_
654  message("LCE_BreedAssortativeMating::execute (Patch nb: %i offsprg nb: %i adlt nb: %i)\n"
656 #endif
657 
658  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
659 
660  patch = _popPtr->getPatch(i);
661 
662  if( !checkMatingCondition(patch) ) continue; // set to checkNoSelfing()
663 
664  randmales.clear();
665  // randomize the males within the patch
666  patch->getCopy(MAL, ADLTx, randmales);
667 
668  ScrambleContainer(randmales.size(), randmales);
669 
670  for(unsigned int size = patch->size(FEM, ADLTx), indexOfMother = 0;
671  indexOfMother < size;
672  indexOfMother++)
673  {
674  mother = patch->get(FEM, ADLTx, indexOfMother);
675 
676  nbBaby = (unsigned int)mother->setFecundity( fec ) ;
677 
678  if(nbBaby == 0) continue; // skip this female
679 
680  // choose a male:
682  father = non_assortative_mating(patch, mother, indexOfMother);
683  else
684  father = assortative_mating(randmales, mother, indexOfMother);
685 
686  if(father == NULL) continue; // move to the next female if mating wasn't possible
687 
688  for(unsigned int j = 0; j < nbBaby; ++j) {
689 
690  // LAMPREY SPECIFIC !!!
691 // NewOffsprg = breed_lamprey(mother, father, i);
692 //
693 // patch->add(NewOffsprg->getSex(), OFFSx, NewOffsprg);
694 
695  }
696  }
697  }
698 }
double setFecundity(double value)
Sets the fecundity to the value given and returns it.
Definition: individual.h:207
Individual * assortative_mating(deque< Individual * > &males, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male chosen relative to its phenotypic resemblance with the mother.
Definition: LCEbreed.cc:720
void ScrambleContainer(const int length, deque< Individual * > &array)
Definition: LCEbreed.cc:789
Individual * non_assortative_mating(Patch *patch, Individual *mother, unsigned int motherIndex)
Proceed with non-assortative mating, choosing a male at random in the patch, conditioned on him being...
Definition: LCEbreed.cc:702
bool checkMatingCondition(Patch *thePatch)
Checks if any mating will take place in the patch passed as argument.
Definition: LCEbreed.h:173
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:312
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
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:432
void getCopy(sex_t SEX, age_idx AGE, deque< Individual * > &to)
Definition: metapop.h:724
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:498
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:534
void clear(sex_t SEX, age_idx AGE)
Sets the size of the appropriate container to zero.
Definition: metapop.h:674
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:124
void message(const char *message,...)
Definition: output.cc:40
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
@ ADLTx
Definition: types.h:42

References LifeCycleEvent::_popPtr, _prop_non_assortative, ADLTx, ADULTS, assortative_mating(), LCE_Breed_base::checkMatingCondition(), Patch::clear(), FEM, Patch::get(), Patch::getCopy(), Metapop::getPatch(), Metapop::getPatchNbr(), MAL, message(), non_assortative_mating(), OFFSPRG, ScrambleContainer(), Individual::setFecundity(), Metapop::size(), Patch::size(), and RAND::Uniform().

◆ loadFileServices()

virtual void LCE_BreedAssortativeMating::loadFileServices ( FileServices loader)
inlinevirtual

Implements SimComponent.

450 {}

◆ loadStatServices()

virtual void LCE_BreedAssortativeMating::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

451 {}

◆ non_assortative_mating()

Individual * LCE_BreedAssortativeMating::non_assortative_mating ( Patch patch,
Individual mother,
unsigned int  motherIndex 
)

Proceed with non-assortative mating, choosing a male at random in the patch, conditioned on him being a "virgin".

703 {
704  Individual* father = NULL;
705  unsigned int cnt = 0;
706 
707  do {
708  father = RandomMating(patch, mother, motherIndex);
709  cnt++;
710  } while( father->getTotMatings() != 0 && cnt < patch->size(MAL, ADLTx) );
711 
712  if(father->getTotMatings() != 0)
713  return NULL;
714 
715  return father;
716 }
Individual * RandomMating(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male drawn randomly from a patch.
Definition: LCEbreed.h:230

References ADLTx, Individual::getTotMatings(), MAL, and LCE_Breed_base::RandomMating().

Referenced by execute().

◆ removeAgeClass()

virtual age_t LCE_BreedAssortativeMating::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

453 {return 0;}

◆ requiredAgeClass()

virtual age_t LCE_BreedAssortativeMating::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

455 {return ADULTS;}

References ADULTS.

◆ resetParameterFromSource()

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

Implements SimComponent.

452 {return false;}

◆ ScrambleContainer()

void LCE_BreedAssortativeMating::ScrambleContainer ( const int  length,
deque< Individual * > &  array 
)
inline
790 {
791  unsigned int size = length, pos, last = length - 1, num = length -1;
792  Individual* el;
793 
794  // with stop after 2 elements are left
795  // this algo allows swapping an element with itself, which is fine
796  for (unsigned int i = 0; i < num; i++) {
797  pos = RAND::Uniform(size);
798  el = array[last];
799  array[last] = array[pos];
800  array[pos] = el;
801  size--; last--;
802  }
803 
804  assert(size == 1); //we stopped before swapping the last (first) element with itself
805 }

References RAND::Uniform().

Referenced by execute().

◆ setParameters()

bool LCE_BreedAssortativeMating::setParameters ( )
virtual

Reimplemented from LCE_Breed_base.

557 {
558  if(!LCE_Breed_base::setParameters( )) return false;
559 
560  // trait link to query for the phenotypic value
561  _LCELinkedTraitType = get_parameter("breed_assortative_trait")->getArg();
563 
564  if(_LCELinkedTraitIndex == -1)
565  return error("assortative mating trait \"%s\" cannot be found in loaded traits\n",_LCELinkedTraitType.c_str());
566 
567 
568  // value of trait difference b/n male and female to initiate mating, it is 0 by default
569  if ( get_parameter("breed_assortative_value")->isSet() )
570  _assortative_value = get_parameter_value("breed_assortative_value");
571  else
572  _assortative_value = 0;
573 
574 
575  // tolerance value around the assortative value, it 0 by default
576  if (get_parameter("breed_assortative_tolerance")->isSet()) {
577 
578  _assortative_tolerance = get_parameter_value("breed_assortative_tolerance");
579 
580  } else {
581 
583 
584  }
585 
587 
588  string _assortative_test_condition;
589 
590  // predicate for the choice of mating
591  if (get_parameter("breed_assortative_condition")->isSet()) {
592 
593  _assortative_test_condition = tstring::removeEnclosingChar(get_parameter("breed_assortative_condition")->getArg(), '"', '"', true) ;
594 
595  if(_assortative_test_condition == "==") {
596 
597  _assortative_predicate = std::equal_to<double>{};
598 
599  } else if (_assortative_test_condition == "!=") {
600 
601  _assortative_predicate = std::not_equal_to<double>{};
602 
603  } else if (_assortative_test_condition == ">") {
604 
605  _assortative_predicate = std::greater<double>{};
606 
607  } else if (_assortative_test_condition == "<") {
608 
609  _assortative_predicate = std::less<double>{};
610 
611  } else if (_assortative_test_condition == "<=") {
612 
613  _assortative_predicate = std::less_equal<double>{};
614 
615  } else if (_assortative_test_condition == ">=") {
616 
617  _assortative_predicate = std::greater_equal<double>{};
618 
619  } else
620  return error("value for \"breed_assortative_condition\" could not be understood\n");
621 
622  } else {
623  _assortative_predicate = std::equal_to<double>{};
624  }
625 
626  if( get_parameter("mating_proportion")->isSet()) {
627  // proportion of time mating is done at random
628  _prop_non_assortative = get_parameter_value("mating_proportion");
629  }
630  else
632 
633  // backup the mating function
635 
636 
637 
638  return true;
639 }
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
Individual *(LCE_Breed_base::* MatingFuncPtr)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:60
virtual bool setParameters()
Definition: LCEbreed.cc:77
std::string _LCELinkedTraitType
The name of the linked trait.
Definition: lifecycleevent.h:85
string getArg()
Definition: param.h:138
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
static string removeEnclosingChar(const string &str, const char o, const char c, bool allowMissing=false)
Removes characters enclosing a string.
Definition: tstring.h:356
int error(const char *str,...)
Definition: output.cc:77

References _assortative_predicate, _assortative_tolerance, _assortative_value, LifeCycleEvent::_LCELinkedTraitIndex, LifeCycleEvent::_LCELinkedTraitType, LifeCycleEvent::_popPtr, _prop_non_assortative, assortative_value_with_tolerance, error(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getArg(), IndFactory::getTraitIndex(), LCE_Breed_base::MatingFuncPtr, MatingFuncPtr_base, tstring::removeEnclosingChar(), and LCE_Breed_base::setParameters().

Referenced by LCE_BreedAssortativeMating().

◆ setPhenotypeAncestryBased()

void LCE_BreedAssortativeMating::setPhenotypeAncestryBased ( Individual ind)

◆ setPhenotypeMotherInherited()

void LCE_BreedAssortativeMating::setPhenotypeMotherInherited ( Individual ind)

◆ testAssortativeMatingCouple()

bool LCE_BreedAssortativeMating::testAssortativeMatingCouple ( const double  female_trait_value,
const double  male_trait_value 
)

Test whether male and female match for mating.

772 {
773  // we test the difference between the male and female values
774  // to match with the predicate, we take diff = male - female
775  // predicate tells how the male value must be relative to the female value:
776  // "<=": males must be smaller or equal to the female to mate,
777  // thus, male - female <= 0 to match.
778  double diff = male_trait_value - female_trait_value;
779 
780  // by default the assortative value is 0 (diff b/n female and male phenotype)
781  if(abs(diff) <= (_assortative_value + _assortative_tolerance))
782  diff = _assortative_value;
783 
785 }

References _assortative_predicate, _assortative_tolerance, and _assortative_value.

Referenced by assortative_mating().

Member Data Documentation

◆ _assortative_predicate

std::function<bool(double,double)> LCE_BreedAssortativeMating::_assortative_predicate
private

◆ _assortative_tolerance

double LCE_BreedAssortativeMating::_assortative_tolerance
private

◆ _assortative_value

double LCE_BreedAssortativeMating::_assortative_value
private

◆ _prop_non_assortative

double LCE_BreedAssortativeMating::_prop_non_assortative
private

Referenced by execute(), and setParameters().

◆ assortative_value_with_tolerance

double LCE_BreedAssortativeMating::assortative_value_with_tolerance
private

Referenced by setParameters().

◆ AssortativeMatingFuncPtr

Individual*(LCE_Breed_base::* LCE_BreedAssortativeMating::AssortativeMatingFuncPtr) (Patch *, Individual *, unsigned int)
private

◆ MatingFuncPtr_base

Individual*(LCE_Breed_base::* LCE_BreedAssortativeMating::MatingFuncPtr_base) (Patch *, Individual *, unsigned int)
private

Referenced by setParameters().


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