Nemo  2.4.2
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 ()
 
void doAgingInWFpop ()
 
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...
 
IndividualmakeOffspring (Individual *newind, Individual *mother, Individual *father, unsigned int natalPatch)
 Overloads previous function when a new offspring is created "in-place", that is from existing pointer in a patch. 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 ( )
609  : LifeCycleEvent("breed_assortative",""),
612 {
614 
615  add_parameter("breed_assortative_trait", STR, true, false, 0, 0, updater); //the trait used for the assortment
616  add_parameter("breed_assortative_tolerance", DBL, false, false, 0, 0, updater); //the threshold used for mating
617  add_parameter("breed_assortative_condition", STR, false, false, 0, 0, updater); //the predicate used to test for assortment
618  add_parameter("breed_assortative_value", DBL, false, false, 0, 0, updater); //the value matched by the difference b/n male and female
619 
620  // get_parameter("mating_system")->setIsRequired(false);
621 
622 }
Individual *(LCE_Breed_base::* AssortativeMatingFuncPtr)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:427
double _assortative_value
Definition: LCEbreed.h:413
double _prop_non_assortative
Definition: LCEbreed.h:423
double _assortative_tolerance
Definition: LCEbreed.h:416
Individual *(LCE_Breed_base::* MatingFuncPtr_base)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:425
std::function< bool(double, double)> _assortative_predicate
Definition: LCEbreed.h:421
double assortative_value_with_tolerance
Definition: LCEbreed.h:418
virtual bool setParameters()
Definition: LCEbreed.cc:626
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:96
Implementation of the ParamUpdaterBase interface.
Definition: param.h:371
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:110
@ DBL
Definition: types.h:76
@ STR
Definition: types.h:76

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

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~LCE_BreedAssortativeMating()

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

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_BreedAssortativeMating::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

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

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.

791 {
792  Individual* father = NULL;
793 
794  if(males.size() >= motherIndex+1)
795  father = males[motherIndex]; // we model monogamy, the female mates with a single male, if they match
796  else
797  father = males[0]; // start from first males in the array if not enough males
798 
799  unsigned int cnt = 0;
800 
801 // cout<<" "<<motherIndex<<" - LCE_BreedAssortativeMating::assortative_mating\n";
802  double fem_trait_value = ((double*)mother->getTraitValue(_LCELinkedTraitIndex))[0]; //works for quanti trait only
803 // cout<<" female trait value: "<<fem_trait_value<<endl;
804  double mal_trait_value = ((double*)father->getTraitValue(_LCELinkedTraitIndex))[0];
805 // cout<<" male trait value: "<<mal_trait_value<<endl;
806 
807  bool match = testAssortativeMatingCouple(fem_trait_value, mal_trait_value);
808 
809 // cout<<" trait match: "<<std::boolalpha<<match<<" || mated: "<<(father->getTotMatings() != 0)<<endl;
810 
811  // these are Lamprey-specific conditions for strictly monogamous couples.
812  while( (!match || father->getTotMatings() != 0) && cnt < males.size())
813  {
814  // the male doesn't match or the male has already reproduced, we need to change it
815  if(males.size() > motherIndex+1)
816  motherIndex++;
817  else
818  motherIndex = 0; //restart from the beginning
819 
820  father = males[motherIndex];
821 
822  mal_trait_value = ((double*)father->getTraitValue(_LCELinkedTraitIndex))[0];
823 
824  match = testAssortativeMatingCouple(fem_trait_value, mal_trait_value);
825 
826  cnt++;
827  }
828 // cout<<" + match trials: "<<cnt<< "; father: "<<motherIndex <<"("<<father->getID()<<")"<<endl;
829 // cout<<" male trait value: "<<mal_trait_value<<endl;
830 // cout<<" trait match: "<<std::boolalpha<<match<<" || mated: "<<(father->getTotMatings() != 0)<<endl;
831  if( !match || father->getTotMatings() != 0) {
832 // cout<<" @@ FAIL\n";
833  return NULL; // no more matching mating partner available
834  }
835 
836  return father;
837 }
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:47
unsigned int getTotMatings()
Gives the total number of matings of an individual.
Definition: individual.h:150
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:269
bool testAssortativeMatingCouple(const double female_trait_value, const double male_trait_value)
Test whether male and female match for mating.
Definition: LCEbreed.cc:841
int _LCELinkedTraitIndex
The index in the individual's trait table of the linked trait.
Definition: lifecycleevent.h:87

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

