Exemplo n.º 1
0
        /// <summary>
        /// Copies the parameters into an array of genotype structures
        /// </summary>
        /// <param name="model">The animal model</param>
        /// <param name="genoValues">The genotypes returned</param>
        public static void MakeGenotypesValue(StockList model, ref StockGeno[] genoValues)
        {
            AnimalParamSet parameters;
            string         damBreed = string.Empty;
            string         sireBreed = string.Empty;
            int            generation = 0;
            int            idx, jdx;

            Array.Resize(ref genoValues, model.GenotypeCount());
            for (idx = 0; idx <= model.GenotypeCount() - 1; idx++)
            {
                parameters = model.GetGenotype(idx);

                if (parameters.iParentageCount() == 1)
                {
                    damBreed   = parameters.sParentageBreed(0);
                    sireBreed  = damBreed;
                    generation = 0;
                }
                else if ((parameters.iParentageCount() == 2) && (parameters.fParentagePropn(0) > 0))
                {
                    damBreed   = parameters.sParentageBreed(0);
                    sireBreed  = parameters.sParentageBreed(1);
                    generation = Convert.ToInt32(Math.Max(0, Math.Round(Math.Log(parameters.fParentagePropn(0)) / Math.Log(0.5))));    // TODO: may need checking
                }
                else if (parameters.iParentageCount() == 2)
                {
                    sireBreed  = parameters.sParentageBreed(1);
                    damBreed   = sireBreed;
                    generation = 0;
                }
                else
                {
                    damBreed   = parameters.sParentageBreed(0);
                    sireBreed  = parameters.sParentageBreed(1);
                    generation = 0;
                }

                genoValues[idx].Name       = parameters.sName;
                genoValues[idx].DamBreed   = damBreed;
                genoValues[idx].SireBreed  = sireBreed;
                genoValues[idx].Generation = generation;

                genoValues[idx].SRW          = parameters.BreedSRW;
                genoValues[idx].DeathRate    = parameters.AnnualDeaths(false);
                genoValues[idx].WnrDeathRate = parameters.AnnualDeaths(true);
                genoValues[idx].RefFleeceWt  = parameters.PotentialGFW;
                genoValues[idx].MaxFibreDiam = parameters.MaxMicrons;
                genoValues[idx].FleeceYield  = parameters.FleeceYield;
                genoValues[idx].PeakMilk     = parameters.PotMilkYield;

                if (parameters.Animal == GrazType.AnimalType.Sheep)
                {
                    Array.Resize(ref genoValues[idx].Conception, 3);
                }
                else
                {
                    Array.Resize(ref genoValues[idx].Conception, 2);
                }
                for (jdx = 0; jdx < genoValues[idx].Conception.Length; jdx++)
                {
                    genoValues[idx].Conception[jdx] = parameters.Conceptions[jdx];
                }
            }
        }