Example #1
0
        public void ItErrorsIfTheIndexesAreOutOfRange()
        {
            var chromosome = GATestHelper.GetAlphabetCharacterChromosome();
            var mutation   = new ScrambleMutation();

            mutation.Scramble(chromosome, -1, 1, GATestHelper.GetTravelingSalesmanDefaultConfiguration());
        }
Example #2
0
        public void ItErrorsIfEndIsSameAsStart()
        {
            var chromosome = GATestHelper.GetAlphabetCharacterChromosome();
            var mutation   = new ScrambleMutation();

            mutation.Scramble(chromosome, 2, 2, GATestHelper.GetTravelingSalesmanDefaultConfiguration());
        }
Example #3
0
        public void ItCanRandomlyScrambleGenes()
        {
            var chromosome = GATestHelper.GetAlphabetCharacterChromosome();
            var mutation   = new ScrambleMutation();

            for (int i = 0; i < 100; i++)
            {
                mutation.Mutate(chromosome, GATestHelper.GetTravelingSalesmanDefaultConfiguration());
            }
        }
Example #4
0
        public void ItCanScrambleGenes()
        {
            var chromosome = GATestHelper.GetAlphabetCharacterChromosome();
            var mutation   = new ScrambleMutation();

            mutation.Scramble(chromosome, 2, 6, GATestHelper.GetTravelingSalesmanDefaultConfiguration());

            Assert.AreNotEqual("A,B,C,D,E,F,G,H,I,J", chromosome.ToString());

            var genes = chromosome.Genes.Cast <TravelingSalesmanGene>().ToArray();

            Assert.AreEqual('A', genes[0].Value);
            Assert.AreEqual('B', genes[1].Value);
            Assert.AreEqual('H', genes[7].Value);
            Assert.AreEqual('I', genes[8].Value);
            Assert.AreEqual('J', genes[9].Value);
        }
Example #5
0
 public void Setup()
 {
     scrambleMutation = new ScrambleMutation();
 }