Changeset 17624
- Timestamp:
- 06/22/20 14:55:40 (4 years ago)
- Location:
- branches/3040_VectorBasedGP
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs
r17622 r17624 132 132 { "EXPINT", new ExponentialIntegralEi()}, 133 133 { "AQ", new AnalyticQuotient() }, 134 { "MEAN", new Average()},134 //{ "MEAN", new Average()}, 135 135 { "IF", new IfThenElse()}, 136 136 { "GT", new GreaterThan()}, … … 142 142 { "DIFF", new Derivative()}, 143 143 { "LAG", new LaggedVariable() }, 144 { "SUM", new Sum() }, 145 { "MEAN", new Mean() }, 146 { "LENGTH", new Length() }, 147 { "STDEV", new StandardDeviation() }, 148 { "VAR", new Variance() }, 144 149 }; 145 150 -
branches/3040_VectorBasedGP/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs
r17606 r17624 271 271 272 272 #region vectors 273 AssertEqualAfterVectorSimplification( 274 "(sum (vectorvariable 2.0 a))", 275 "(* (sum (vectorvariable 1.0 a)) 2.0)"); 276 AssertEqualAfterVectorSimplification( 277 "(sum (* 2.0 (vectorvariable 1.0 a)))", 278 "(* (sum (vectorvariable 1.0 a)) 2.0)"); 279 AssertEqualAfterVectorSimplification( 280 "(sum (+ 2.0 (vectorvariable 1.0 a)))", 281 "(+ (* (length (vectorvariable 1.0 a)) 2.0)(sum (vectorvariable 1.0 a)) )"); 273 AssertEqualAfterVectorSimplification("remove aggregation for scalars from Sum", 274 "SUM(a)", 275 "a"); 276 AssertEqualAfterVectorSimplification("factor out multiplicative scalar from Sum", 277 "SUM(a{} * 2.0)", 278 "SUM(a{}) * 2.0"); 279 AssertEqualAfterVectorSimplification("factor out additive scalar from Sum", 280 "SUM(a{} + 2.0)", 281 "LENGTH(a{}) * 2.0 + SUM(a{})"); 282 283 AssertEqualAfterVectorSimplification("remove aggregation for scalars from Mean", 284 "MEAN(a)", 285 "a"); 286 AssertEqualAfterVectorSimplification("factor out multiplicative scalar from Mean", 287 "MEAN(2.0 * a{})", 288 "MEAN(a{}) * 2.0"); 289 AssertEqualAfterVectorSimplification("factor out additive scalar from Mean", 290 "MEAN(a{} + 2.0)", 291 "MEAN(a{}) + 2.0"); 292 293 AssertEqualAfterVectorSimplification("remove aggregation for scalars from Length", 294 "LENGTH(a)", 295 "1.0"); 296 AssertEqualAfterVectorSimplification("factor out multiplicative scalar from Length", 297 "LENGTH(a{} * 2.0)", 298 "LENGTH(a{})"); 299 AssertEqualAfterVectorSimplification("factor out additive scalar from Length", 300 "LENGTH(a{} + 2.0)", 301 "LENGTH(a{})"); 302 303 AssertEqualAfterVectorSimplification("remove aggregation for scalars from StandardDeviation", 304 "STDEV(a)", 305 "0.0"); 306 AssertEqualAfterVectorSimplification("factor out multiplicative scalar from StandardDeviation", 307 "STDEV(2.0 * a{})", 308 "STDEV(a{}) * 2.0"); 309 AssertEqualAfterVectorSimplification("factor out additive scalar from StandardDeviation", 310 "STDEV(a{} + 2.0)", 311 "STDEV(a{})"); 312 313 AssertEqualAfterVectorSimplification("remove aggregation for scalars from Variance", 314 "VAR(a)", 315 "0.0"); 316 AssertEqualAfterVectorSimplification("factor out multiplicative scalar from Variance", 317 "VAR(a{} * 2.0)", 318 "VAR(a{}) * 4.0"); 319 AssertEqualAfterVectorSimplification("factor out additive scalar from Variance", 320 "VAR(a{} + 2.0)", 321 "VAR(a{})"); 282 322 #endregion 283 323 } … … 292 332 } 293 333 294 private void AssertEqualAfterVectorSimplification(string original, string expected) {295 var formatter = new SymbolicExpressionTreeStringFormatter();296 var importer = new SymbolicExpressionImporter();334 private void AssertEqualAfterVectorSimplification(string msg, string original, string expected) { 335 var formatter = new InfixExpressionFormatter(); 336 var parser = new InfixExpressionParser(); 297 337 var simplifier = new VectorTreeSimplifier(new SymbolicDataAnalysisExpressionTreeVectorInterpreter()); 298 var actualTree = simplifier.Simplify( importer.Import(original));299 var expectedTree = importer.Import(expected);300 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree) );338 var actualTree = simplifier.Simplify(parser.Parse(original)); 339 var expectedTree = parser.Parse(expected); 340 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree), msg); 301 341 } 302 342 }
Note: See TracChangeset
for help on using the changeset viewer.