Referenced by execute().

+ Here is the caller graph for this function:

◆ breed_lamprey()

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

◆ clone()

virtual LifeCycleEvent* LCE_BreedAssortativeMating::clone ( )
inlinevirtual

Implements LifeCycleEvent.

459 {return new LCE_BreedAssortativeMating();}
LCE_BreedAssortativeMating()
Definition: LCEbreed.cc:609

References LCE_BreedAssortativeMating().

◆ execute()

void LCE_BreedAssortativeMating::execute ( )
virtual

Implements LifeCycleEvent.

714 {
715  Patch* patch;
716  Individual* mother;
717  Individual* father;
718  Individual* NewOffsprg;
719  deque<Individual*> randmales;
720  unsigned int nbBaby;
721  double fec, fec_factor;
722 
723 #ifdef _DEBUG_
724  message("LCE_BreedAssortativeMating::execute (Patch nb: %i offsprg nb: %i adlt nb: %i)\n"
726 #endif
727 
728  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
729 
730  patch = _popPtr->getPatch(i);
731 
732  if( !checkMatingCondition(patch) ) continue; // set to checkNoSelfing()
733 
734  randmales.clear();
735  // randomize the males within the patch
736  patch->getCopy(MAL, ADLTx, randmales);
737 
738  ScrambleContainer(randmales.size(), randmales);
739 
740  for(unsigned int size = patch->size(FEM, ADLTx), indexOfMother = 0;
741  indexOfMother < size;
742  indexOfMother++)
743  {
744  mother = patch->get(FEM, ADLTx, indexOfMother);
745 
746  nbBaby = (unsigned int)mother->setFecundity( fec ) ;
747 
748  if(nbBaby == 0) continue; // skip this female
749 
750  // choose a male:
752  father = non_assortative_mating(patch, mother, indexOfMother);
753  else
754  father = assortative_mating(randmales, mother, indexOfMother);
755 
756  if(father == NULL) continue; // move to the next female if mating wasn't possible
757 
758  for(unsigned int j = 0; j < nbBaby; ++j) {
759 
760  // LAMPREY SPECIFIC !!!
761 // NewOffsprg = breed_lamprey(mother, father, i);
762 //
763 // patch->add(NewOffsprg->getSex(), OFFSx, NewOffsprg);
764 
765  }
766  }
767  }
768 }
double setFecundity(double value)
Sets the fecundity to the value given and returns it.
Definition: individual.h:205
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:790
void ScrambleContainer(const int length, deque< Individual * > &array)
Definition: LCEbreed.cc:859
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:772
bool checkMatingCondition(Patch *thePatch)
Checks if any mating will take place in the patch passed as argument.
Definition: LCEbreed.h:184
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:79
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:310
unsigned int getPatchNbr()
Definition: metapop.h:274
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:255
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
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:496
Individual * get(sex_t SEX, age_idx AGE, unsigned int at)
Returns a pointer to the individual sitting at the index passed.
Definition: metapop.h:532
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:125
void message(const char *message,...)
Definition: output.cc:38
@ FEM
Definition: types.h:35
@ MAL
Definition: types.h:35
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:52
@ ADLTx
Definition: types.h:40

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.

461 {}

◆ loadStatServices()

virtual void LCE_BreedAssortativeMating::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

462 {}

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

