/// <summary>
        /// Applies each function in this Lifestage process to a cohort item that is owned by a Lifestage
        /// </summary>
        /// <param name="cohortItem"></param>
        public void ProcessCohort(Cohort cohortItem)
        {
            //apply the functions from the function list to this cohort
            foreach (IFunction func in FunctionList)
            {
                if (func == ProgenyFunc)    // assume there is only one of these for the process
                {
                    if (FecundityFunc != null && ProgenyFunc != null)
                    {
                        if (cohortItem.Fecundity < 0)
                        {
                            cohortItem.Fecundity = FecundityFunc.Value();
                        }
                        double progenyrate = ProgenyFunc.Value();

                        if (cohortItem.Fecundity > 0)
                        {
                            //number of Progeny produced per individual per timestep
                            double progenyRate = Math.Max(0.0, Math.Min(cohortItem.Fecundity, progenyrate));
                            if (progenyRate > 0)
                            {
                                double numberToCreate = cohortItem.Count * progenyRate;
                                if (numberToCreate > 0)
                                {
                                    //transfer magic here
                                    LifeStage destStage = cohortItem.OwningStage.OwningCycle.ChildStages.Find(s => s.Name == TransferTo);
                                    cohortItem.OwningStage.Reproduce(cohortItem, destStage, numberToCreate);
                                }
                                cohortItem.Fecundity -= progenyRate;
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("Fecundity and Progeny functions must be configured for " + this.Name + " lifestage");
                    }
                }
                else
                {
                    //execute another function
                }
            }
        }
Example #2
0
 /// <summary>
 /// Remove a specified cohort item
 /// </summary>
 /// <param name="aCohort">The cohort object to be removed</param>
 public void Remove(Cohort aCohort)
 {
     CohortList.Remove(aCohort);
 }
 /// <summary>
 /// Applies each function in this Lifestage process to a cohort item that is owned by a Lifestage
 /// </summary>
 /// <param name="cohortItem">An existing cohort</param>
 public void ProcessCohort(Cohort cohortItem)
 {
     //immigration does not require this
 }
Example #4
0
 /// <summary>
 /// Remove a specified cohort item
 /// </summary>
 /// <param name="aCohort">The cohort object to be removed</param>
 public void Remove(Cohort aCohort)
 {
     Cohorts.Remove(aCohort);
 }