Changeset 18087 for branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4
- Timestamp:
- 11/19/21 16:16:54 (3 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Tests
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs
r17226 r18087 274 274 [TestProperty("Time", "long")] 275 275 public void TestCompiledInterpreterEstimatedValuesConsistency() { 276 const double delta = 1e- 12;276 const double delta = 1e-8; 277 277 278 278 var twister = new MersenneTwister(); … … 288 288 grammar.ConfigureAsDefaultRegressionGrammar(); 289 289 grammar.Symbols.First(x => x.Name == "Power Functions").Enabled = true; 290 grammar.Symbols.First(x => x is Cube).Enabled = true; 291 grammar.Symbols.First(x => x is CubeRoot).Enabled = true; 292 grammar.Symbols.First(x => x is Square).Enabled = true; 293 grammar.Symbols.First(x => x is SquareRoot).Enabled = true; 294 grammar.Symbols.First(x => x is Absolute).Enabled = true; 295 grammar.Symbols.First(x => x is Sine).Enabled = true; 296 grammar.Symbols.First(x => x is Cosine).Enabled = true; 297 grammar.Symbols.First(x => x is Tangent).Enabled = true; 298 grammar.Symbols.First(x => x is Root).Enabled = false; 299 grammar.Symbols.First(x => x is Power).Enabled = false; 290 300 291 301 var randomTrees = Util.CreateRandomTrees(twister, dataset, grammar, N, 1, 10, 0, 0); … … 311 321 var v2 = valuesMatrix[n][row]; 312 322 if (double.IsNaN(v1) && double.IsNaN(v2)) continue; 313 if ( Math.Abs(v1 - v2) >delta) {323 if (v1 != v2 && Math.Abs(1.0 - v1 / v2) >= delta) { 314 324 Console.WriteLine(formatter.Format(tree)); 315 325 foreach (var node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToList()) { … … 339 349 } 340 350 string errorMessage = string.Format("Interpreters {0} and {1} do not agree on tree {2} and row {3} (seed = {4}).", interpreters[m].Name, interpreters[n].Name, i, row, seed); 341 Assert.AreEqual(v1, v2, delta, errorMessage); 351 Assert.IsTrue(double.IsNaN(v1) && double.IsNaN(v2) || 352 v1 == v2 || // in particular 0 = 0 353 Math.Abs(1.0 - v1 / v2) < delta, errorMessage); 342 354 } 343 355 } -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs
r17226 r18087 99 99 #region root rules 100 100 // cancellation 101 AssertEqualAfterSimplification("(root (variable 2.0 a) 0.0)", " 1.0");101 AssertEqualAfterSimplification("(root (variable 2.0 a) 0.0)", "NaN"); 102 102 // fixed point 103 103 AssertEqualAfterSimplification("(root (variable 2.0 a) 1.0)", "(variable 2.0 a)"); … … 269 269 270 270 #endregion 271 272 #region do not drop subtrees with small weights 273 AssertEqualAfterSimplification("(* 1e-14 (variable 1.0 a))", "(variable 1e-14 a)"); 274 AssertEqualAfterSimplification("(+ (variable 1.0 a) 1e-14)", 275 "(+ (variable 1.0 a) 1e-14)"); 276 // a scenario where a term with small weight can have large effect 277 AssertEqualAfterSimplification("(+ (* (pow (variable 1.0 a) 10) 1e-14) 1.0)", 278 "(+ (* (pow (variable 1.0 a) 10) 1e-14) 1.0)"); 279 // a test case (from ticket #2985) 280 AssertEqualAfterSimplification("(+ (* (exp (variable 3.5861E+001 a)) 5.5606E-016) 5.9323E-002)", 281 "(+ (* (exp (variable 3.5861E+001 a)) 5.5606E-016) 5.9323E-002)"); 282 #endregion 271 283 } 272 284
Note: See TracChangeset
for help on using the changeset viewer.