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

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

            mutation.Scramble(chromosome, 2, 2, GATestHelper.GetTravelingSalesmanDefaultConfiguration());
        }
Exemple #3
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);
        }