Changeset 3060 for trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Tests/SimulatedBinaryCrossoverTest.cs
- Timestamp:
- 03/16/10 10:46:59 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Tests/SimulatedBinaryCrossoverTest.cs
r3053 r3060 68 68 public void SimulatedBinaryCrossoverCrossTest() { 69 69 SimulatedBinaryCrossover_Accessor target = new SimulatedBinaryCrossover_Accessor(new PrivateObject(typeof(SimulatedBinaryCrossover))); 70 ItemArray< DoubleArray> parents;70 ItemArray<RealVector> 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 more than 2 parents 74 74 random.Reset(); 75 parents = new ItemArray< DoubleArray>(new DoubleArray[] { new DoubleArray(5), new DoubleArray(6), new DoubleArray(4) });75 parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) }); 76 76 exceptionFired = false; 77 77 try { 78 DoubleArrayactual;78 RealVector actual; 79 79 actual = target.Cross(random, parents); 80 80 } … … 85 85 // The following test checks if there is an exception when there are less than 2 parents 86 86 random.Reset(); 87 parents = new ItemArray< DoubleArray>(new DoubleArray[] { new DoubleArray(4) });87 parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) }); 88 88 exceptionFired = false; 89 89 try { 90 DoubleArrayactual;90 RealVector actual; 91 91 actual = target.Cross(random, parents); 92 92 } catch (System.ArgumentException) { … … 102 102 public void SimulatedBinaryCrossoverApplyTest() { 103 103 TestRandom random = new TestRandom(); 104 DoubleArrayparent1, parent2, expected, actual;104 RealVector parent1, parent2, expected, actual; 105 105 DoubleValue contiguity; 106 106 bool exceptionFired; … … 109 109 random.DoubleNumbers = new double[] { 0.3, 0.9, 0.7, 0.2, 0.8, 0.1, 0.2, 0.3, 0.4, 0.8, 0.7 }; 110 110 contiguity = new DoubleValue(0.3); 111 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });112 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });113 expected = new DoubleArray(new double[] { 1.11032829834638, -0.0145477755417797, 0.3, 0.5, 0.1 });111 parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 112 parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 113 expected = new RealVector(new double[] { 1.11032829834638, -0.0145477755417797, 0.3, 0.5, 0.1 }); 114 114 actual = SimulatedBinaryCrossover.Apply(random, parent1, parent2, contiguity); 115 Assert.IsTrue(Auxiliary. RealVectorIsAlmostEqualByPosition(actual, expected));115 Assert.IsTrue(Auxiliary.DoubleArrayIsAlmostEqualByPosition(actual, expected)); 116 116 // The following test is not based on published examples 117 117 random.Reset(); 118 118 random.DoubleNumbers = new double[] { 0.3, 0.9, 0.7, 0.2, 0.8, 0.1, 0.2, 0.3, 0.4, 0.8, 0.7 }; 119 119 contiguity = new DoubleValue(0.3); 120 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer121 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });120 parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 121 parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 122 122 exceptionFired = false; 123 123 try { … … 131 131 random.DoubleNumbers = new double[] { 0.3, 0.9, 0.7, 0.2, 0.8, 0.1, 0.2, 0.3, 0.4, 0.8, 0.7 }; 132 132 contiguity = new DoubleValue(-0.3); // contiguity < 0 133 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1});134 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });133 parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1}); 134 parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 135 135 exceptionFired = false; 136 136 try {
Note: See TracChangeset
for help on using the changeset viewer.