Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/26/10 17:43:21 (14 years ago)
Author:
abeham
Message:

Updated CosaCrossover #889

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Permutation/3.3/Tests/CosaCrossoverTest.cs

    r2854 r2879  
    110110      TestRandom random = new TestRandom();
    111111      Permutation parent1, parent2, expected, actual;
     112      // The following test is based on an example from Wendt, O. 1994. COSA: COoperative Simulated Annealing - Integration von Genetischen Algorithmen und Simulated Annealing am Beispiel der Tourenplanung. Dissertation Thesis. IWI Frankfurt.
     113      random.Reset();
     114      random.IntNumbers = new int[] { 1 };
     115      parent1 = new Permutation(new int[] { 0, 1, 5, 2, 4, 3 });
     116      Assert.IsTrue(parent1.Validate());
     117      parent2 = new Permutation(new int[] { 3, 0, 2, 1, 4, 5 });
     118      Assert.IsTrue(parent2.Validate());
     119      expected = new Permutation(new int[] { 0, 1, 4, 2, 5, 3 });
     120      Assert.IsTrue(expected.Validate());
     121      actual = CosaCrossover.Apply(random, parent1, parent2);
     122      Assert.IsTrue(actual.Validate());
     123      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
     124      // The following test is not based on published examples
    112125      random.Reset();
    113126      random.IntNumbers = new int[] { 4 };
     
    116129      parent2 = new Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
    117130      Assert.IsTrue(parent2.Validate());
    118       expected = new Permutation(new int[] { 6, 5, 7, 0, 1, 2, 3, 4 });
     131      expected = new Permutation(new int[] { 7, 6, 5, 3, 4, 2, 1, 0 });
    119132      Assert.IsTrue(expected.Validate());
    120133      actual = CosaCrossover.Apply(random, parent1, parent2);
    121134      Assert.IsTrue(actual.Validate());
    122135      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
    123 
     136      // The following test is not based on published examples
     137      random.Reset();
     138      random.IntNumbers = new int[] { 5 };
     139      parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
     140      Assert.IsTrue(parent1.Validate());
     141      parent2 = new Permutation(new int[] { 4, 3, 5, 1, 0, 9, 7, 2, 8, 6 });
     142      Assert.IsTrue(parent2.Validate());
     143      expected = new Permutation(new int[] { 7, 6, 2, 3, 4, 5, 1, 0, 9, 8 });
     144      Assert.IsTrue(expected.Validate());
     145      actual = CosaCrossover.Apply(random, parent1, parent2);
     146      Assert.IsTrue(actual.Validate());
     147      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
     148     
    124149      // perform a test when the two permutations are of unequal length
    125150      random.Reset();
Note: See TracChangeset for help on using the changeset viewer.