Evolution/Evolution/Breeders/BreederGenerators.cs
/// <summary>
/// Returns a breeder which creates a population of genotypes with random values for <see cref="FloatGene"/> optionally bounded
/// </summary>
/// <param name="numberOfGenes">The number of genes.</param>
/// <param name="min">The minimum. If it is set, the gene will be bounded and its values will have this minimum</param>
/// <param name="max">The maximum. If it is set, the gene will be bounded and its values will have this maximum</param>
/// <param name="populationSize">Size of the population.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentException">
/// </exception>
Returns a breeder which creates a population of genotypes with random values for  optionally bounded
Returns a breeder which creates a population of genotypes with random values for optionally bounded
public static GenotypeGeneratorBreeder<ListGenotype<FloatGene>> FloatBreeder(int numberOfGenes, double? min,
            double? max, int populationSize)
        {
            IEnumerable<double> sequence;
            if (min.HasValue != max.HasValue)
                throw new ArgumentException(Resources.Both_or_none_bounds_must_be_null);
            if (numberOfGenes <= 0)
                throw new ArgumentException($"Must have a non-zero positive {nameof(numberOfGenes)}");
            if (populationSize < 0)
                throw new ArgumentException($"Must have a positive {nameof(populationSize)}");
            if (min.GetValueOrDefault() > max.GetValueOrDefault())
                throw new ArgumentException($"{nameof(max)} must be greater or equal than {nameof(min)}");
            if (min.HasValue)
                sequence = RandomGenerator.GetInstance().DoubleSequence(max.Value, min.Value);
            else
                sequence = RandomGenerator.GetInstance().DoubleSequence();
            return new GenotypeGeneratorBreeder<
                ListGenotype<FloatGene>>(
                () => new ListGenotype<FloatGene>(
                    sequence.Take(numberOfGenes).Select(i => new FloatGene(i, max, min))),
                populationSize);
        }
public static GenotypeGeneratorBreeder < ListGenotype < FloatGene > > FloatBreeder ( int numberOfGenes , double ? min , double ? max , int populationSize ) { IEnumerable < double > sequence ; if ( min . HasValue != max . HasValue ) throw new ArgumentException ( Resources . Both_or_none_bounds_must_be_null ) ; if ( numberOfGenes <= 0 ) throw new ArgumentException ( $" Must have a non-zero positive  { nameof ( numberOfGenes ) } " ) ; if ( populationSize < 0 ) throw new ArgumentException ( $" Must have a positive  { nameof ( populationSize ) } " ) ; if ( min . GetValueOrDefault ( ) > max . GetValueOrDefault ( ) ) throw new ArgumentException ( $" { nameof ( max ) }  must be greater or equal than  { nameof ( min ) } " ) ; if ( min . HasValue ) sequence = RandomGenerator . GetInstance ( ) . DoubleSequence ( max . Value , min . Value ) ; else sequence = RandomGenerator . GetInstance ( ) . DoubleSequence ( ) ; return new GenotypeGeneratorBreeder < ListGenotype < FloatGene > > ( ( ) => new ListGenotype < FloatGene > ( sequence . Take ( numberOfGenes ) . Select ( i => new FloatGene ( i , max , min ) ) ) , populationSize ) ; }
Returns a breeder which creates a population of genotypes with random values for  optionally bounded
Returns a breeder which creates a population of genotypes with random values for optionally bounded
None
None
numberOfGenes
int
The number of genes.
The number of genes .
min
double?
The minimum. If it is set, the gene will be bounded and its values will have this minimum
The minimum . If it is set the gene will be bounded and its values will have this minimum
max
double?
The maximum. If it is set, the gene will be bounded and its values will have this maximum
The maximum . If it is set the gene will be bounded and its values will have this maximum
populationSize
int
Size of the population.
Size of the population .