Nemo  2.4.0
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 ( )
610  : LifeCycleEvent("breed_assortative",""),
613 {
615 
616  add_parameter("breed_assortative_trait", STR, true, false, 0, 0, updater); //the trait used for the assortment
617  add_parameter("breed_assortative_tolerance", DBL, false, false, 0, 0, updater); //the threshold used for mating
618  add_parameter("breed_assortative_condition", STR, false, false, 0, 0, updater); //the predicate used to test for assortment
619  add_parameter("breed_assortative_value", DBL, false, false, 0, 0, updater); //the value matched by the difference b/n male and female
620 
621  // get_parameter("mating_system")->setIsRequired(false);
622 
623 }
Individual *(LCE_Breed_base::* AssortativeMatingFuncPtr)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:428
double _assortative_value
Definition: LCEbreed.h:414
double _prop_non_assortative
Definition: LCEbreed.h:424
double _assortative_tolerance
Definition: LCEbreed.h:417
Individual *(LCE_Breed_base::* MatingFuncPtr_base)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:426
std::function< bool(double, double)> _assortative_predicate
Definition: LCEbreed.h:422
double assortative_value_with_tolerance
Definition: LCEbreed.h:419
virtual bool setParameters()
Definition: LCEbreed.cc:627
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:97
Implementation of the ParamUpdaterBase interface.
Definition: param.h:362
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:111
@ DBL
Definition: types.h:77
@ STR
Definition: types.h:77

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

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_BreedAssortativeMating::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

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

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.

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

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.

460 {return new LCE_BreedAssortativeMating();}
LCE_BreedAssortativeMating()
Definition: LCEbreed.cc:610

References LCE_BreedAssortativeMating().

◆ execute()

void LCE_BreedAssortativeMating::execute ( )
virtual

Implements LifeCycleEvent.

715 {
716  Patch* patch;
717  Individual* mother;
718  Individual* father;
719  Individual* NewOffsprg;
720  deque<Individual*> randmales;
721  unsigned int nbBaby;
722  double fec, fec_factor;
723 
724 #ifdef _DEBUG_
725  message("LCE_BreedAssortativeMating::execute (Patch nb: %i offsprg nb: %i adlt nb: %i)\n"
727 #endif
728 
729  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
730 
731  patch = _popPtr->getPatch(i);
732 
733  if( !checkMatingCondition(patch) ) continue; // set to checkNoSelfing()
734 
735  randmales.clear();
736  // randomize the males within the patch
737  patch->getCopy(MAL, ADLTx, randmales);
738 
739  ScrambleContainer(randmales.size(), randmales);
740 
741  for(unsigned int size = patch->size(FEM, ADLTx), indexOfMother = 0;
742  indexOfMother < size;
743  indexOfMother++)
744  {
745  mother = patch->get(FEM, ADLTx, indexOfMother);
746 
747  nbBaby = (unsigned int)mother->setFecundity( fec ) ;
748 
749  if(nbBaby == 0) continue; // skip this female
750 
751  // choose a male:
753  father = non_assortative_mating(patch, mother, indexOfMother);
754  else
755  father = assortative_mating(randmales, mother, indexOfMother);
756 
757  if(father == NULL) continue; // move to the next female if mating wasn't possible
758 
759  for(unsigned int j = 0; j < nbBaby; ++j) {
760 
761  // LAMPREY SPECIFIC !!!
762 // NewOffsprg = breed_lamprey(mother, father, i);
763 //
764 // patch->add(NewOffsprg->getSex(), OFFSx, NewOffsprg);
765 
766  }
767  }
768  }
769 }
double setFecundity(double value)
Sets the fecundity to the value given and returns it.
Definition: individual.h:206
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:791
void ScrambleContainer(const int length, deque< Individual * > &array)
Definition: LCEbreed.cc:860
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:773
bool checkMatingCondition(Patch *thePatch)
Checks if any mating will take place in the patch passed as argument.
Definition: LCEbreed.h:185
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:80
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:311
unsigned int getPatchNbr()
Definition: metapop.h:275
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:256
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:431
void getCopy(sex_t SEX, age_idx AGE, deque< Individual * > &to)
Definition: metapop.h:725
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:497
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:533
void clear(sex_t SEX, age_idx AGE)
Sets the size of the appropriate container to zero.
Definition: metapop.h:675
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:126
void message(const char *message,...)
Definition: output.cc:39
@ FEM
Definition: types.h:36
@ MAL
Definition: types.h:36
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:53
@ ADLTx
Definition: types.h:41

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.

462 {}

◆ loadStatServices()

virtual void LCE_BreedAssortativeMating::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

463 {}

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

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

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.

465 {return 0;}

◆ requiredAgeClass()

virtual age_t LCE_BreedAssortativeMating::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

467 {return ADULTS;}

References ADULTS.

◆ resetParameterFromSource()

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

Implements SimComponent.

464 {return false;}

◆ ScrambleContainer()

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

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.

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

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.

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

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.0 by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR