- Timestamp:
- 06/01/17 09:28:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Erc/ErcTests.cs
r14952 r15017 112 112 [TestProperty("Time", "Short")] 113 113 [TestCategory("ErcTests")] 114 public void StringStringErcValueTests() { 115 var options = new StringErcOptions( 116 new StringConstantErc(true, 1.0, "_1", "_2", "_3")); 117 118 Assert.IsTrue(options.IsEnabled); 119 120 var distribution = Enumerable.Range(0, 1000) 121 .Select(_ => options.GetErcValue(random)) 122 .GroupBy(x => x) 123 .ToDictionary(group => group.Key, group => group.Count()); 124 125 var estimatedRatio = 1.0 / 3.0; 126 127 Assert.IsTrue(IsAlmost(estimatedRatio, distribution["_1"] / 1000.0, tolerance)); 128 Assert.IsTrue(IsAlmost(estimatedRatio, distribution["_2"] / 1000.0, tolerance)); 129 Assert.IsTrue(IsAlmost(estimatedRatio, distribution["_3"] / 1000.0, tolerance)); 130 } 131 132 [TestMethod] 133 [TestProperty("Time", "Short")] 134 [TestCategory("ErcTests")] 114 135 public void MixedIntegerVectorErcValueTests() { 115 136 var options = new IntegerVectorErcOptions( … … 133 154 [TestProperty("Time", "Short")] 134 155 [TestCategory("ErcTests")] 156 public void DisabledIntegerVectorErcValueTests() { 157 var options = new IntegerVectorErcOptions( 158 new IntegerVectorConstantsErc(false, 0.8, new[] { 1, 2, 3 }, new[] { 4, 5, 6 }), 159 new IntegerVectorConstantsErc(true, 0.2, new[] { 10, 11, 12 }, new[] { 13, 14, 15 })); 160 161 Assert.IsTrue(options.IsEnabled); 162 163 var distribution = Enumerable.Range(0, 1000) 164 .Select(_ => options.GetErcValue(random)) 165 .GroupBy(x => x.All(_ => _ < 10) ? "constants1" : "constants2") 166 .ToDictionary(group => group.Key, group => group.Count()); 167 168 Assert.IsFalse(distribution.ContainsKey("constants1")); 169 Assert.AreEqual(1000, distribution["constants2"]); 170 } 171 172 [TestMethod] 173 [TestProperty("Time", "Short")] 174 [TestCategory("ErcTests")] 135 175 public void MixedFloatVectorErcValueTests() { 136 176 var options = new FloatVectorErcOptions(
Note: See TracChangeset
for help on using the changeset viewer.