Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2930


Ignore:
Timestamp:
03/04/10 15:15:44 (15 years ago)
Author:
abeham
Message:

fixed permutation tests due to namespace change #95
removed constructor tests as well

Location:
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests
Files:
1 added
1 deleted
19 edited

Legend:

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

    r2929 r2930  
    2020#endregion
    2121
     22using HeuristicLab.Encodings.Permutation;
     23
    2224namespace HeuristicLab.Encodings.Permutation_33.Tests {
    2325  public static class Auxiliary {
    24     public static bool PermutationIsEqualByPosition(Permutation p1, Permutation p2) {
     26    public static bool PermutationIsEqualByPosition(Permutation.Permutation p1, Permutation.Permutation p2) {
    2527      bool equal = (p1.Length == p2.Length);
    2628      if (equal) {
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/CosaCrossoverTest.cs

    r2929 r2930  
    2222using HeuristicLab.Core;
    2323using Microsoft.VisualStudio.TestTools.UnitTesting;
     24using HeuristicLab.Encodings.Permutation;
    2425
    2526namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    9192      bool exceptionFired = false;
    9293      try {
    93         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    94           new Permutation(4), new Permutation(4), new Permutation(4)}));
     94        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     95          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4)}));
    9596      } catch (System.InvalidOperationException) {
    9697        exceptionFired = true;
     
    105106    public void CosaCrossoverApplyTest() {
    106107      TestRandom random = new TestRandom();
    107       Permutation parent1, parent2, expected, actual;
     108      Permutation.Permutation parent1, parent2, expected, actual;
    108109      // 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.
    109110      random.Reset();
    110111      random.IntNumbers = new int[] { 1 };
    111       parent1 = new Permutation(new int[] { 0, 1, 5, 2, 4, 3 });
     112      parent1 = new Permutation.Permutation(new int[] { 0, 1, 5, 2, 4, 3 });
    112113      Assert.IsTrue(parent1.Validate());
    113       parent2 = new Permutation(new int[] { 3, 0, 2, 1, 4, 5 });
     114      parent2 = new Permutation.Permutation(new int[] { 3, 0, 2, 1, 4, 5 });
    114115      Assert.IsTrue(parent2.Validate());
    115       expected = new Permutation(new int[] { 0, 1, 4, 2, 5, 3 });
     116      expected = new Permutation.Permutation(new int[] { 0, 1, 4, 2, 5, 3 });
    116117      Assert.IsTrue(expected.Validate());
    117118      actual = CosaCrossover.Apply(random, parent1, parent2);
     
    121122      random.Reset();
    122123      random.IntNumbers = new int[] { 4 };
    123       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     124      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    124125      Assert.IsTrue(parent1.Validate());
    125       parent2 = new Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
     126      parent2 = new Permutation.Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
    126127      Assert.IsTrue(parent2.Validate());
    127       expected = new Permutation(new int[] { 7, 6, 5, 3, 4, 2, 1, 0 });
     128      expected = new Permutation.Permutation(new int[] { 7, 6, 5, 3, 4, 2, 1, 0 });
    128129      Assert.IsTrue(expected.Validate());
    129130      actual = CosaCrossover.Apply(random, parent1, parent2);
     
    133134      random.Reset();
    134135      random.IntNumbers = new int[] { 5 };
    135       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
     136      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    136137      Assert.IsTrue(parent1.Validate());
    137       parent2 = new Permutation(new int[] { 4, 3, 5, 1, 0, 9, 7, 2, 8, 6 });
     138      parent2 = new Permutation.Permutation(new int[] { 4, 3, 5, 1, 0, 9, 7, 2, 8, 6 });
    138139      Assert.IsTrue(parent2.Validate());
    139       expected = new Permutation(new int[] { 7, 6, 2, 3, 4, 5, 1, 0, 9, 8 });
     140      expected = new Permutation.Permutation(new int[] { 7, 6, 2, 3, 4, 5, 1, 0, 9, 8 });
    140141      Assert.IsTrue(expected.Validate());
    141142      actual = CosaCrossover.Apply(random, parent1, parent2);
     
    147148      bool exceptionFired = false;
    148149      try {
    149         CosaCrossover.Apply(random, new Permutation(8), new Permutation(6));
     150        CosaCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
    150151      } catch (System.ArgumentException) {
    151152        exceptionFired = true;
     
    153154      Assert.IsTrue(exceptionFired);
    154155    }
    155 
    156     /// <summary>
    157     ///A test for CosaCrossover Constructor
    158     ///</summary>
    159     [TestMethod()]
    160     public void CosaCrossoverConstructorTest() {
    161       CosaCrossover target = new CosaCrossover();
    162     }
    163156  }
    164157}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/CyclicCrossover2Test.cs

    r2929 r2930  
    11using HeuristicLab.Core;
    22using Microsoft.VisualStudio.TestTools.UnitTesting;
     3using HeuristicLab.Encodings.Permutation;
    34
    45namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    6970      bool exceptionFired = false;
    7071      try {
    71         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    72           new Permutation(4), new Permutation(4), new Permutation(4)}));
     72        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     73          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4)}));
    7374      } catch (System.InvalidOperationException) {
    7475        exceptionFired = true;
     
    8384    public void CyclicCrossover2ApplyTest() {
    8485      TestRandom random = new TestRandom();
    85       Permutation parent1, parent2, expected, actual;
     86      Permutation.Permutation parent1, parent2, expected, actual;
    8687      // 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.
    8788      random.Reset();
    8889      random.IntNumbers = new int[] { 0 };
    89       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
     90      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    9091      Assert.IsTrue(parent1.Validate());
    91       parent2 = new Permutation(new int[] { 2, 5, 6, 0, 7, 1, 3, 8, 4, 9 });
     92      parent2 = new Permutation.Permutation(new int[] { 2, 5, 6, 0, 7, 1, 3, 8, 4, 9 });
    9293      Assert.IsTrue(parent2.Validate());
    93       expected = new Permutation(new int[] { 0, 5, 2, 3, 7, 1, 6, 8, 4, 9 });
     94      expected = new Permutation.Permutation(new int[] { 0, 5, 2, 3, 7, 1, 6, 8, 4, 9 });
    9495      Assert.IsTrue(expected.Validate());
    9596      actual = CyclicCrossover2.Apply(random, parent1, parent2);
     
    101102      bool exceptionFired = false;
    102103      try {
    103         CyclicCrossover.Apply(random, new Permutation(8), new Permutation(6));
     104        CyclicCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
    104105      } catch (System.ArgumentException) {
    105106        exceptionFired = true;
     
    107108      Assert.IsTrue(exceptionFired);
    108109    }
    109 
    110     /// <summary>
    111     ///A test for CyclicCrossover2 Constructor
    112     ///</summary>
    113     [TestMethod()]
    114     public void CyclicCrossover2ConstructorTest() {
    115       CyclicCrossover2 target = new CyclicCrossover2();
    116     }
    117110  }
    118111}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/CyclicCrossoverTest.cs

    r2929 r2930  
    2222using HeuristicLab.Core;
    2323using Microsoft.VisualStudio.TestTools.UnitTesting;
     24using HeuristicLab.Encodings.Permutation;
    2425
    2526namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    9192      bool exceptionFired = false;
    9293      try {
    93         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    94           new Permutation(4), new Permutation(4), new Permutation(4)}));
     94        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     95          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4)}));
    9596      }
    9697      catch (System.InvalidOperationException) {
     
    106107    public void CyclicCrossoverApplyTest() {
    107108      TestRandom random = new TestRandom();
    108       Permutation parent1, parent2, expected, actual;
     109      Permutation.Permutation parent1, parent2, expected, actual;
    109110      // The following test is based on an example from Larranaga, P. et al. 1999. Genetic Algorithms for the Travelling Salesman Problem: A Review of Representations and Operators. Artificial Intelligence Review, 13
    110111      random.Reset();
    111112      random.DoubleNumbers = new double[] { 0.9 };
    112       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     113      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    113114      Assert.IsTrue(parent1.Validate());
    114       parent2 = new Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
     115      parent2 = new Permutation.Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
    115116      Assert.IsTrue(parent2.Validate());
    116       expected = new Permutation(new int[] { 0, 1, 5, 3, 6, 4, 2, 7 });
     117      expected = new Permutation.Permutation(new int[] { 0, 1, 5, 3, 6, 4, 2, 7 });
    117118      Assert.IsTrue(expected.Validate());
    118119      actual = CyclicCrossover.Apply(random, parent1, parent2);
     
    124125      bool exceptionFired = false;
    125126      try {
    126         CyclicCrossover.Apply(random, new Permutation(8), new Permutation(6));
     127        CyclicCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
    127128      }
    128129      catch (System.ArgumentException) {
     
    131132      Assert.IsTrue(exceptionFired);
    132133    }
    133 
    134     /// <summary>
    135     ///A test for OrderCrossover Constructor
    136     ///</summary>
    137     [TestMethod()]
    138     public void CyclicCrossoverConstructorTest() {
    139       CyclicCrossover target = new CyclicCrossover();
    140     }
    141134  }
    142135}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/EdgeRecombinationCrossoverTest.cs

    r2929 r2930  
    2222using HeuristicLab.Core;
    2323using Microsoft.VisualStudio.TestTools.UnitTesting;
     24using HeuristicLab.Encodings.Permutation;
    2425
    2526namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    9192      bool exceptionFired = false;
    9293      try {
    93         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    94           new Permutation(4), new Permutation(4), new Permutation(4)}));
     94        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     95          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4)}));
    9596      }
    9697      catch (System.InvalidOperationException) {
     
    106107    public void EdgeRecombinationCrossoverApplyTest() {
    107108      TestRandom random = new TestRandom();
    108       Permutation parent1, parent2, expected, actual;
     109      Permutation.Permutation parent1, parent2, expected, actual;
    109110      // The following test is based on an example from Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg, pp. 54-55
    110111      random.Reset();
    111112      random.IntNumbers = new int[] { 0 };
    112113      random.DoubleNumbers = new double[] { 0.5, 0, 0, 0 };
    113       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
     114      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    114115      Assert.IsTrue(parent1.Validate());
    115       parent2 = new Permutation(new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 });
     116      parent2 = new Permutation.Permutation(new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 });
    116117      Assert.IsTrue(parent2.Validate());
    117       expected = new Permutation(new int[] { 0, 4, 5, 1, 7, 6, 2, 8, 3 });
     118      expected = new Permutation.Permutation(new int[] { 0, 4, 5, 1, 7, 6, 2, 8, 3 });
    118119      Assert.IsTrue(expected.Validate());
    119120      actual = EdgeRecombinationCrossover.Apply(random, parent1, parent2);
     
    125126      bool exceptionFired = false;
    126127      try {
    127         EdgeRecombinationCrossover.Apply(random, new Permutation(8), new Permutation(6));
     128        EdgeRecombinationCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
    128129      }
    129130      catch (System.ArgumentException) {
     
    132133      Assert.IsTrue(exceptionFired);
    133134    }
    134 
    135     /// <summary>
    136     ///A test for EdgeRecombinationCrossover Constructor
    137     ///</summary>
    138     [TestMethod()]
    139     public void EdgeRecombinationCrossoverConstructorTest() {
    140       EdgeRecombinationCrossover target = new EdgeRecombinationCrossover();
    141     }
    142135  }
    143136}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/HeuristicLab.Encodings.Permutation-3.3.Tests.csproj

    r2929 r2930  
    141141  </ItemGroup>
    142142  <ItemGroup>
    143     <Shadow Include="Test References\HeuristicLab.Permutation-3.3.accessor" />
     143    <Shadow Include="Test References\HeuristicLab.Encodings.Permutation-3.3.accessor" />
    144144  </ItemGroup>
    145145  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/InsertionManipulatorTest.cs

    r2929 r2930  
    2121
    2222using Microsoft.VisualStudio.TestTools.UnitTesting;
     23using HeuristicLab.Encodings.Permutation;
    2324
    2425namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    8384    public void InsertionManipulatorApplyTest() {
    8485      TestRandom random = new TestRandom();
    85       Permutation parent, expected;
     86      Permutation.Permutation parent, expected;
    8687      // The following test is based on an example from Larranaga, P. et al. 1999. Genetic Algorithms for the Travelling Salesman Problem: A Review of Representations and Operators. Artificial Intelligence Review, 13
    8788      random.Reset();
    8889      random.IntNumbers = new int[] { 3, 6 };
    89       parent = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     90      parent = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    9091      Assert.IsTrue(parent.Validate());
    9192     
    92       expected = new Permutation(new int[] { 0, 1, 2, 4, 5, 6, 3, 7 });
     93      expected = new Permutation.Permutation(new int[] { 0, 1, 2, 4, 5, 6, 3, 7 });
    9394      Assert.IsTrue(expected.Validate());
    9495      InsertionManipulator.Apply(random, parent);
    9596      Assert.IsTrue(parent.Validate());
    9697      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    97      
    98       // perform a test when the two permutations are of unequal length
    99       random.Reset();
    100       bool exceptionFired = false;
    101       try {
    102         CyclicCrossover.Apply(random, new Permutation(8), new Permutation(6));
    103       }
    104       catch (System.ArgumentException) {
    105         exceptionFired = true;
    106       }
    107       Assert.IsTrue(exceptionFired);
    108     }
    109 
    110     /// <summary>
    111     ///A test for InsertionManipulator Constructor
    112     ///</summary>
    113     [TestMethod()]
    114     public void InsertionManipulatorConstructorTest() {
    115       InsertionManipulator target = new InsertionManipulator();
    11698    }
    11799  }
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/InversionManipulatorTest.cs

    r2929 r2930  
    2121
    2222using Microsoft.VisualStudio.TestTools.UnitTesting;
     23using HeuristicLab.Encodings.Permutation;
    2324
    2425namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    8384    public void InversionManipulatorApplyTest() {
    8485      TestRandom random = new TestRandom();
    85       Permutation parent, expected;
     86      Permutation.Permutation parent, expected;
    8687      // The following test is based on an example from Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg, pp. 46-47
    8788      random.Reset();
    8889      random.IntNumbers = new int[] { 1, 4 };
    89       parent = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
     90      parent = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    9091      Assert.IsTrue(parent.Validate());
    9192     
    92       expected = new Permutation(new int[] { 0, 4, 3, 2, 1, 5, 6, 7, 8 });
     93      expected = new Permutation.Permutation(new int[] { 0, 4, 3, 2, 1, 5, 6, 7, 8 });
    9394      Assert.IsTrue(expected.Validate());
    9495      InversionManipulator.Apply(random, parent);
    9596      Assert.IsTrue(parent.Validate());
    9697      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    97      
    98       // perform a test when the two permutations are of unequal length
    99       random.Reset();
    100       bool exceptionFired = false;
    101       try {
    102         CyclicCrossover.Apply(random, new Permutation(8), new Permutation(6));
    103       }
    104       catch (System.ArgumentException) {
    105         exceptionFired = true;
    106       }
    107       Assert.IsTrue(exceptionFired);
    108     }
    109 
    110     /// <summary>
    111     ///A test for InversionManipulator Constructor
    112     ///</summary>
    113     [TestMethod()]
    114     public void InversionManipulatorConstructorTest() {
    115       InversionManipulator target = new InversionManipulator();
    11698    }
    11799  }
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/MaximalPreservativeCrossoverTest.cs

    r2929 r2930  
    2222using HeuristicLab.Core;
    2323using Microsoft.VisualStudio.TestTools.UnitTesting;
     24using HeuristicLab.Encodings.Permutation;
    2425
    2526namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    9192      bool exceptionFired = false;
    9293      try {
    93         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    94           new Permutation(4), new Permutation(4), new Permutation(4)}));
     94        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     95          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4)}));
    9596      }
    9697      catch (System.InvalidOperationException) {
     
    106107    public void MaximalPreservativeCrossoverApplyTest() {
    107108      TestRandom random = new TestRandom();
    108       Permutation parent1, parent2, expected, actual;
     109      Permutation.Permutation parent1, parent2, expected, actual;
    109110      // The following test is based on an example from Larranaga, 1999. Genetic Algorithms for the Traveling Salesman Problem.
    110111      random.Reset();
    111112      random.IntNumbers = new int[] { 3, 2 };
    112       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     113      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    113114      Assert.IsTrue(parent1.Validate());
    114       parent2 = new Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
     115      parent2 = new Permutation.Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
    115116      Assert.IsTrue(parent2.Validate());
    116       expected = new Permutation(new int[] { 1, 0, 2, 3, 4, 5, 7, 6 });
     117      expected = new Permutation.Permutation(new int[] { 1, 0, 2, 3, 4, 5, 7, 6 });
    117118      Assert.IsTrue(expected.Validate());
    118119      actual = MaximalPreservativeCrossover.Apply(random, parent1, parent2);
     
    124125      bool exceptionFired = false;
    125126      try {
    126         MaximalPreservativeCrossover.Apply(random, new Permutation(8), new Permutation(6));
     127        MaximalPreservativeCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
    127128      }
    128129      catch (System.ArgumentException) {
     
    131132      Assert.IsTrue(exceptionFired);
    132133    }
    133 
    134     /// <summary>
    135     ///A test for OrderCrossover Constructor
    136     ///</summary>
    137     [TestMethod()]
    138     public void MaximalPreservativeCrossoverConstructorTest() {
    139       MaximalPreservativeCrossover target = new MaximalPreservativeCrossover();
    140     }
    141134  }
    142135}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/OrderBasedCrossoverTest.cs

    r2929 r2930  
    2222using HeuristicLab.Core;
    2323using Microsoft.VisualStudio.TestTools.UnitTesting;
     24using HeuristicLab.Encodings.Permutation;
    2425
    2526namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    9192      bool exceptionFired = false;
    9293      try {
    93         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    94           new Permutation(4), new Permutation(4), new Permutation(4)}));
     94        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     95          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4)}));
    9596      } catch (System.InvalidOperationException) {
    9697        exceptionFired = true;
     
    105106    public void OrderBasedCrossoverApplyTest() {
    106107      TestRandom random = new TestRandom();
    107       Permutation parent1, parent2, expected, actual;
     108      Permutation.Permutation parent1, parent2, expected, actual;
    108109      // The following test is based on an example from Larranaga, P. et al. 1999. Genetic Algorithms for the Travelling Salesman Problem: A Review of Representations and Operators. Artificial Intelligence Review, 13
    109110      random.Reset();
    110111      random.IntNumbers = new int[] { 3, 5, 2, 1 };
    111       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     112      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    112113      Assert.IsTrue(parent1.Validate());
    113       parent2 = new Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
     114      parent2 = new Permutation.Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
    114115      Assert.IsTrue(parent2.Validate());
    115       expected = new Permutation(new int[] { 1, 3, 2, 7, 6, 4, 5, 0 });
     116      expected = new Permutation.Permutation(new int[] { 1, 3, 2, 7, 6, 4, 5, 0 });
    116117      actual = OrderBasedCrossover.Apply(random, parent1, parent2);
    117118      Assert.IsTrue(actual.Validate());
     
    121122      bool exceptionFired = false;
    122123      try {
    123         OrderBasedCrossover.Apply(random, new Permutation(8), new Permutation(6));
     124        OrderBasedCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
    124125      } catch (System.ArgumentException) {
    125126        exceptionFired = true;
     
    127128      Assert.IsTrue(exceptionFired);
    128129    }
    129 
    130     /// <summary>
    131     ///A test for OrderBasedCrossover Constructor
    132     ///</summary>
    133     [TestMethod()]
    134     public void OrderBasedCrossoverConstructorTest() {
    135       OrderBasedCrossover target = new OrderBasedCrossover();
    136     }
    137130  }
    138131}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/OrderCrossover2Test.cs

    r2929 r2930  
    11using HeuristicLab.Core;
    22using Microsoft.VisualStudio.TestTools.UnitTesting;
     3using HeuristicLab.Encodings.Permutation;
    34
    45namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    6869      bool exceptionFired = false;
    6970      try {
    70         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    71           new Permutation(4), new Permutation(4), new Permutation(4)}));
     71        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     72          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4)}));
    7273      } catch (System.InvalidOperationException) {
    7374        exceptionFired = true;
     
    8283    public void OrderCrossover2ApplyTest() {
    8384      TestRandom random = new TestRandom();
    84       Permutation parent1, parent2, expected, actual;
     85      Permutation.Permutation parent1, parent2, expected, actual;
    8586      // 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.
    8687      random.Reset();
    8788      random.IntNumbers = new int[] { 5, 7 };
    88       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
     89      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    8990      Assert.IsTrue(parent1.Validate());
    90       parent2 = new Permutation(new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 });
     91      parent2 = new Permutation.Permutation(new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 });
    9192      Assert.IsTrue(parent2.Validate());
    92       expected = new Permutation(new int[] { 2, 0, 9, 1, 3, 5, 6, 7, 8, 4 });
     93      expected = new Permutation.Permutation(new int[] { 2, 0, 9, 1, 3, 5, 6, 7, 8, 4 });
    9394      Assert.IsTrue(expected.Validate());
    9495      actual = OrderCrossover2.Apply(random, parent1, parent2);
     
    100101      bool exceptionFired = false;
    101102      try {
    102         OrderCrossover.Apply(random, new Permutation(8), new Permutation(6));
     103        OrderCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
    103104      } catch (System.ArgumentException) {
    104105        exceptionFired = true;
     
    106107      Assert.IsTrue(exceptionFired);
    107108    }
    108 
    109     /// <summary>
    110     ///A test for OrderCrossover2 Constructor
    111     ///</summary>
    112     [TestMethod()]
    113     public void OrderCrossover2ConstructorTest() {
    114       OrderCrossover2 target = new OrderCrossover2();
    115     }
    116109  }
    117110}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/OrderCrossoverTest.cs

    r2929 r2930  
    2222using HeuristicLab.Core;
    2323using Microsoft.VisualStudio.TestTools.UnitTesting;
     24using HeuristicLab.Encodings.Permutation;
    2425
    2526namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    9192      bool exceptionFired = false;
    9293      try {
    93         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    94           new Permutation(4), new Permutation(4), new Permutation(4)}));
     94        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     95          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4)}));
    9596      } catch (System.InvalidOperationException) {
    9697        exceptionFired = true;
     
    105106    public void OrderCrossoverApplyTest() {
    106107      TestRandom random = new TestRandom();
    107       Permutation parent1, parent2, expected, actual;
     108      Permutation.Permutation parent1, parent2, expected, actual;
    108109      // The following test is based on an example from Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg, pp. 55-56
    109110      random.Reset();
    110111      random.IntNumbers = new int[] { 3, 6 };
    111       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
     112      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    112113      Assert.IsTrue(parent1.Validate());
    113       parent2 = new Permutation(new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 });
     114      parent2 = new Permutation.Permutation(new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 });
    114115      Assert.IsTrue(parent2.Validate());
    115       expected = new Permutation(new int[] { 2, 7, 1, 3, 4, 5, 6, 0, 8 });
     116      expected = new Permutation.Permutation(new int[] { 2, 7, 1, 3, 4, 5, 6, 0, 8 });
    116117      Assert.IsTrue(expected.Validate());
    117118      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    121122      random.Reset();
    122123      random.IntNumbers = new int[] { 2, 4 };
    123       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     124      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    124125      Assert.IsTrue(parent1.Validate());
    125       parent2 = new Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
     126      parent2 = new Permutation.Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
    126127      Assert.IsTrue(parent2.Validate());
    127       expected = new Permutation(new int[] { 7, 6, 2, 3, 4, 0, 1, 5 });
     128      expected = new Permutation.Permutation(new int[] { 7, 6, 2, 3, 4, 0, 1, 5 });
    128129      actual = OrderCrossover.Apply(random, parent1, parent2);
    129130      Assert.IsTrue(actual.Validate());
     
    132133      random.Reset();
    133134      random.IntNumbers = new int[] { 2, 5 };
    134       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
     135      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    135136      Assert.IsTrue(parent1.Validate());
    136       parent2 = new Permutation(new int[] { 7, 3, 0, 4, 8, 2, 5, 1, 6 });
     137      parent2 = new Permutation.Permutation(new int[] { 7, 3, 0, 4, 8, 2, 5, 1, 6 });
    137138      Assert.IsTrue(parent2.Validate());
    138       expected = new Permutation(new int[] { 0, 8, 2, 3, 4, 5, 1, 6, 7 });
     139      expected = new Permutation.Permutation(new int[] { 0, 8, 2, 3, 4, 5, 1, 6, 7 });
    139140      Assert.IsTrue(expected.Validate());
    140141      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    144145      random.Reset();
    145146      random.IntNumbers = new int[] { 0, 5 };
    146       parent1 = new Permutation(new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });
     147      parent1 = new Permutation.Permutation(new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });
    147148      Assert.IsTrue(parent1.Validate());
    148       parent2 = new Permutation(new int[] { 5, 3, 4, 0, 9, 8, 2, 7, 1, 6 });
     149      parent2 = new Permutation.Permutation(new int[] { 5, 3, 4, 0, 9, 8, 2, 7, 1, 6 });
    149150      Assert.IsTrue(parent2.Validate());
    150       expected = new Permutation(new int[] { 2, 1, 4, 3, 7, 8, 6, 5, 0, 9 });
     151      expected = new Permutation.Permutation(new int[] { 2, 1, 4, 3, 7, 8, 6, 5, 0, 9 });
    151152      Assert.IsTrue(expected.Validate());
    152153      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    156157      random.Reset();
    157158      random.IntNumbers = new int[] { 6, 9 };
    158       expected = new Permutation(new int[] { 3, 4, 8, 2, 7, 1, 6, 0, 5, 9 });
     159      expected = new Permutation.Permutation(new int[] { 3, 4, 8, 2, 7, 1, 6, 0, 5, 9 });
    159160      Assert.IsTrue(expected.Validate());
    160161      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    164165      random.Reset();
    165166      random.IntNumbers = new int[] { 0, 9 };
    166       expected = new Permutation(new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });
     167      expected = new Permutation.Permutation(new int[] { 2, 1, 4, 3, 7, 8, 6, 0, 5, 9 });
    167168      Assert.IsTrue(expected.Validate());
    168169      actual = OrderCrossover.Apply(random, parent1, parent2);
     
    174175      bool exceptionFired = false;
    175176      try {
    176         OrderCrossover.Apply(random, new Permutation(8), new Permutation(6));
     177        OrderCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
    177178      } catch (System.ArgumentException) {
    178179        exceptionFired = true;
     
    180181      Assert.IsTrue(exceptionFired);
    181182    }
    182 
    183     /// <summary>
    184     ///A test for OrderCrossover Constructor
    185     ///</summary>
    186     [TestMethod()]
    187     public void OrderCrossoverConstructorTest() {
    188       OrderCrossover target = new OrderCrossover();
    189     }
    190183  }
    191184}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/PartiallyMatchedCrossoverTest.cs

    r2929 r2930  
    2222using HeuristicLab.Core;
    2323using Microsoft.VisualStudio.TestTools.UnitTesting;
     24using HeuristicLab.Encodings.Permutation;
    2425
    2526namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    9192      bool exceptionFired = false;
    9293      try {
    93         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    94           new Permutation(4), new Permutation(4), new Permutation(4)}));
     94        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     95          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4)}));
    9596      }
    9697      catch (System.InvalidOperationException) {
     
    106107    public void PartiallyMatchedCrossoverApplyTest() {
    107108      TestRandom random = new TestRandom();
    108       Permutation parent1, parent2, expected, actual;
     109      Permutation.Permutation parent1, parent2, expected, actual;
    109110      // The following test is based on an example from Larranaga, 1999. Genetic Algorithms for the Traveling Salesman Problem.
    110111      random.Reset();
    111112      random.IntNumbers = new int[] { 3, 5 };
    112       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     113      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    113114      Assert.IsTrue(parent1.Validate());
    114       parent2 = new Permutation(new int[] { 2, 6, 4, 0, 5, 7, 1, 3 });
     115      parent2 = new Permutation.Permutation(new int[] { 2, 6, 4, 0, 5, 7, 1, 3 });
    115116      Assert.IsTrue(parent2.Validate());
    116       expected = new Permutation(new int[] { 2, 6, 7, 3, 4, 5, 1, 0 });
     117      expected = new Permutation.Permutation(new int[] { 2, 6, 7, 3, 4, 5, 1, 0 });
    117118      Assert.IsTrue(expected.Validate());
    118119      actual = PartiallyMatchedCrossover.Apply(random, parent1, parent2);
     
    122123      random.Reset();
    123124      random.IntNumbers = new int[] { 5, 7 };
    124       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
     125      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
    125126      Assert.IsTrue(parent1.Validate());
    126       parent2 = new Permutation(new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 });
     127      parent2 = new Permutation.Permutation(new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 });
    127128      Assert.IsTrue(parent2.Validate());
    128       expected = new Permutation(new int[] { 2, 1, 3, 0, 9, 5, 6, 7, 4, 8 });
     129      expected = new Permutation.Permutation(new int[] { 2, 1, 3, 0, 9, 5, 6, 7, 4, 8 });
    129130      Assert.IsTrue(expected.Validate());
    130131      actual = PartiallyMatchedCrossover.Apply(random, parent1, parent2);
     
    136137      bool exceptionFired = false;
    137138      try {
    138         PartiallyMatchedCrossover.Apply(random, new Permutation(8), new Permutation(6));
     139        PartiallyMatchedCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
    139140      }
    140141      catch (System.ArgumentException) {
     
    143144      Assert.IsTrue(exceptionFired);
    144145    }
    145 
    146     /// <summary>
    147     ///A test for PartiallyMatchedCrossover Constructor
    148     ///</summary>
    149     [TestMethod()]
    150     public void PartiallyMatchedCrossoverConstructorTest() {
    151       PartiallyMatchedCrossover target = new PartiallyMatchedCrossover();
    152     }
    153146  }
    154147}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/PositionBasedCrossoverTest.cs

    r2929 r2930  
    2222using HeuristicLab.Core;
    2323using Microsoft.VisualStudio.TestTools.UnitTesting;
     24using HeuristicLab.Encodings.Permutation;
    2425
    2526namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    9293      bool exceptionFired = false;
    9394      try {
    94         target.Cross(random, new ItemArray<Permutation>(new Permutation[] {
    95           new Permutation(4), new Permutation(4), new Permutation(4) }));
     95        target.Cross(random, new ItemArray<Permutation.Permutation>(new Permutation.Permutation[] {
     96          new Permutation.Permutation(4), new Permutation.Permutation(4), new Permutation.Permutation(4) }));
    9697      }
    9798      catch (System.InvalidOperationException) {
     
    108109    public void PositionBasedCrossoverApplyTest() {
    109110      TestRandom random = new TestRandom();
    110       Permutation parent1, parent2, expected, actual;
     111      Permutation.Permutation parent1, parent2, expected, actual;
    111112
    112113      // The following test is based on an example from Larranaga, 1999. Genetic Algorithms for the Traveling Salesman Problem.
    113114      random.Reset();
    114115      random.IntNumbers = new int[] { 3, 1, 2, 5 };
    115       parent1 = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     116      parent1 = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    116117      Assert.IsTrue(parent1.Validate());
    117       parent2 = new Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
     118      parent2 = new Permutation.Permutation(new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
    118119      Assert.IsTrue(parent2.Validate());
    119120
    120       expected = new Permutation(new int[] { 0, 3, 5, 1, 2, 4, 6, 7 });
     121      expected = new Permutation.Permutation(new int[] { 0, 3, 5, 1, 2, 4, 6, 7 });
    121122      Assert.IsTrue(expected.Validate());
    122123      actual = PositionBasedCrossover.Apply(random, parent1, parent2);
     
    128129      bool exceptionFired = false;
    129130      try {
    130         PositionBasedCrossover.Apply(random, new Permutation(8), new Permutation(6));
    131       }
    132       catch (System.ArgumentException) {
     131        PositionBasedCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6));
     132      } catch (System.ArgumentException) {
    133133        exceptionFired = true;
    134134      }
    135135      Assert.IsTrue(exceptionFired);
    136136    }
    137 
    138     /// <summary>
    139     ///A test for PositionBasedCrossover Constructor
    140     ///</summary>
    141     [TestMethod()]
    142     public void PositionBasedCrossoverConstructorTest() {
    143       PositionBasedCrossover target = new PositionBasedCrossover();
    144     }
    145137  }
    146138}
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/ScrambleManipulatorTest.cs

    r2929 r2930  
    2121
    2222using Microsoft.VisualStudio.TestTools.UnitTesting;
     23using HeuristicLab.Encodings.Permutation;
    2324
    2425namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    8384    public void ScrambleManipulatorApplyTest() {
    8485      TestRandom random = new TestRandom();
    85       Permutation parent, expected;
     86      Permutation.Permutation parent, expected;
    8687      // The following test is based on an example from Larranaga, P. et al. 1999. Genetic Algorithms for the Travelling Salesman Problem: A Review of Representations and Operators. Artificial Intelligence Review, 13
    8788      random.Reset();
    8889      random.IntNumbers = new int[] { 3, 6, 1, 1, 1, 0 };
    89       parent = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     90      parent = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    9091      Assert.IsTrue(parent.Validate());
    9192     
    92       expected = new Permutation(new int[] { 0, 1, 2, 4, 5, 6, 3, 7 });
     93      expected = new Permutation.Permutation(new int[] { 0, 1, 2, 4, 5, 6, 3, 7 });
    9394      Assert.IsTrue(expected.Validate());
    9495      ScrambleManipulator.Apply(random, parent);
    9596      Assert.IsTrue(parent.Validate());
    9697      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    97      
    98       // perform a test when the two permutations are of unequal length
    99       random.Reset();
    100       bool exceptionFired = false;
    101       try {
    102         CyclicCrossover.Apply(random, new Permutation(8), new Permutation(6));
    103       }
    104       catch (System.ArgumentException) {
    105         exceptionFired = true;
    106       }
    107       Assert.IsTrue(exceptionFired);
    108     }
    109 
    110     /// <summary>
    111     ///A test for ScrambleManipulator Constructor
    112     ///</summary>
    113     [TestMethod()]
    114     public void ScrambleManipulatorConstructorTest() {
    115       ScrambleManipulator target = new ScrambleManipulator();
    11698    }
    11799  }
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/Swap2ManipulatorTest.cs

    r2929 r2930  
    2121
    2222using Microsoft.VisualStudio.TestTools.UnitTesting;
     23using HeuristicLab.Encodings.Permutation;
    2324
    2425namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    8384    public void Swap2ManipulatorApplyTest() {
    8485      TestRandom random = new TestRandom();
    85       Permutation parent, expected;
     86      Permutation.Permutation parent, expected;
    8687      // The following test is based on an example from Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg, p. 45
    8788      random.Reset();
    8889      random.IntNumbers = new int[] { 1, 4 };
    89       parent = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
     90      parent = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    9091      Assert.IsTrue(parent.Validate());
    9192
    92       expected = new Permutation(new int[] { 0, 4, 2, 3, 1, 5, 6, 7, 8 });
     93      expected = new Permutation.Permutation(new int[] { 0, 4, 2, 3, 1, 5, 6, 7, 8 });
    9394      Assert.IsTrue(expected.Validate());
    9495      Swap2Manipulator.Apply(random, parent);
    9596      Assert.IsTrue(parent.Validate());
    9697      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    97      
    98       // perform a test when the two permutations are of unequal length
    99       random.Reset();
    100       bool exceptionFired = false;
    101       try {
    102         CyclicCrossover.Apply(random, new Permutation(8), new Permutation(6));
    103       }
    104       catch (System.ArgumentException) {
    105         exceptionFired = true;
    106       }
    107       Assert.IsTrue(exceptionFired);
    108     }
    109 
    110     /// <summary>
    111     ///A test for Swap2Manipulator Constructor
    112     ///</summary>
    113     [TestMethod()]
    114     public void Swap2ManipulatorConstructorTest() {
    115       Swap2Manipulator target = new Swap2Manipulator();
    11698    }
    11799  }
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/Swap3ManipulatorTest.cs

    r2929 r2930  
    2121
    2222using Microsoft.VisualStudio.TestTools.UnitTesting;
     23using HeuristicLab.Encodings.Permutation;
    2324
    2425namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    8384    public void Swap3ManipulatorApplyTest() {
    8485      TestRandom random = new TestRandom();
    85       Permutation parent, expected;
     86      Permutation.Permutation parent, expected;
    8687      // Test manipulator
    8788      random.Reset();
    8889      random.IntNumbers = new int[] { 1, 3, 6 };
    8990      random.DoubleNumbers = new double[] { 0 };
    90       parent = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
     91      parent = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
    9192      Assert.IsTrue(parent.Validate());
    9293
    93       expected = new Permutation(new int[] { 0, 3, 2, 6, 4, 5, 1, 7, 8 });
     94      expected = new Permutation.Permutation(new int[] { 0, 3, 2, 6, 4, 5, 1, 7, 8 });
    9495      Assert.IsTrue(expected.Validate());
    9596      Swap3Manipulator.Apply(random, parent);
    9697      Assert.IsTrue(parent.Validate());
    9798      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    98      
    99       // perform a test when the two permutations are of unequal length
    100       random.Reset();
    101       bool exceptionFired = false;
    102       try {
    103         CyclicCrossover.Apply(random, new Permutation(8), new Permutation(6));
    104       }
    105       catch (System.ArgumentException) {
    106         exceptionFired = true;
    107       }
    108       Assert.IsTrue(exceptionFired);
    109     }
    110 
    111     /// <summary>
    112     ///A test for Swap3Manipulator Constructor
    113     ///</summary>
    114     [TestMethod()]
    115     public void Swap3ManipulatorConstructorTest() {
    116       Swap3Manipulator target = new Swap3Manipulator();
    11799    }
    118100  }
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/TranslocationInversionManipulatorTest.cs

    r2929 r2930  
    2121
    2222using Microsoft.VisualStudio.TestTools.UnitTesting;
     23using HeuristicLab.Encodings.Permutation;
    2324
    2425namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    8384    public void TranslocationInversionManipulatorApplyTest() {
    8485      TestRandom random = new TestRandom();
    85       Permutation parent, expected;
     86      Permutation.Permutation parent, expected;
    8687      // The following test is based on an example from Larranaga, P. et al. 1999. Genetic Algorithms for the Travelling Salesman Problem: A Review of Representations and Operators. Artificial Intelligence Review, 13
    8788      random.Reset();
    8889      random.IntNumbers = new int[] { 2, 4, 4 };
    89       parent = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     90      parent = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    9091      Assert.IsTrue(parent.Validate());
    9192     
    92       expected = new Permutation(new int[] { 0, 1, 5, 6, 4, 3, 2, 7 });
     93      expected = new Permutation.Permutation(new int[] { 0, 1, 5, 6, 4, 3, 2, 7 });
    9394      Assert.IsTrue(expected.Validate());
    9495      TranslocationInversionManipulator.Apply(random, parent);
    9596      Assert.IsTrue(parent.Validate());
    9697      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    97      
    98       // perform a test when the two permutations are of unequal length
    99       random.Reset();
    100       bool exceptionFired = false;
    101       try {
    102         CyclicCrossover.Apply(random, new Permutation(8), new Permutation(6));
    103       }
    104       catch (System.ArgumentException) {
    105         exceptionFired = true;
    106       }
    107       Assert.IsTrue(exceptionFired);
    108     }
    109 
    110     /// <summary>
    111     ///A test for InversionManipulator Constructor
    112     ///</summary>
    113     [TestMethod()]
    114     public void InversionManipulatorConstructorTest() {
    115       TranslocationInversionManipulator target = new TranslocationInversionManipulator();
    11698    }
    11799  }
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/TranslocationManipulatorTest.cs

    r2929 r2930  
    2121
    2222using Microsoft.VisualStudio.TestTools.UnitTesting;
     23using HeuristicLab.Encodings.Permutation;
    2324
    2425namespace HeuristicLab.Encodings.Permutation_33.Tests {
     
    8384    public void TranslocationManipulatorApplyTest() {
    8485      TestRandom random = new TestRandom();
    85       Permutation parent, expected;
     86      Permutation.Permutation parent, expected;
    8687      // The following test is based on an example from Larranaga, P. et al. 1999. Genetic Algorithms for the Travelling Salesman Problem: A Review of Representations and Operators. Artificial Intelligence Review, 13, p. 24
    8788      random.Reset();
    8889      random.IntNumbers = new int[] { 2, 4, 4 };
    89       parent = new Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
     90      parent = new Permutation.Permutation(new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
    9091      Assert.IsTrue(parent.Validate());
    9192     
    92       expected = new Permutation(new int[] { 0, 1, 5, 6, 2, 3, 4, 7 });
     93      expected = new Permutation.Permutation(new int[] { 0, 1, 5, 6, 2, 3, 4, 7 });
    9394      Assert.IsTrue(expected.Validate());
    9495      TranslocationManipulator.Apply(random, parent);
    9596      Assert.IsTrue(parent.Validate());
    9697      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    97      
    98       // perform a test when the two permutations are of unequal length
    99       random.Reset();
    100       bool exceptionFired = false;
    101       try {
    102         CyclicCrossover.Apply(random, new Permutation(8), new Permutation(6));
    103       }
    104       catch (System.ArgumentException) {
    105         exceptionFired = true;
    106       }
    107       Assert.IsTrue(exceptionFired);
    108     }
    109 
    110     /// <summary>
    111     ///A test for InversionManipulator Constructor
    112     ///</summary>
    113     [TestMethod()]
    114     public void InversionManipulatorConstructorTest() {
    115       TranslocationManipulator target = new TranslocationManipulator();
    11698    }
    11799  }
Note: See TracChangeset for help on using the changeset viewer.