- Timestamp:
- 03/04/10 15:15:44 (14 years ago)
- 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 20 20 #endregion 21 21 22 using HeuristicLab.Encodings.Permutation; 23 22 24 namespace HeuristicLab.Encodings.Permutation_33.Tests { 23 25 public static class Auxiliary { 24 public static bool PermutationIsEqualByPosition(Permutation p1,Permutation p2) {26 public static bool PermutationIsEqualByPosition(Permutation.Permutation p1, Permutation.Permutation p2) { 25 27 bool equal = (p1.Length == p2.Length); 26 28 if (equal) { -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/CosaCrossoverTest.cs
r2929 r2930 22 22 using HeuristicLab.Core; 23 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 24 using HeuristicLab.Encodings.Permutation; 24 25 25 26 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 91 92 bool exceptionFired = false; 92 93 try { 93 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {94 new Permutation (4), new Permutation(4), newPermutation(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)})); 95 96 } catch (System.InvalidOperationException) { 96 97 exceptionFired = true; … … 105 106 public void CosaCrossoverApplyTest() { 106 107 TestRandom random = new TestRandom(); 107 Permutation parent1, parent2, expected, actual;108 Permutation.Permutation parent1, parent2, expected, actual; 108 109 // 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. 109 110 random.Reset(); 110 111 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 }); 112 113 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 }); 114 115 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 }); 116 117 Assert.IsTrue(expected.Validate()); 117 118 actual = CosaCrossover.Apply(random, parent1, parent2); … … 121 122 random.Reset(); 122 123 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 }); 124 125 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 }); 126 127 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 }); 128 129 Assert.IsTrue(expected.Validate()); 129 130 actual = CosaCrossover.Apply(random, parent1, parent2); … … 133 134 random.Reset(); 134 135 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 }); 136 137 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 }); 138 139 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 }); 140 141 Assert.IsTrue(expected.Validate()); 141 142 actual = CosaCrossover.Apply(random, parent1, parent2); … … 147 148 bool exceptionFired = false; 148 149 try { 149 CosaCrossover.Apply(random, new Permutation (8), newPermutation(6));150 CosaCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6)); 150 151 } catch (System.ArgumentException) { 151 152 exceptionFired = true; … … 153 154 Assert.IsTrue(exceptionFired); 154 155 } 155 156 /// <summary>157 ///A test for CosaCrossover Constructor158 ///</summary>159 [TestMethod()]160 public void CosaCrossoverConstructorTest() {161 CosaCrossover target = new CosaCrossover();162 }163 156 } 164 157 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/CyclicCrossover2Test.cs
r2929 r2930 1 1 using HeuristicLab.Core; 2 2 using Microsoft.VisualStudio.TestTools.UnitTesting; 3 using HeuristicLab.Encodings.Permutation; 3 4 4 5 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 69 70 bool exceptionFired = false; 70 71 try { 71 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {72 new Permutation (4), new Permutation(4), newPermutation(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)})); 73 74 } catch (System.InvalidOperationException) { 74 75 exceptionFired = true; … … 83 84 public void CyclicCrossover2ApplyTest() { 84 85 TestRandom random = new TestRandom(); 85 Permutation parent1, parent2, expected, actual;86 Permutation.Permutation parent1, parent2, expected, actual; 86 87 // 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. 87 88 random.Reset(); 88 89 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 }); 90 91 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 }); 92 93 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 }); 94 95 Assert.IsTrue(expected.Validate()); 95 96 actual = CyclicCrossover2.Apply(random, parent1, parent2); … … 101 102 bool exceptionFired = false; 102 103 try { 103 CyclicCrossover.Apply(random, new Permutation (8), newPermutation(6));104 CyclicCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6)); 104 105 } catch (System.ArgumentException) { 105 106 exceptionFired = true; … … 107 108 Assert.IsTrue(exceptionFired); 108 109 } 109 110 /// <summary>111 ///A test for CyclicCrossover2 Constructor112 ///</summary>113 [TestMethod()]114 public void CyclicCrossover2ConstructorTest() {115 CyclicCrossover2 target = new CyclicCrossover2();116 }117 110 } 118 111 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/CyclicCrossoverTest.cs
r2929 r2930 22 22 using HeuristicLab.Core; 23 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 24 using HeuristicLab.Encodings.Permutation; 24 25 25 26 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 91 92 bool exceptionFired = false; 92 93 try { 93 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {94 new Permutation (4), new Permutation(4), newPermutation(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)})); 95 96 } 96 97 catch (System.InvalidOperationException) { … … 106 107 public void CyclicCrossoverApplyTest() { 107 108 TestRandom random = new TestRandom(); 108 Permutation parent1, parent2, expected, actual;109 Permutation.Permutation parent1, parent2, expected, actual; 109 110 // 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 110 111 random.Reset(); 111 112 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 }); 113 114 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 }); 115 116 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 }); 117 118 Assert.IsTrue(expected.Validate()); 118 119 actual = CyclicCrossover.Apply(random, parent1, parent2); … … 124 125 bool exceptionFired = false; 125 126 try { 126 CyclicCrossover.Apply(random, new Permutation (8), newPermutation(6));127 CyclicCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6)); 127 128 } 128 129 catch (System.ArgumentException) { … … 131 132 Assert.IsTrue(exceptionFired); 132 133 } 133 134 /// <summary>135 ///A test for OrderCrossover Constructor136 ///</summary>137 [TestMethod()]138 public void CyclicCrossoverConstructorTest() {139 CyclicCrossover target = new CyclicCrossover();140 }141 134 } 142 135 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/EdgeRecombinationCrossoverTest.cs
r2929 r2930 22 22 using HeuristicLab.Core; 23 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 24 using HeuristicLab.Encodings.Permutation; 24 25 25 26 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 91 92 bool exceptionFired = false; 92 93 try { 93 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {94 new Permutation (4), new Permutation(4), newPermutation(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)})); 95 96 } 96 97 catch (System.InvalidOperationException) { … … 106 107 public void EdgeRecombinationCrossoverApplyTest() { 107 108 TestRandom random = new TestRandom(); 108 Permutation parent1, parent2, expected, actual;109 Permutation.Permutation parent1, parent2, expected, actual; 109 110 // 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 110 111 random.Reset(); 111 112 random.IntNumbers = new int[] { 0 }; 112 113 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 }); 114 115 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 }); 116 117 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 }); 118 119 Assert.IsTrue(expected.Validate()); 119 120 actual = EdgeRecombinationCrossover.Apply(random, parent1, parent2); … … 125 126 bool exceptionFired = false; 126 127 try { 127 EdgeRecombinationCrossover.Apply(random, new Permutation (8), newPermutation(6));128 EdgeRecombinationCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6)); 128 129 } 129 130 catch (System.ArgumentException) { … … 132 133 Assert.IsTrue(exceptionFired); 133 134 } 134 135 /// <summary>136 ///A test for EdgeRecombinationCrossover Constructor137 ///</summary>138 [TestMethod()]139 public void EdgeRecombinationCrossoverConstructorTest() {140 EdgeRecombinationCrossover target = new EdgeRecombinationCrossover();141 }142 135 } 143 136 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/HeuristicLab.Encodings.Permutation-3.3.Tests.csproj
r2929 r2930 141 141 </ItemGroup> 142 142 <ItemGroup> 143 <Shadow Include="Test References\HeuristicLab. Permutation-3.3.accessor" />143 <Shadow Include="Test References\HeuristicLab.Encodings.Permutation-3.3.accessor" /> 144 144 </ItemGroup> 145 145 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/InsertionManipulatorTest.cs
r2929 r2930 21 21 22 22 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 using HeuristicLab.Encodings.Permutation; 23 24 24 25 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 83 84 public void InsertionManipulatorApplyTest() { 84 85 TestRandom random = new TestRandom(); 85 Permutation parent, expected;86 Permutation.Permutation parent, expected; 86 87 // 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 87 88 random.Reset(); 88 89 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 }); 90 91 Assert.IsTrue(parent.Validate()); 91 92 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 }); 93 94 Assert.IsTrue(expected.Validate()); 94 95 InsertionManipulator.Apply(random, parent); 95 96 Assert.IsTrue(parent.Validate()); 96 97 Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent)); 97 98 // perform a test when the two permutations are of unequal length99 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 Constructor112 ///</summary>113 [TestMethod()]114 public void InsertionManipulatorConstructorTest() {115 InsertionManipulator target = new InsertionManipulator();116 98 } 117 99 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/InversionManipulatorTest.cs
r2929 r2930 21 21 22 22 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 using HeuristicLab.Encodings.Permutation; 23 24 24 25 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 83 84 public void InversionManipulatorApplyTest() { 84 85 TestRandom random = new TestRandom(); 85 Permutation parent, expected;86 Permutation.Permutation parent, expected; 86 87 // 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 87 88 random.Reset(); 88 89 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 }); 90 91 Assert.IsTrue(parent.Validate()); 91 92 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 }); 93 94 Assert.IsTrue(expected.Validate()); 94 95 InversionManipulator.Apply(random, parent); 95 96 Assert.IsTrue(parent.Validate()); 96 97 Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent)); 97 98 // perform a test when the two permutations are of unequal length99 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 Constructor112 ///</summary>113 [TestMethod()]114 public void InversionManipulatorConstructorTest() {115 InversionManipulator target = new InversionManipulator();116 98 } 117 99 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/MaximalPreservativeCrossoverTest.cs
r2929 r2930 22 22 using HeuristicLab.Core; 23 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 24 using HeuristicLab.Encodings.Permutation; 24 25 25 26 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 91 92 bool exceptionFired = false; 92 93 try { 93 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {94 new Permutation (4), new Permutation(4), newPermutation(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)})); 95 96 } 96 97 catch (System.InvalidOperationException) { … … 106 107 public void MaximalPreservativeCrossoverApplyTest() { 107 108 TestRandom random = new TestRandom(); 108 Permutation parent1, parent2, expected, actual;109 Permutation.Permutation parent1, parent2, expected, actual; 109 110 // The following test is based on an example from Larranaga, 1999. Genetic Algorithms for the Traveling Salesman Problem. 110 111 random.Reset(); 111 112 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 }); 113 114 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 }); 115 116 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 }); 117 118 Assert.IsTrue(expected.Validate()); 118 119 actual = MaximalPreservativeCrossover.Apply(random, parent1, parent2); … … 124 125 bool exceptionFired = false; 125 126 try { 126 MaximalPreservativeCrossover.Apply(random, new Permutation (8), newPermutation(6));127 MaximalPreservativeCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6)); 127 128 } 128 129 catch (System.ArgumentException) { … … 131 132 Assert.IsTrue(exceptionFired); 132 133 } 133 134 /// <summary>135 ///A test for OrderCrossover Constructor136 ///</summary>137 [TestMethod()]138 public void MaximalPreservativeCrossoverConstructorTest() {139 MaximalPreservativeCrossover target = new MaximalPreservativeCrossover();140 }141 134 } 142 135 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/OrderBasedCrossoverTest.cs
r2929 r2930 22 22 using HeuristicLab.Core; 23 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 24 using HeuristicLab.Encodings.Permutation; 24 25 25 26 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 91 92 bool exceptionFired = false; 92 93 try { 93 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {94 new Permutation (4), new Permutation(4), newPermutation(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)})); 95 96 } catch (System.InvalidOperationException) { 96 97 exceptionFired = true; … … 105 106 public void OrderBasedCrossoverApplyTest() { 106 107 TestRandom random = new TestRandom(); 107 Permutation parent1, parent2, expected, actual;108 Permutation.Permutation parent1, parent2, expected, actual; 108 109 // 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 109 110 random.Reset(); 110 111 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 }); 112 113 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 }); 114 115 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 }); 116 117 actual = OrderBasedCrossover.Apply(random, parent1, parent2); 117 118 Assert.IsTrue(actual.Validate()); … … 121 122 bool exceptionFired = false; 122 123 try { 123 OrderBasedCrossover.Apply(random, new Permutation (8), newPermutation(6));124 OrderBasedCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6)); 124 125 } catch (System.ArgumentException) { 125 126 exceptionFired = true; … … 127 128 Assert.IsTrue(exceptionFired); 128 129 } 129 130 /// <summary>131 ///A test for OrderBasedCrossover Constructor132 ///</summary>133 [TestMethod()]134 public void OrderBasedCrossoverConstructorTest() {135 OrderBasedCrossover target = new OrderBasedCrossover();136 }137 130 } 138 131 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/OrderCrossover2Test.cs
r2929 r2930 1 1 using HeuristicLab.Core; 2 2 using Microsoft.VisualStudio.TestTools.UnitTesting; 3 using HeuristicLab.Encodings.Permutation; 3 4 4 5 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 68 69 bool exceptionFired = false; 69 70 try { 70 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {71 new Permutation (4), new Permutation(4), newPermutation(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)})); 72 73 } catch (System.InvalidOperationException) { 73 74 exceptionFired = true; … … 82 83 public void OrderCrossover2ApplyTest() { 83 84 TestRandom random = new TestRandom(); 84 Permutation parent1, parent2, expected, actual;85 Permutation.Permutation parent1, parent2, expected, actual; 85 86 // 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. 86 87 random.Reset(); 87 88 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 }); 89 90 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 }); 91 92 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 }); 93 94 Assert.IsTrue(expected.Validate()); 94 95 actual = OrderCrossover2.Apply(random, parent1, parent2); … … 100 101 bool exceptionFired = false; 101 102 try { 102 OrderCrossover.Apply(random, new Permutation (8), newPermutation(6));103 OrderCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6)); 103 104 } catch (System.ArgumentException) { 104 105 exceptionFired = true; … … 106 107 Assert.IsTrue(exceptionFired); 107 108 } 108 109 /// <summary>110 ///A test for OrderCrossover2 Constructor111 ///</summary>112 [TestMethod()]113 public void OrderCrossover2ConstructorTest() {114 OrderCrossover2 target = new OrderCrossover2();115 }116 109 } 117 110 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/OrderCrossoverTest.cs
r2929 r2930 22 22 using HeuristicLab.Core; 23 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 24 using HeuristicLab.Encodings.Permutation; 24 25 25 26 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 91 92 bool exceptionFired = false; 92 93 try { 93 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {94 new Permutation (4), new Permutation(4), newPermutation(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)})); 95 96 } catch (System.InvalidOperationException) { 96 97 exceptionFired = true; … … 105 106 public void OrderCrossoverApplyTest() { 106 107 TestRandom random = new TestRandom(); 107 Permutation parent1, parent2, expected, actual;108 Permutation.Permutation parent1, parent2, expected, actual; 108 109 // 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 109 110 random.Reset(); 110 111 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 }); 112 113 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 }); 114 115 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 }); 116 117 Assert.IsTrue(expected.Validate()); 117 118 actual = OrderCrossover.Apply(random, parent1, parent2); … … 121 122 random.Reset(); 122 123 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 }); 124 125 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 }); 126 127 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 }); 128 129 actual = OrderCrossover.Apply(random, parent1, parent2); 129 130 Assert.IsTrue(actual.Validate()); … … 132 133 random.Reset(); 133 134 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 }); 135 136 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 }); 137 138 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 }); 139 140 Assert.IsTrue(expected.Validate()); 140 141 actual = OrderCrossover.Apply(random, parent1, parent2); … … 144 145 random.Reset(); 145 146 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 }); 147 148 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 }); 149 150 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 }); 151 152 Assert.IsTrue(expected.Validate()); 152 153 actual = OrderCrossover.Apply(random, parent1, parent2); … … 156 157 random.Reset(); 157 158 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 }); 159 160 Assert.IsTrue(expected.Validate()); 160 161 actual = OrderCrossover.Apply(random, parent1, parent2); … … 164 165 random.Reset(); 165 166 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 }); 167 168 Assert.IsTrue(expected.Validate()); 168 169 actual = OrderCrossover.Apply(random, parent1, parent2); … … 174 175 bool exceptionFired = false; 175 176 try { 176 OrderCrossover.Apply(random, new Permutation (8), newPermutation(6));177 OrderCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6)); 177 178 } catch (System.ArgumentException) { 178 179 exceptionFired = true; … … 180 181 Assert.IsTrue(exceptionFired); 181 182 } 182 183 /// <summary>184 ///A test for OrderCrossover Constructor185 ///</summary>186 [TestMethod()]187 public void OrderCrossoverConstructorTest() {188 OrderCrossover target = new OrderCrossover();189 }190 183 } 191 184 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/PartiallyMatchedCrossoverTest.cs
r2929 r2930 22 22 using HeuristicLab.Core; 23 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 24 using HeuristicLab.Encodings.Permutation; 24 25 25 26 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 91 92 bool exceptionFired = false; 92 93 try { 93 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {94 new Permutation (4), new Permutation(4), newPermutation(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)})); 95 96 } 96 97 catch (System.InvalidOperationException) { … … 106 107 public void PartiallyMatchedCrossoverApplyTest() { 107 108 TestRandom random = new TestRandom(); 108 Permutation parent1, parent2, expected, actual;109 Permutation.Permutation parent1, parent2, expected, actual; 109 110 // The following test is based on an example from Larranaga, 1999. Genetic Algorithms for the Traveling Salesman Problem. 110 111 random.Reset(); 111 112 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 }); 113 114 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 }); 115 116 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 }); 117 118 Assert.IsTrue(expected.Validate()); 118 119 actual = PartiallyMatchedCrossover.Apply(random, parent1, parent2); … … 122 123 random.Reset(); 123 124 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 }); 125 126 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 }); 127 128 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 }); 129 130 Assert.IsTrue(expected.Validate()); 130 131 actual = PartiallyMatchedCrossover.Apply(random, parent1, parent2); … … 136 137 bool exceptionFired = false; 137 138 try { 138 PartiallyMatchedCrossover.Apply(random, new Permutation (8), newPermutation(6));139 PartiallyMatchedCrossover.Apply(random, new Permutation.Permutation(8), new Permutation.Permutation(6)); 139 140 } 140 141 catch (System.ArgumentException) { … … 143 144 Assert.IsTrue(exceptionFired); 144 145 } 145 146 /// <summary>147 ///A test for PartiallyMatchedCrossover Constructor148 ///</summary>149 [TestMethod()]150 public void PartiallyMatchedCrossoverConstructorTest() {151 PartiallyMatchedCrossover target = new PartiallyMatchedCrossover();152 }153 146 } 154 147 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/PositionBasedCrossoverTest.cs
r2929 r2930 22 22 using HeuristicLab.Core; 23 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 24 using HeuristicLab.Encodings.Permutation; 24 25 25 26 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 92 93 bool exceptionFired = false; 93 94 try { 94 target.Cross(random, new ItemArray<Permutation >(newPermutation[] {95 new Permutation (4), new Permutation(4), newPermutation(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) })); 96 97 } 97 98 catch (System.InvalidOperationException) { … … 108 109 public void PositionBasedCrossoverApplyTest() { 109 110 TestRandom random = new TestRandom(); 110 Permutation parent1, parent2, expected, actual;111 Permutation.Permutation parent1, parent2, expected, actual; 111 112 112 113 // The following test is based on an example from Larranaga, 1999. Genetic Algorithms for the Traveling Salesman Problem. 113 114 random.Reset(); 114 115 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 }); 116 117 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 }); 118 119 Assert.IsTrue(parent2.Validate()); 119 120 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 }); 121 122 Assert.IsTrue(expected.Validate()); 122 123 actual = PositionBasedCrossover.Apply(random, parent1, parent2); … … 128 129 bool exceptionFired = false; 129 130 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) { 133 133 exceptionFired = true; 134 134 } 135 135 Assert.IsTrue(exceptionFired); 136 136 } 137 138 /// <summary>139 ///A test for PositionBasedCrossover Constructor140 ///</summary>141 [TestMethod()]142 public void PositionBasedCrossoverConstructorTest() {143 PositionBasedCrossover target = new PositionBasedCrossover();144 }145 137 } 146 138 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/ScrambleManipulatorTest.cs
r2929 r2930 21 21 22 22 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 using HeuristicLab.Encodings.Permutation; 23 24 24 25 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 83 84 public void ScrambleManipulatorApplyTest() { 84 85 TestRandom random = new TestRandom(); 85 Permutation parent, expected;86 Permutation.Permutation parent, expected; 86 87 // 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 87 88 random.Reset(); 88 89 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 }); 90 91 Assert.IsTrue(parent.Validate()); 91 92 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 }); 93 94 Assert.IsTrue(expected.Validate()); 94 95 ScrambleManipulator.Apply(random, parent); 95 96 Assert.IsTrue(parent.Validate()); 96 97 Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent)); 97 98 // perform a test when the two permutations are of unequal length99 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 Constructor112 ///</summary>113 [TestMethod()]114 public void ScrambleManipulatorConstructorTest() {115 ScrambleManipulator target = new ScrambleManipulator();116 98 } 117 99 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/Swap2ManipulatorTest.cs
r2929 r2930 21 21 22 22 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 using HeuristicLab.Encodings.Permutation; 23 24 24 25 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 83 84 public void Swap2ManipulatorApplyTest() { 84 85 TestRandom random = new TestRandom(); 85 Permutation parent, expected;86 Permutation.Permutation parent, expected; 86 87 // 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 87 88 random.Reset(); 88 89 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 }); 90 91 Assert.IsTrue(parent.Validate()); 91 92 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 }); 93 94 Assert.IsTrue(expected.Validate()); 94 95 Swap2Manipulator.Apply(random, parent); 95 96 Assert.IsTrue(parent.Validate()); 96 97 Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent)); 97 98 // perform a test when the two permutations are of unequal length99 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 Constructor112 ///</summary>113 [TestMethod()]114 public void Swap2ManipulatorConstructorTest() {115 Swap2Manipulator target = new Swap2Manipulator();116 98 } 117 99 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/Swap3ManipulatorTest.cs
r2929 r2930 21 21 22 22 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 using HeuristicLab.Encodings.Permutation; 23 24 24 25 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 83 84 public void Swap3ManipulatorApplyTest() { 84 85 TestRandom random = new TestRandom(); 85 Permutation parent, expected;86 Permutation.Permutation parent, expected; 86 87 // Test manipulator 87 88 random.Reset(); 88 89 random.IntNumbers = new int[] { 1, 3, 6 }; 89 90 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 }); 91 92 Assert.IsTrue(parent.Validate()); 92 93 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 }); 94 95 Assert.IsTrue(expected.Validate()); 95 96 Swap3Manipulator.Apply(random, parent); 96 97 Assert.IsTrue(parent.Validate()); 97 98 Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent)); 98 99 // perform a test when the two permutations are of unequal length100 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 Constructor113 ///</summary>114 [TestMethod()]115 public void Swap3ManipulatorConstructorTest() {116 Swap3Manipulator target = new Swap3Manipulator();117 99 } 118 100 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/TranslocationInversionManipulatorTest.cs
r2929 r2930 21 21 22 22 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 using HeuristicLab.Encodings.Permutation; 23 24 24 25 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 83 84 public void TranslocationInversionManipulatorApplyTest() { 84 85 TestRandom random = new TestRandom(); 85 Permutation parent, expected;86 Permutation.Permutation parent, expected; 86 87 // 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 87 88 random.Reset(); 88 89 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 }); 90 91 Assert.IsTrue(parent.Validate()); 91 92 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 }); 93 94 Assert.IsTrue(expected.Validate()); 94 95 TranslocationInversionManipulator.Apply(random, parent); 95 96 Assert.IsTrue(parent.Validate()); 96 97 Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent)); 97 98 // perform a test when the two permutations are of unequal length99 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 Constructor112 ///</summary>113 [TestMethod()]114 public void InversionManipulatorConstructorTest() {115 TranslocationInversionManipulator target = new TranslocationInversionManipulator();116 98 } 117 99 } -
trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/TranslocationManipulatorTest.cs
r2929 r2930 21 21 22 22 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 using HeuristicLab.Encodings.Permutation; 23 24 24 25 namespace HeuristicLab.Encodings.Permutation_33.Tests { … … 83 84 public void TranslocationManipulatorApplyTest() { 84 85 TestRandom random = new TestRandom(); 85 Permutation parent, expected;86 Permutation.Permutation parent, expected; 86 87 // 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 87 88 random.Reset(); 88 89 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 }); 90 91 Assert.IsTrue(parent.Validate()); 91 92 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 }); 93 94 Assert.IsTrue(expected.Validate()); 94 95 TranslocationManipulator.Apply(random, parent); 95 96 Assert.IsTrue(parent.Validate()); 96 97 Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent)); 97 98 // perform a test when the two permutations are of unequal length99 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 Constructor112 ///</summary>113 [TestMethod()]114 public void InversionManipulatorConstructorTest() {115 TranslocationManipulator target = new TranslocationManipulator();116 98 } 117 99 }
Note: See TracChangeset
for help on using the changeset viewer.