private void SetParameters(RuminantType ruminant) { List <Tuple <string, string, double> > parameters = new List <Tuple <string, string, double> >() { new Tuple <string, string, double>("concep_rate_assym", "ConceptionRateAsymptote", 1), new Tuple <string, string, double>("concep_rate_coeff", "ConceptionRateCoefficient", 1), new Tuple <string, string, double>("concep_rate_incpt", "ConceptionRateIntercept", 1), new Tuple <string, string, double>("birth_SRW", "SRWBirth", 1), new Tuple <string, string, double>("cashmere_coeff", "CashmereCoefficient", 1), new Tuple <string, string, double>("Critical_cow_wt", "CriticalCowWeight", 0.01), new Tuple <string, string, double>("grwth_coeff1", "AgeGrowthRateCoefficient", 1), new Tuple <string, string, double>("grwth_coeff2", "SRWGrowthScalar", 1), new Tuple <string, string, double>("intake_coeff", "IntakeCoefficient", 1), new Tuple <string, string, double>("intake_incpt", "IntakeIntercept", 1), new Tuple <string, string, double>("IPI_coeff", "InterParturitionIntervalCoefficient", 1), new Tuple <string, string, double>("IPI_incpt", "InterParturitionIntervalIntercept", 1), new Tuple <string, string, double>("Joining_age", "MinimumAge1stMating", 1), new Tuple <string, string, double>("Joining_size", "MinimumSize1stMating", 0.01), new Tuple <string, string, double>("juvenile_mort_coeff", "JuvenileMortalityCoefficient", 1), new Tuple <string, string, double>("juvenile_mort_exp", "JuvenileMortalityExponent", 1), new Tuple <string, string, double>("juvenile_mort_max", "JuvenileMortalityMaximum", 0.01), new Tuple <string, string, double>("kg_coeff", "EGrowthEfficiencyCoefficient", 1), new Tuple <string, string, double>("kg_incpt", "EGrowthEfficiencyIntercept", 1), new Tuple <string, string, double>("kl_coeff", "ELactationEfficiencyCoefficient", 1), new Tuple <string, string, double>("kl_incpt", "ELactationEfficiencyIntercept", 1), new Tuple <string, string, double>("km_coeff", "EMaintEfficiencyCoefficient", 1), new Tuple <string, string, double>("km_incpt", "EMaintEfficiencyIntercept", 1), new Tuple <string, string, double>("kme", "Kme", 1), new Tuple <string, string, double>("Milk_Curve_nonsuck", "MilkCurveNonSuckling", 1), new Tuple <string, string, double>("Milk_Curve_suck", "MilkCurveSuckling", 1), new Tuple <string, string, double>("Milk_end", "MilkingDays", 30), new Tuple <string, string, double>("Milk_intake_coeff", "MilkIntakeCoefficient", 1), new Tuple <string, string, double>("Milk_intake_incpt", "MilkIntakeIntercept", 1), new Tuple <string, string, double>("Milk_max", "MilkPeakYield", 1), new Tuple <string, string, double>("Milk_offset_day", "MilkOffsetDay", 1), new Tuple <string, string, double>("Milk_Peak_day", "MilkPeakDay", 1), new Tuple <string, string, double>("Mortality_base", "MortalityBase", 0.01), new Tuple <string, string, double>("protein_coeff", "ProteinCoefficient", 1), new Tuple <string, string, double>("Rum_gest_int", "GestationLength", 1), new Tuple <string, string, double>("SRW", "SRWFemale", 1), new Tuple <string, string, double>("Twin_rate", "TwinRate", 1), new Tuple <string, string, double>("wool_coeff", "WoolCoefficient", 1) }; int index = Breeds.IndexOf(ruminant.Breed); foreach (var parameter in parameters) { double value = GetValue <double>(FindFirst(Source, parameter.Item1), index) * parameter.Item3; ruminant.GetType().GetProperty(parameter.Item2).SetValue(ruminant, value); } }
/// <summary> /// Map the IAT parameters to their CLEM counterpart /// </summary> public void SetParameters(RuminantType ruminant) { foreach (var map in Maps) { // Find the subtable which contains the parameter var table = this.GetType().GetProperty(map.Table).GetValue(this, null) as SubTable; // Find the row which contains the parameter (if it exists) int row = table.RowNames.FindIndex(s => s == map.ParamIAT); if (row < 0) { continue; } // Convert the value of the parameter to CLEM double value = table.GetData <double>(row, RumActiveID) * map.Proportion; // Set the value of the CLEM parameter ruminant.GetType().GetProperty(map.ParamCLEM).SetValue(ruminant, value); } }