Changeset 2930 for trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/TranslocationManipulatorTest.cs
- Timestamp:
- 03/04/10 15:15:44 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.