Beispiel #1
0
        /// <summary>
        /// A funtion to add intake and track changes in %N and DietDryMatterDigestibility
        /// </summary>
        /// <param name="intake">Feed request contianing intake information kg, %n, DMD</param>
        public void AddIntake(RuminantFeedRequest intake)
        {
            // determine the adjusted DMD of all intake
            this.DietDryMatterDigestibility = ((this.Intake * this.DietDryMatterDigestibility / 100.0) + (intake.FeedActivity.FeedType.DMD / 100.0 * intake.Amount)) / (this.Intake + intake.Amount) * 100.0;
            // determine the adjusted percentage N of all intake
            this.PercentNOfIntake = ((this.Intake * this.PercentNOfIntake / 100.0) + (intake.FeedActivity.FeedType.Nitrogen / 100.0 * intake.Amount)) / (this.Intake + intake.Amount) * 100.0;;

            this.Intake += intake.Amount;
        }
Beispiel #2
0
        private void OnWFRequestFeed(object sender, EventArgs e)
        {
            if (labourLimiter > 0)
            {
                RuminantHerd    ruminantHerd = Resources.RuminantHerd();
                List <Ruminant> herd         = ruminantHerd.Herd;

                if (herd == null && herd.Count == 0)
                {
                    return;
                }

                // get month from clock
                int month = Clock.Today.Month;

                // get list from filters
                foreach (var child in this.Children)
                {
                    if (child.GetType() == typeof(RuminantFilterGroup))
                    {
                        foreach (Ruminant ind in herd.Filter(child as RuminantFilterGroup))
                        {
                            RuminantFeedRequest freqest = new RuminantFeedRequest();
                            freqest.FeedActivity = this;
                            freqest.Requestor    = ind;
                            freqest.Amount       = 0;
                            switch (FeedStyle)
                            {
                            case RuminantFeedActivityTypes.SpecifiedAmount:
                                freqest.Amount = (child as RuminantFilterGroup).MonthlyValues[month - 1];                                         // * ind.Number;
                                break;

                            case RuminantFeedActivityTypes.ProportionOfWeight:
                                freqest.Amount = (child as RuminantFilterGroup).MonthlyValues[month - 1] * ind.Weight;                                         // * ind.Number;
                                break;

                            case RuminantFeedActivityTypes.ProportionOfPotentialIntake:
                                freqest.Amount = (child as RuminantFilterGroup).MonthlyValues[month - 1] * ind.PotentialIntake;                                         // * ind.Number;
                                break;

                            case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired:
                                freqest.Amount = (child as RuminantFilterGroup).MonthlyValues[month - 1] * (ind.PotentialIntake - ind.Intake);                                         // * ind.Number;
                                break;

                            default:
                                break;
                            }
                            freqest.Amount *= labourLimiter;
                            FoodSource.Remove(freqest);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="RemoveRequest"></param>
        public void Remove(object RemoveRequest)
        {
            RuminantFeedRequest removeRequest = RemoveRequest as RuminantFeedRequest;

            // limit by available
            removeRequest.Amount = Math.Min(removeRequest.Amount, amount);
            // add to intake and update %N and %DMD values
            removeRequest.Requestor.AddIntake(removeRequest);
            // Remove from resource
            Remove(removeRequest.Amount, removeRequest.FeedActivity.Name, removeRequest.Requestor.BreedParams.Name);
        }
Beispiel #4
0
        private void OnWFRequestFeed(object sender, EventArgs e)
        {
            RuminantHerd    ruminantHerd = Resources.RuminantHerd();
            List <Ruminant> herd         = ruminantHerd.Herd;

            IResourceType grazeStoreType = null;

            if (FeedArbitratorName != "")
            {
                grazeStoreType = Arbitrators.GetByName(FeedArbitratorName) as IResourceType;
            }

            // for each paddock defined in PastureActivityManage
            foreach (PastureActivityManage pasture in Activities.Children.Where(a => a.GetType() == typeof(PastureActivityManage)))
            {
                if (FeedArbitratorName == "")
                {
                    grazeStoreType = pasture.FeedType;
                }

                // create feeding activity for this pasture
                RuminantActivityGraze activity = new RuminantActivityGraze();
                activity.FeedPriority = this.FeedPriority;
                activity.FeedType     = pasture.FeedType;
                activity.HoursGrazed  = this.HoursGrazed;
                activity.Name         = String.Format("Graze {0}", pasture.FeedType.Name);

                // calculate kg per ha available
                double kgPerHa = pasture.FeedType.Amount / pasture.Area;

                if (pasture.FeedType.Amount > 0)
                {
                    // get list of all Ruminants in this paddock
                    foreach (Ruminant ind in herd.Where(a => a.Location == pasture.Name))
                    {
                        RuminantFeedRequest freqest = new RuminantFeedRequest();
                        freqest.FeedActivity = activity;
                        freqest.Requestor    = ind;

                        // Reduce potential intake based on pasture quality for the proportion consumed.


                        // calculate intake from potential modified by pasture availability and hours grazed
                        freqest.Amount = ind.PotentialIntake * (1 - Math.Exp(-ind.BreedParams.IntakeCoefficientBiomass * kgPerHa)) * (HoursGrazed / 8);
                        grazeStoreType.Remove(freqest);
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="RemoveRequest"></param>
        public void Remove(object RemoveRequest)
        {
            // Called if activity removes food directly from GrazeFoodStore (no Feed Arbitrator used)
            // Remove requested amount from all pools as proportion pool amount of whole biomass

            RuminantFeedRequest feedRequest = RemoveRequest as RuminantFeedRequest;
            double totalAvailable           = Pools.Sum(a => a.Amount);
            double amountToTake             = Math.Min(feedRequest.Amount, totalAvailable);

            foreach (var pool in Pools)
            {
                feedRequest.Amount = amountToTake * (pool.Amount / totalAvailable);
                pool.Remove(feedRequest);
            }
        }
Beispiel #6
0
        private void OnWFRequestFeed(object sender, EventArgs e)
        {
            RuminantHerd ruminantHerd = Resources.RuminantHerd();
            List<Ruminant> herd = ruminantHerd.Herd;

            IResourceType grazeStoreType = null;
            if (FeedArbitratorName != "")
            {
                grazeStoreType = Arbitrators.GetByName(FeedArbitratorName) as IResourceType;
            }

            // for each paddock defined in PastureActivityManage
            foreach (PastureActivityManage pasture in Activities.Children.Where(a => a.GetType() == typeof(PastureActivityManage)))
            {
                if (FeedArbitratorName == "")
                {
                    grazeStoreType = pasture.FeedType;
                }

                // create feeding activity for this pasture
                RuminantActivityGraze activity = new RuminantActivityGraze();
                activity.FeedPriority = this.FeedPriority;
                activity.FeedType = pasture.FeedType;
                activity.HoursGrazed = this.HoursGrazed;
                activity.Name = String.Format("Graze {0}", pasture.FeedType.Name);

                // calculate kg per ha available
                double kgPerHa = pasture.FeedType.Amount / pasture.Area;

                if (pasture.FeedType.Amount > 0)
                {
                    // get list of all Ruminants in this paddock
                    foreach (Ruminant ind in herd.Where(a => a.Location == pasture.Name))
                    {
                        RuminantFeedRequest freqest = new RuminantFeedRequest();
                        freqest.FeedActivity = activity;
                        freqest.Requestor = ind;

                        // Reduce potential intake based on pasture quality for the proportion consumed.

                        // calculate intake from potential modified by pasture availability and hours grazed
                        freqest.Amount = ind.PotentialIntake * (1 - Math.Exp(-ind.BreedParams.IntakeCoefficientBiomass * kgPerHa)) * (HoursGrazed / 8);
                        grazeStoreType.Remove(freqest);
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// A funtion to add intake and track changes in %N and DietDryMatterDigestibility
        /// </summary>
        /// <param name="intake">Feed request contianing intake information kg, %n, DMD</param>
        public void AddIntake(RuminantFeedRequest intake)
        {
            // determine the adjusted DMD of all intake
            this.DietDryMatterDigestibility = ((this.Intake * this.DietDryMatterDigestibility / 100.0) + (intake.FeedActivity.FeedType.DMD / 100.0 * intake.Amount)) / (this.Intake + intake.Amount) * 100.0;
            // determine the adjusted percentage N of all intake
            this.PercentNOfIntake = ((this.Intake * this.PercentNOfIntake / 100.0) + (intake.FeedActivity.FeedType.Nitrogen / 100.0 * intake.Amount)) / (this.Intake + intake.Amount) * 100.0; ;

            this.Intake += intake.Amount;
        }