Beispiel #1
0
 public NumericGene(NumericGene gene)
 {
     // Min and max are being set BEFORE base constructor is called.
     // This won't work :'(  Guess we just se the value here and don't call base
     Value    = gene.Value;
     MinValue = gene.MinValue;
     MaxValue = gene.MaxValue;
 }
Beispiel #2
0
        public NumericChromosome(int length, double minValue = double.MinValue, double maxValue = double.MaxValue)
        {
            IGene <double> newGene = new NumericGene(minValue, maxValue);

            if (length < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(length),
                                                      "Length of a chromosome cannot be less than 1.");
            }

            for (int i = 0; i < length; i++)
            {
                Add(newGene);
            }
        }