/// <summary> /// Convert the Stock geno object to TSingleGenotypeInits /// </summary> /// <param name="aValue"></param> /// <param name="Inits"></param> public void Value2GenotypeInits(TStockGeno aValue, ref TSingleGenotypeInits Inits) { int Idx; Inits.sGenotypeName = aValue.name; Inits.sDamBreed = aValue.dam_breed; Inits.sSireBreed = aValue.sire_breed; Inits.iGeneration = aValue.generation; Inits.SRW = aValue.srw; Inits.PotFleeceWt = aValue.ref_fleece_wt; Inits.MaxFibreDiam = aValue.max_fibre_diam; Inits.FleeceYield = aValue.fleece_yield; Inits.PeakMilk = aValue.peak_milk; Inits.DeathRate[FALSE] = aValue.death_rate; Inits.DeathRate[TRUE] = aValue.wnr_death_rate; // Catch weaner death rates that are missing from v1.3 input data... if (Inits.DeathRate[TRUE] == 0.0) Inits.DeathRate[TRUE] = Inits.DeathRate[FALSE]; for (int i = 0; i < Inits.Conceptions.Length; i++) Inits.Conceptions[0] = 0.0; for (Idx = 1; Idx <= aValue.conception.Length; Idx++) Inits.Conceptions[Idx-1] = aValue.conception[Idx-1]; }
/// <summary> /// Copies the parameters into an array of genotype structures /// </summary> /// <param name="Model"></param> /// <param name="aValue"></param> public static void MakeGenotypesValue(TStockList Model, ref TStockGeno[] aValue) { TAnimalParamSet Params; string sDamBreed = ""; string sSireBreed = ""; int iGeneration = 0; int Idx, Jdx; Array.Resize(ref aValue, Model.iGenotypeCount()); for (Idx = 0; Idx <= Model.iGenotypeCount() - 1; Idx++) { Params = Model.getGenotype(Idx); if (Params.iParentageCount() == 1) { sDamBreed = Params.sParentageBreed(0); sSireBreed = sDamBreed; iGeneration = 0; } else if ((Params.iParentageCount() == 2) && (Params.fParentagePropn(0) > 0)) { sDamBreed = Params.sParentageBreed(0); sSireBreed = Params.sParentageBreed(1); iGeneration = Convert.ToInt32(Math.Max(0, Math.Round(Math.Log(Params.fParentagePropn(0)) / Math.Log(0.5)))); //TODO: may need checking } else if (Params.iParentageCount() == 2) { sSireBreed = Params.sParentageBreed(1); sDamBreed = sSireBreed; iGeneration = 0; } else { sDamBreed = Params.sParentageBreed(0); sSireBreed = Params.sParentageBreed(1); iGeneration = 0; } aValue[Idx].name = Params.sName; aValue[Idx].dam_breed = sDamBreed; aValue[Idx].sire_breed = sSireBreed; aValue[Idx].generation = iGeneration; aValue[Idx].srw = Params.BreedSRW; aValue[Idx].death_rate = Params.AnnualDeaths(false); aValue[Idx].wnr_death_rate = Params.AnnualDeaths(true); aValue[Idx].ref_fleece_wt = Params.PotentialGFW; aValue[Idx].max_fibre_diam = Params.MaxMicrons; aValue[Idx].fleece_yield = Params.FleeceYield; aValue[Idx].peak_milk = Params.PotMilkYield; if (Params.Animal == GrazType.AnimalType.Sheep) Array.Resize(ref aValue[Idx].conception, 3); else Array.Resize(ref aValue[Idx].conception, 2); for (Jdx = 0; Jdx < aValue[Idx].conception.Length; Jdx++) aValue[Idx].conception[Jdx] = Params.Conceptions[Jdx]; } }