public void Recombine()
        {
            Func <DoubleGene> Factory = delegate()
            {
                return(DoubleGene.Of(0, 100));
            };

            var v = MutableSeq.Of(Factory, 10);
            var w = MutableSeq.Of(Factory, 10);

            var recombinator = new IntermediateCrossover <DoubleGene, double>(0.1, 10);

            recombinator.Crossover(v, w);

            Assert.True(v.ForAll(dg => dg.IsValid));
            Assert.True(w.ForAll(dg => dg.IsValid));
        }
예제 #2
0
        public void Recombine()
        {
            DoubleGene Factory()
            {
                return(DoubleGene.Of(0, 100));
            }

            var v = MutableSeq.Of(Factory, 10);
            var w = MutableSeq.Of(Factory, 10);

            var recombinator = new LineCrossover <DoubleGene, double>();

            recombinator.Crossover(v, w);

            Assert.True(v.ForAll(dg => dg.IsValid));
            Assert.True(w.ForAll(dg => dg.IsValid));
        }
예제 #3
0
 public static Phenotype <DoubleGene, double> NewDoublePhenotype(double value)
 {
     return(Phenotype.Of(Genotype.Of(
                             DoubleChromosome.Of(DoubleGene.Of(value, 0, 10))), 0, Ff
                         ).Evaluate());
 }
예제 #4
0
 private static Phenotype <DoubleGene, double> CreatePhenotype(double value)
 {
     return(Phenotype.Of(Genotype.Of(DoubleChromosome.Of(DoubleGene.Of(value, 0, 10))), 0, gt => gt.Gene.Allele));
 }