773 {
774  Individual* father = NULL;
775  unsigned int cnt = 0;
776 
777  do {
778  father = RandomMating(patch, mother, motherIndex);
779  cnt++;
780  } while( father->getTotMatings() != 0 && cnt < patch->size(MAL, ADLTx) );
781 
782  if(father->getTotMatings() != 0)
783  return NULL;
784 
785  return father;
786 }
Individual * RandomMating(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male drawn randomly from a patch.
Definition: LCEbreed.h:241

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

Referenced by execute().

+ Here is the caller graph for this function:

◆ removeAgeClass()

virtual age_t LCE_BreedAssortativeMating::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

464 {return 0;}

◆ requiredAgeClass()

virtual age_t LCE_BreedAssortativeMating::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

466 {return ADULTS;}

References ADULTS.

◆ resetParameterFromSource()

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

Implements SimComponent.

463 {return false;}

◆ ScrambleContainer()

void LCE_BreedAssortativeMating::ScrambleContainer ( const int  length,
deque< Individual * > &  array 
)
inline
860 {
861  unsigned int size = length, pos, last = length - 1, num = length -1;
862  Individual* el;
863 
864  // with stop after 2 elements are left
865  // this algo allows swapping an element with itself, which is fine
866  for (unsigned int i = 0; i < num; i++) {
867  pos = RAND::Uniform(size);
868  el = array[last];
869  array[last] = array[pos];
870  array[pos] = el;
871  size--; last--;
872  }
873 
874  assert(size == 1); //we stopped before swapping the last (first) element with itself
875 }

References RAND::Uniform().

Referenced by execute().

+ Here is the caller graph for this function:

◆ setParameters()

bool LCE_BreedAssortativeMating::setParameters ( )
virtual

Reimplemented from LCE_Breed_base.

627 {
628  if(!LCE_Breed_base::setParameters( )) return false;
629 
630  // trait link to query for the phenotypic value
631  _LCELinkedTraitType = get_parameter("breed_assortative_trait")->getArg();
633 
634  if(_LCELinkedTraitIndex == -1)
635  return error("assortative mating trait \"%s\" cannot be found in loaded traits\n",_LCELinkedTraitType.c_str());
636 
637 
638  // value of trait difference b/n male and female to initiate mating, it is 0 by default
639  if ( get_parameter("breed_assortative_value")->isSet() )
640  _assortative_value = get_parameter_value("breed_assortative_value");
641  else
642  _assortative_value = 0;
643 
644 
645  // tolerance value around the assortative value, it 0 by default
646  if (get_parameter("breed_assortative_tolerance")->isSet()) {
647 
648  _assortative_tolerance = get_parameter_value("breed_assortative_tolerance");
649 
650  } else {
651 
653 
654  }
655 
657 
658  string _assortative_test_condition;
659 
660  // predicate for the choice of mating
661  if (get_parameter("breed_assortative_condition")->isSet()) {
662 
663  _assortative_test_condition = tstring::removeEnclosingChar(get_parameter("breed_assortative_condition")->getArg(), '"', '"', true) ;
664 
665  if(_assortative_test_condition == "==") {
666 
667  _assortative_predicate = std::equal_to<double>{};
668 
669  } else if (_assortative_test_condition == "!=") {
670 
671  _assortative_predicate = std::not_equal_to<double>{};
672 
673  } else if (_assortative_test_condition == ">") {
674 
675  _assortative_predicate = std::greater<double>{};
676 
677  } else if (_assortative_test_condition == "<") {
678 
679  _assortative_predicate = std::less<double>{};
680 
681  } else if (_assortative_test_condition == "<=") {
682 
683  _assortative_predicate = std::less_equal<double>{};
684 
685  } else if (_assortative_test_condition == ">=") {
686 
687  _assortative_predicate = std::greater_equal<double>{};
688 
689  } else
690  return error("value for \"breed_assortative_condition\" could not be understood\n");
691 
692  } else {
693  _assortative_predicate = std::equal_to<double>{};
694  }
695 
696  if( get_parameter("mating_proportion")->isSet()) {
697  // proportion of time mating is done at random
698  _prop_non_assortative = get_parameter_value("mating_proportion");
699  }
700  else
702 
703  // backup the mating function
705 
706 
707 
708  return true;
709 }
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:126
Individual *(LCE_Breed_base::* MatingFuncPtr)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:58
virtual bool setParameters()
Definition: LCEbreed.cc:75
std::string _LCELinkedTraitType
The name of the linked trait.
Definition: lifecycleevent.h:83
string getArg()
Definition: param.h:142
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:141
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:137
static string removeEnclosingChar(const string &str, const char o, const char c, bool allowMissing=false)
Removes characters enclosing a string.
Definition: tstring.h:354
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().

+ Here is the caller graph for this function:

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

842 {
843  // we test the difference between the male and female values
844  // to match with the predicate, we take diff = male - female
845  // predicate tells how the male value must be relative to the female value:
846  // "<=": males must be smaller or equal to the female to mate,
847  // thus, male - female <= 0 to match.
848  double diff = male_trait_value - female_trait_value;
849 
850  // by default the assortative value is 0 (diff b/n female and male phenotype)
851  if(abs(diff) <= (_assortative_value + _assortative_tolerance))
852  diff = _assortative_value;
853 
855 }

References _assortative_predicate, _assortative_tolerance, and _assortative_value.

Referenced by assortative_mating().

+ Here is the caller graph for this function:

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.2 by  doxygen 1.9.1

Catalogued on GSR