Changeset 3060 for trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Tests/BlendAlphaBetaCrossoverTest.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/BlendAlphaBetaCrossoverTest.cs
r3053 r3060 68 68 public void BlendAlphaBetaCrossoverCrossTest() { 69 69 BlendAlphaBetaCrossover_Accessor target = new BlendAlphaBetaCrossover_Accessor(new PrivateObject(typeof(BlendAlphaBetaCrossover))); 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 } catch (System.ArgumentException) { … … 84 84 // The following test checks if there is an exception when there are less than 2 parents 85 85 random.Reset(); 86 parents = new ItemArray< DoubleArray>(new DoubleArray[] { new DoubleArray(4) });86 parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) }); 87 87 exceptionFired = false; 88 88 try { 89 DoubleArrayactual;89 RealVector actual; 90 90 actual = target.Cross(random, parents); 91 91 } catch (System.ArgumentException) { … … 101 101 public void BlendAlphaBetaCrossoverApplyTest() { 102 102 TestRandom random = new TestRandom(); 103 DoubleArrayparent1, parent2, expected, actual;103 RealVector parent1, parent2, expected, actual; 104 104 DoubleValue alpha; 105 105 DoubleValue beta; … … 110 110 alpha = new DoubleValue(0.5); 111 111 beta = new DoubleValue(0.5); 112 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });113 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });114 expected = new DoubleArray(new double[] { 0.3, 0.15, 0.3, 0.35, 0.45 });112 parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 113 parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 114 expected = new RealVector(new double[] { 0.3, 0.15, 0.3, 0.35, 0.45 }); 115 115 actual = BlendAlphaBetaCrossover.Apply(random, parent1, parent2, alpha, beta); 116 Assert.IsTrue(Auxiliary. RealVectorIsAlmostEqualByPosition(actual, expected));116 Assert.IsTrue(Auxiliary.DoubleArrayIsAlmostEqualByPosition(actual, expected)); 117 117 // The following test is not based on published examples 118 118 random.Reset(); 119 119 random.DoubleNumbers = new double[] { 0.25, 0.75, 0.25, 0.75, 0.25 }; 120 120 alpha = new DoubleValue(-0.25); // negative values for alpha are not allowed 121 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });122 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });121 parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 }); 122 parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 123 123 exceptionFired = false; 124 124 try { … … 132 132 random.DoubleNumbers = new double[] { 0.25, 0.75, 0.25, 0.75, 0.25, .75 }; 133 133 alpha = new DoubleValue(0.25); 134 parent1 = new DoubleArray(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer135 parent2 = new DoubleArray(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 });134 parent1 = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1, 0.9 }); // this parent is longer 135 parent2 = new RealVector(new double[] { 0.4, 0.1, 0.3, 0.2, 0.8 }); 136 136 exceptionFired = false; 137 137 try {
Note: See TracChangeset
for help on using the changeset viewer.