Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/25/10 17:22:13 (14 years ago)
Author:
abeham
Message:

Added tests from our book for OX, PMX and CX.
Corrected a mistake in the MPX test regarding the name of one test
The tests currently fail with the new implementations.
#889

Location:
trunk/sources/HeuristicLab.Permutation/3.3/Tests
Files:
4 edited

Legend:

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

    r2854 r2867  
    122122      Assert.IsTrue(actual.Validate());
    123123      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
    124      
     124      // The following test is based on an example from Affenzeller, M. et al. 2009. Genetic Algorithms and Genetic Programming - Modern Concepts and Practical Applications. CRC Press. pp. 134.
     125      random.Reset();
     126      random.DoubleNumbers = new double[] { 0.9 };
     127      parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
     128      Assert.IsTrue(parent1.Validate());
     129      parent2 = new Permutation(new int[] { 2, 5, 6, 0, 7, 1, 3, 8, 4, 9 });
     130      Assert.IsTrue(parent2.Validate());
     131      expected = new Permutation(new int[] { 0, 5, 2, 3, 7, 1, 6, 8, 4, 9 });
     132      Assert.IsTrue(expected.Validate());
     133      actual = CyclicCrossover.Apply(random, parent1, parent2);
     134      Assert.IsTrue(actual.Validate());
     135      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
     136
    125137      // perform a test when the two permutations are of unequal length
    126138      random.Reset();
  • trunk/sources/HeuristicLab.Permutation/3.3/Tests/MaximalPreservativeCrossoverTest.cs

    r2854 r2867  
    8686    [TestMethod()]
    8787    [DeploymentItem("HeuristicLab.Permutation-3.3.dll")]
    88     public void CyclicCrossoverCrossTest() {
     88    public void MaximalPreservativeCrossoverCrossTest() {
    8989      TestRandom random = new TestRandom();
    9090      MaximalPreservativeCrossover_Accessor target =
  • trunk/sources/HeuristicLab.Permutation/3.3/Tests/OrderCrossoverTest.cs

    r2854 r2867  
    173173      Assert.IsTrue(actual.Validate());
    174174      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
     175      // The following test is based on an example from Affenzeller, M. et al. 2009. Genetic Algorithms and Genetic Programming - Modern Concepts and Practical Applications. CRC Press. p. 135.
     176      random.Reset();
     177      random.IntNumbers = new int[] { 2, 5 };
     178      parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
     179      Assert.IsTrue(parent1.Validate());
     180      parent2 = new Permutation(new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 });
     181      Assert.IsTrue(parent2.Validate());
     182      expected = new Permutation(new int[] { 2, 0, 9, 1, 3, 5, 6, 7, 8, 4 });
     183      Assert.IsTrue(expected.Validate());
     184      actual = OrderCrossover.Apply(random, parent1, parent2);
     185      Assert.IsTrue(actual.Validate());
     186      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
     187
    175188      // perform a test when the two permutations are of unequal length
    176189      random.Reset();
  • trunk/sources/HeuristicLab.Permutation/3.3/Tests/PartiallyMatchedCrossoverTest.cs

    r2854 r2867  
    122122      Assert.IsTrue(actual.Validate());
    123123      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
    124      
     124      // The following test is based on an example from Affenzeller, M. et al. 2009. Genetic Algorithms and Genetic Programming - Modern Concepts and Practical Applications. CRC Press. p. 134.
     125      random.Reset();
     126      random.IntNumbers = new int[] { 5, 7 };
     127      parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
     128      Assert.IsTrue(parent1.Validate());
     129      parent2 = new Permutation(new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 });
     130      Assert.IsTrue(parent2.Validate());
     131      expected = new Permutation(new int[] { 2, 1, 3, 0, 9, 5, 6, 7, 4, 8 });
     132      Assert.IsTrue(expected.Validate());
     133      actual = PartiallyMatchedCrossover.Apply(random, parent1, parent2);
     134      Assert.IsTrue(actual.Validate());
     135      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
     136
    125137      // perform a test when the two permutations are of unequal length
    126138      random.Reset();
Note: See TracChangeset for help on using the changeset viewer.