Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/29/10 17:53:12 (15 years ago)
Author:
abeham
Message:

Added a permutation type property specifying whether it's a relative (directed or undirected) or absolute permutation #889

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Tests/OrderCrossoverTest.cs

    r3063 r3231  
    9393      try {
    9494        target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    95           new Permutation(4), new Permutation(4), new Permutation(4)}));
     95          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
    9696      } catch (System.InvalidOperationException) {
    9797        exceptionFired = true;
     
    110110      random.Reset();
    111111      random.IntNumbers = new int[] { 3, 6 };
    112       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
     112      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    113113      Assert.IsTrue(parent1.Validate());
    114       parent2 = new Permutation(new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 });
     114      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 });
    115115      Assert.IsTrue(parent2.Validate());
    116       expected = new Permutation(new int[] { 2, 7, 1, 3, 4, 5, 6, 0, 8 });
     116      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 7, 1, 3, 4, 5, 6, 0, 8 });
    117117      Assert.IsTrue(expected.Validate());
    118118      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    122122      random.Reset();
    123123      random.IntNumbers = new int[] { 2, 4 };
    124       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     124      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    125125      Assert.IsTrue(parent1.Validate());
    126       parent2 = new Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
     126      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
    127127      Assert.IsTrue(parent2.Validate());
    128       expected = new Permutation(new int[] { 7, 6, 2, 3, 4, 0, 1, 5 });
     128      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 7, 6, 2, 3, 4, 0, 1, 5 });
    129129      actual = OrderCrossover.Apply(random, parent1, parent2);
    130130      Assert.IsTrue(actual.Validate());
     
    133133      random.Reset();
    134134      random.IntNumbers = new int[] { 2, 5 };
    135       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
     135      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    136136      Assert.IsTrue(parent1.Validate());
    137       parent2 = new Permutation(new int[] { 7, 3, 0, 4, 8, 2, 5, 1, 6 });
     137      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 7, 3, 0, 4, 8, 2, 5, 1, 6 });
    138138      Assert.IsTrue(parent2.Validate());
    139       expected = new Permutation(new int[] { 0, 8, 2, 3, 4, 5, 1, 6, 7 });
     139      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 8, 2, 3, 4, 5, 1, 6, 7 });
    140140      Assert.IsTrue(expected.Validate());
    141141      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    145145      random.Reset();
    146146      random.IntNumbers = new int[] { 0, 5 };
    147       parent1 = new Permutation(new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });
     147      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });
    148148      Assert.IsTrue(parent1.Validate());
    149       parent2 = new Permutation(new int[] { 5, 3, 4, 0, 9, 8, 2, 7, 1, 6 });
     149      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 5, 3, 4, 0, 9, 8, 2, 7, 1, 6 });
    150150      Assert.IsTrue(parent2.Validate());
    151       expected = new Permutation(new int[] { 2, 1, 4, 3, 7, 8, 6, 5, 0, 9 });
     151      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 1, 4, 3, 7, 8, 6, 5, 0, 9 });
    152152      Assert.IsTrue(expected.Validate());
    153153      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    157157      random.Reset();
    158158      random.IntNumbers = new int[] { 6, 9 };
    159       expected = new Permutation(new int[] { 3, 4, 8, 2, 7, 1, 6, 0, 5, 9 });
     159      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 3, 4, 8, 2, 7, 1, 6, 0, 5, 9 });
    160160      Assert.IsTrue(expected.Validate());
    161161      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    165165      random.Reset();
    166166      random.IntNumbers = new int[] { 0, 9 };
    167       expected = new Permutation(new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });
     167      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });
    168168      Assert.IsTrue(expected.Validate());
    169169      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    175175      bool exceptionFired = false;
    176176      try {
    177         OrderCrossover.Apply(random, new Permutation(8), new Permutation(6));
     177        OrderCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6));
    178178      } catch (System.ArgumentException) {
    179179        exceptionFired = true;
Note: See TracChangeset for help on using the changeset viewer.