Пример #1
0
        /// <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];
            }
        }