public void Join() { var alterer = CompositeAlterer.Join( new Mutator <DoubleGene, double>(), new SwapMutator <DoubleGene, double>() ); Assert.Equal(2, alterer.Alterers.Length); Assert.Equal(new Mutator <DoubleGene, double>(), alterer.Alterers[0]); Assert.Equal(new SwapMutator <DoubleGene, double>(), alterer.Alterers[1]); alterer = CompositeAlterer.Join(alterer, new MeanAlterer <DoubleGene, double>()); Assert.Equal(3, alterer.Alterers.Length); Assert.Equal(new Mutator <DoubleGene, double>(), alterer.Alterers[0]); Assert.Equal(new SwapMutator <DoubleGene, double>(), alterer.Alterers[1]); Assert.Equal(new MeanAlterer <DoubleGene, double>(), alterer.Alterers[2]); alterer = CompositeAlterer.Of( new MeanAlterer <DoubleGene, double>(), new SwapMutator <DoubleGene, double>(), alterer, new SwapMutator <DoubleGene, double>() ); Assert.Equal(6, alterer.Alterers.Length); Assert.Equal(new MeanAlterer <DoubleGene, double>(), alterer.Alterers[0]); Assert.Equal(new SwapMutator <DoubleGene, double>(), alterer.Alterers[1]); Assert.Equal(new Mutator <DoubleGene, double>(), alterer.Alterers[2]); Assert.Equal(new SwapMutator <DoubleGene, double>(), alterer.Alterers[3]); Assert.Equal(new MeanAlterer <DoubleGene, double>(), alterer.Alterers[4]); Assert.Equal(new SwapMutator <DoubleGene, double>(), alterer.Alterers[5]); }
public IAlterer <DoubleGene, double> NewAlterer(double p) { var p3 = Math.Pow(p, 3); return(CompositeAlterer.Of( new Mutator <DoubleGene, double>(p3), new Mutator <DoubleGene, double>(p3), new Mutator <DoubleGene, double>(p3) )); }