Changeset 3048 for trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/DiscreteCrossoverTest.cs
- Timestamp:
- 03/15/10 23:49:54 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/DiscreteCrossoverTest.cs
r2936 r3048 68 68 public void DiscreteCrossoverCrossTest() { 69 69 DiscreteCrossover_Accessor target = new DiscreteCrossover_Accessor(new PrivateObject(typeof(DiscreteCrossover))); 70 ItemArray<DoubleArray Data> parents;70 ItemArray<DoubleArray> parents; 71 71 TestRandom random = new TestRandom(); 72 72 bool exceptionFired; 73 73 // The following test checks if there is an exception when there are less than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { new DoubleArrayData(4) });75 parents = new ItemArray<DoubleArray>(new DoubleArray[] { new DoubleArray(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArray Dataactual;78 DoubleArray actual; 79 79 actual = target.Cross(random, parents); 80 80 } catch (System.ArgumentException) { … … 90 90 public void DiscreteCrossoverApplyTest() { 91 91 TestRandom random = new TestRandom(); 92 DoubleArray Dataparent1, parent2, expected, actual;93 ItemArray<DoubleArray Data> parents;92 DoubleArray parent1, parent2, expected, actual; 93 ItemArray<DoubleArray> parents; 94 94 bool exceptionFired; 95 95 // The following test is not based on published examples 96 96 random.Reset(); 97 97 random.IntNumbers = new int[] { 0, 0, 1, 0, 1 }; 98 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });99 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });100 parents = new ItemArray<DoubleArray Data>( new DoubleArrayData[] { parent1, parent2 } );101 expected = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.8 });98 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 99 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 100 parents = new ItemArray<DoubleArray>( new DoubleArray[] { parent1, parent2 } ); 101 expected = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.8 }); 102 102 actual = DiscreteCrossover.Apply(random, parents); 103 103 Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(actual, expected)); … … 105 105 random.Reset(); 106 106 random.IntNumbers = new int[] { 0, 0, 1, 0, 1, 0 }; 107 parent1 = new DoubleArray Data(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer108 parent2 = new DoubleArray Data(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });109 parents = new ItemArray<DoubleArray Data>(new DoubleArrayData[] { parent1, parent2 });107 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 108 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 109 parents = new ItemArray<DoubleArray>(new DoubleArray[] { parent1, parent2 }); 110 110 exceptionFired = false; 111 111 try {
Note: See TracChangeset
for help on using the changeset viewer.