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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.