private void OnEndOfSimulation(object sender, EventArgs e) { // report all females of breeding age at end of simulation foreach (RuminantFemale female in Herd.Where(a => a.Gender == Sex.Female && a.Age >= a.BreedParams.MinimumAge1stMating)) { RuminantReportItemEventArgs args = new RuminantReportItemEventArgs { RumObj = female, Category = "breeding stats" }; OnFinalFemaleOccurred(args); } }
/// <summary> /// Wean this individual /// </summary> public void Wean(bool report, string reason) { weaned = true; if (this.Mother != null) { this.Mother.SucklingOffspringList.Remove(this); this.Mother.NumberOfWeaned++; } if (report) { RuminantReportItemEventArgs args = new RuminantReportItemEventArgs { RumObj = this, Reason = reason }; (this.BreedParams.Parent as RuminantHerd).OnWeanOccurred(args); } }
/// <summary> /// Remove individual/cohort from the herd /// </summary> /// <param name="ind">Individual Ruminant to remove</param> /// <param name="model">Model removing individual</param> public void RemoveRuminant(Ruminant ind, IModel model) { // Remove mother ID from any suckling offspring if (ind is RuminantFemale) { string reason; switch (ind.SaleFlag) { case HerdChangeReason.Consumed: case HerdChangeReason.DiedUnderweight: case HerdChangeReason.DiedMortality: reason = "MotherDied"; break; case HerdChangeReason.MarkedSale: case HerdChangeReason.TradeSale: case HerdChangeReason.ExcessBreederSale: case HerdChangeReason.MaxAgeSale: reason = "MotherSold"; break; default: reason = "Unknown"; break; } while ((ind as RuminantFemale).SucklingOffspringList.Any()) { Ruminant offspring = (ind as RuminantFemale).SucklingOffspringList.FirstOrDefault(); offspring.Wean(true, reason); offspring.Mother = null; } } // if sold and unweaned set mothers weaning count + 1 as effectively weaned in process and not death if (!ind.Weaned & !ind.SaleFlag.ToString().Contains("Died")) { if (ind.Mother != null) { ind.Mother.NumberOfWeaned++; } } Herd.Remove(ind); LastIndividualChanged = ind; // report transaction of herd change ResourceTransaction details = new ResourceTransaction { TransactionType = TransactionType.Loss, Amount = 1, Activity = model as CLEMModel, Category = ind.SaleFlag.ToString(), ResourceType = ind.BreedParams, RelatesToResource = ind.BreedParams.NameWithParent, ExtraInformation = ind }; LastTransaction = details; TransactionEventArgs te = new TransactionEventArgs() { Transaction = details }; OnTransactionOccurred(te); // report female breeding stats if needed if (ind.Sex == Sex.Female & ind.Age >= ind.BreedParams.MinimumAge1stMating) { RuminantReportItemEventArgs args = new RuminantReportItemEventArgs { RumObj = ind, Category = "breeding stats" }; OnFinalFemaleOccurred(args); } // remove change flag ind.SaleFlag = HerdChangeReason.None; }