/// <summary> /// The method allows the activity to adjust resources requested based on shortfalls (e.g. labour) before they are taken from the pools /// </summary> public override void AdjustResourcesNeededForActivity() { // labour shortfall if any double labourLimit = this.LabourLimitProportion; overfeedProportion = 0; // TODO: adjust if multiple animal food stores included in future. // FirstOrDefault() is still known to be food store request. After this call it will be last in list with wasted and excess at start of list ResourceRequest item = ResourceRequestList.Where(a => a.ResourceType == typeof(AnimalFoodStore)).FirstOrDefault(); if (item != null) { //add limits to amout collected based on labour shortfall item.Required *= labourLimit; // account for any wastage // removed from food resource provided and then will be handled if required if less than provided in next section (DoActivity). if (ProportionTramplingWastage > 0) { double wasted = Math.Min(item.Available, item.Required) * ProportionTramplingWastage; if (wasted > 0) { ResourceRequest wastedRequest = new ResourceRequest() { AllowTransmutation = false, Required = wasted, Available = wasted, ResourceType = typeof(AnimalFoodStore), ResourceTypeName = item.ResourceTypeName, ActivityModel = this, Category = "Wastage", RelatesToResource = this.PredictedHerdName }; ResourceRequestList.Insert(0, wastedRequest); item.Required -= wasted; // adjust the food known available for the actual feed item.Available -= wasted; } } // report any excess fed above feed needed to fill animals itake (including potential multiplier if required for overfeeding) double excess = 0; if (Math.Min(item.Available, item.Required) >= feedToOverSatisfy) { excess = Math.Min(item.Available, item.Required) - feedToOverSatisfy; if (feedToOverSatisfy > feedToSatisfy) { overfeedProportion = 1; } } else if (feedToOverSatisfy > feedToSatisfy && Math.Min(item.Available, item.Required) > feedToSatisfy) { overfeedProportion = (Math.Min(item.Available, item.Required) - feedToSatisfy) / (feedToOverSatisfy - feedToSatisfy); } if (excess > 0) { ResourceRequest excessRequest = new ResourceRequest() { AllowTransmutation = false, Required = excess, Available = excess, ResourceType = typeof(AnimalFoodStore), ResourceTypeName = item.ResourceTypeName, ActivityModel = this, Category = "Overfed wastage", RelatesToResource = this.PredictedHerdName }; ResourceRequestList.Insert(0, excessRequest); item.Required -= excess; item.Available -= excess; } } return; }