/// <summary> /// Model the management activities for each breed /// </summary> public IEnumerable <ActivityFolder> GetManageBreeds(ActivityFolder herd) { List <ActivityFolder> breeds = new List <ActivityFolder>(); foreach (int id in RumIDs) { // Add a new folder for individual breed ActivityFolder breed = new ActivityFolder(herd) { Name = "Manage " + RumSpecs.ColumnNames[id] }; // Manage breed numbers RuminantActivityManage numbers = new RuminantActivityManage(breed) { MaximumBreedersKept = RumSpecs.GetData <int>(2, id), MinimumBreedersKept = RumSpecs.GetData <int>(38, id), MaximumBreedingAge = RumSpecs.GetData <int>(3, id), MaximumBullAge = RumSpecs.GetData <double>(25, id), MaleSellingAge = RumSpecs.GetData <double>(5, id), MaleSellingWeight = RumSpecs.GetData <double>(6, id) }; numbers.Add(new ActivityTimerInterval(numbers) { Name = "NumbersTimer", Interval = 12, MonthDue = 12 }); breed.Add(numbers); // Manage breed weaning breed.Add(new RuminantActivityWean(breed) { WeaningAge = RumSpecs.GetData <double>(7, id), WeaningWeight = RumSpecs.GetData <double>(8, id) }); // Manage breed milking if (RumSpecs.GetData <double>(18, id) > 0) { breed.Add(new RuminantActivityMilking(breed) { Name = "Milk", ResourceTypeName = "HumanFoodStore." + RumSpecs.ColumnNames[id] + "_Milk" }); } // Manage sale of dry breeders breed.Add(new RuminantActivitySellDryBreeders(breed) { MonthsSinceBirth = RumSpecs.GetData <double>(32, id), ProportionToRemove = RumSpecs.GetData <double>(4, id) * 0.01 }); breeds.Add(breed); } return(breeds); }
public IEnumerable <ActivityFolder> GetManageBreeds(ActivityFolder folder) { List <ActivityFolder> folders = new List <ActivityFolder>(); foreach (string breed in PresentBreeds) { string name = breed.Replace(".", " "); int index = Breeds.IndexOf(breed); ActivityFolder manage = new ActivityFolder(folder) { Name = name }; manage.Add(new RuminantActivityWean(manage) { WeaningAge = GetValue <double>(RumSpecs.Element("Weaning_age"), index), WeaningWeight = GetValue <double>(RumSpecs.Element("Weaning_weight"), index), GrazeFoodStoreName = "NativePasture" }); string homemilk = GetValue <string>(RumSpecs.Element("Home_milk"), index); if (homemilk != "0") { manage.Add(new RuminantActivityMilking(manage) { ResourceTypeName = "HumanFoodStore." + name + "_Milk" }); } manage.Add(new RuminantActivityManage(manage) { MaximumBreedersKept = GetValue <int>(RumSpecs.Element("Max_breeders"), index), MaximumBreedingAge = GetValue <int>(RumSpecs.Element("Max_breeder_age"), index), MaximumBullAge = GetValue <int>(RumSpecs.Element("Max_Bull_age"), index), MaleSellingAge = GetValue <int>(RumSpecs.Element("Anim_sell_age"), index), MaleSellingWeight = GetValue <int>(RumSpecs.Element("Anim_sell_wt"), index), GrazeFoodStoreName = "GrazeFoodStore.NativePasture" }); manage.Add(new RuminantActivitySellDryBreeders(manage) { MinimumConceptionBeforeSell = 1, MonthsSinceBirth = GetValue <int>(RumSpecs.Element("Joining_age"), index), ProportionToRemove = GetValue <double>(RumSpecs.Element("Dry_breeder_cull_rate"), index) * 0.01 }); folders.Add(manage); } return(folders); }
public ActivityFolder GetAnnualExpenses(ActivityFolder cashflow) { ActivityFolder annual = new ActivityFolder(cashflow) { Name = "AnnualExpenses" }; // Names of parameters to search for in the Element string[] items = new string[] { "Farm_maint", "Mach_maint", "Fuel", "Pests", "Contractors", "Admin", "Rates", "Insurance", "Electricity", "Water", "Other_costs" }; foreach (string item in items) { string value = FindFirst(SingleParams, item).Value; int.TryParse(value, out int amount); // Only need to add the element if its a non-zero expenditure if (amount <= 0) { continue; } FinanceActivityPayExpense expense = new FinanceActivityPayExpense(annual) { Name = item.Replace("_", ""), Amount = amount, AccountName = "Finances.Bank", IsOverhead = false }; annual.Add(expense); } return(annual); }
/// <summary> /// Return a collection of the annual expenses from the IAT data /// </summary> /// <param name="cashflow">The base model</param> public ActivityFolder GetAnnualExpenses(ActivityFolder cashflow) { var annual = new ActivityFolder(cashflow) { Name = "AnnualExpenses" }; // Names of the expenses var rows = Overheads.RowNames; // Amounts of the expenses var amounts = Overheads.GetColData <double>(0); // Look at each row in the overheads table foreach (string row in rows) { // The overheads table contains more than just annual data, // so stop at the "Int_rate" row (table is ordered) if (row == "Int_rate") { break; } // Find the upkeep amount int index = rows.FindIndex(s => s == row); double amount = amounts.ElementAt(index); // Only need to add the element if its a non-zero expenditure if (amount > 0) { annual.Add(new FinanceActivityPayExpense(annual) { Name = row.Replace("_", ""), Amount = amount }); } } // If there are no annual expenses, ignore this folder if (annual.Children.Count == 0) { return(null); } return(annual); }
public ActivityFolder GetMonthlyExpenses(ActivityFolder cashflow) { ActivityFolder monthly = new ActivityFolder(cashflow) { Name = "MonthlyExpenses" }; string value = FindFirst(SingleParams, "Living_cost").Value; double.TryParse(value, out double amount); monthly.Add(new FinanceActivityPayExpense(monthly) { Name = "LivingCost", Amount = amount, AccountName = "Finance.Bank" }); return(monthly); }
/// <summary> /// Gets the monthly living expenses from the IAT data /// </summary> /// <param name="cashflow">The model to attach the data to</param> public ActivityFolder GetMonthlyExpenses(ActivityFolder cashflow) { var monthly = new ActivityFolder(cashflow) { Name = "MonthlyExpenses" }; // Find the monthly living cost double amount = Overheads.GetData <double>(13, 0); // Only include if non-zero if (amount == 0) { return(null); } monthly.Add(new FinanceActivityPayExpense(monthly) { Name = "LivingCost", Amount = amount }); return(monthly); }