Changeset 16433 for branches/2965_CancelablePersistence/HeuristicLab.Tests
- Timestamp:
- 12/21/18 14:05:46 (5 years ago)
- Location:
- branches/2965_CancelablePersistence
- Files:
-
- 1 deleted
- 7 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2965_CancelablePersistence
- Property svn:mergeinfo changed
-
branches/2965_CancelablePersistence/HeuristicLab.Tests
- Property svn:mergeinfo changed
-
branches/2965_CancelablePersistence/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicRegressionSampleWithOSTest.cs
r15583 r16433 104 104 var squareroot = grammar.Symbols.OfType<SquareRoot>().Single(); 105 105 var root = grammar.Symbols.OfType<Root>().Single(); 106 var cube = grammar.Symbols.OfType<Cube>().Single(); 107 var cuberoot = grammar.Symbols.OfType<CubeRoot>().Single(); 106 108 var log = grammar.Symbols.OfType<Logarithm>().Single(); 107 109 var exp = grammar.Symbols.OfType<Exponential>().Single(); … … 130 132 grammar.AddAllowedChildSymbol(squareroot, variable); 131 133 134 cube.Enabled = false; 135 cuberoot.Enabled = false; 132 136 root.Enabled = false; 133 137 -
branches/2965_CancelablePersistence/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs
r16294 r16433 113 113 var t = new SymbolicExpressionTree(root); 114 114 115 Assert.AreEqual("(('y' * 'z' * 60) / SQR(('y' * 'z' * 20)))", // actually 3 / (4y 5z) but simplifier is not smart enough to cancel numerator and denominator116 // 60 y z / y² z² 20² == 6 / y z 40 == 3 / y z 20115 Assert.AreEqual("(('y' * 'z' * 60) / (SQR('y') * SQR('z') * 400))", // actually 3 / (4y 5z) but simplifier is not smart enough to cancel numerator and denominator 116 // 60 y z / y² z² 20² == 6 / y z 40 == 3 / y z 20 117 117 formatter.Format(DerivativeCalculator.Derive(t, "x"))); 118 Assert.AreEqual("(('x' * 'z' * (-60)) / SQR(('y' * 'z' * 20)))", // actually 3x * -(4 5 z) / (4y 5z)² = -3x / (20 y² z)118 Assert.AreEqual("(('x' * 'z' * (-60)) / (SQR('y') * SQR('z') * 400))", // actually 3x * -(4 5 z) / (4y 5z)² = -3x / (20 y² z) 119 119 // -3 4 5 x z / 4² y² 5² z² = -60 x z / 20² z² y² == -60 x z / y² z² 20² 120 120 formatter.Format(DerivativeCalculator.Derive(t, "y"))); 121 Assert.AreEqual("(('x' * 'y' * (-60)) / SQR(('y' * 'z' * 20)))",121 Assert.AreEqual("(('x' * 'y' * (-60)) / (SQR('y') * SQR('z') * 400))", 122 122 formatter.Format(DerivativeCalculator.Derive(t, "z"))); 123 123 } -
branches/2965_CancelablePersistence/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/InfixExpressionParserTest.cs
r15583 r16433 61 61 62 62 Console.WriteLine(formatter.Format(parser.Parse("log(3)"))); 63 Console.WriteLine(formatter.Format(parser.Parse("log(-3)"))); 63 Console.WriteLine(formatter.Format(parser.Parse("log(-3)"))); // should produce log(-3) as output 64 64 Console.WriteLine(formatter.Format(parser.Parse("exp(3)"))); 65 Console.WriteLine(formatter.Format(parser.Parse("exp(-3)"))); 65 Console.WriteLine(formatter.Format(parser.Parse("exp(-3)"))); // should produce exp(-3) as output 66 66 Console.WriteLine(formatter.Format(parser.Parse("sqrt(3)"))); 67 67 68 Console.WriteLine(formatter.Format(parser.Parse("sqr((-3))"))); 68 Console.WriteLine(formatter.Format(parser.Parse("sqr((-3))"))); // should produce sqr((-3)) as output 69 69 70 Console.WriteLine(formatter.Format(parser.Parse("3/3+2/2+1/1"))); 71 Console.WriteLine(formatter.Format(parser.Parse("-3+30-2+20-1+10"))); 70 Console.WriteLine(formatter.Format(parser.Parse("3/3+2/2+1/1"))); // ((3 * 1 / 3) + (2 * 1 / 2) + (1 * 1 / 1)) 71 Console.WriteLine(formatter.Format(parser.Parse("-3+30-2+20-1+10"))); // not (30 + 20 + 10 + ((-1) * (3 + 2 + 1))) 72 72 // round trip 73 Console.WriteLine(formatter.Format(parser.Parse(formatter.Format(parser.Parse("-3+30-2+20-1+10"))))); 73 Console.WriteLine(formatter.Format(parser.Parse(formatter.Format(parser.Parse("-3+30-2+20-1+10"))))); // not (30 + 20 + 10 + ((-(1)) * (3 + 2 + 1))) 74 74 75 75 Console.WriteLine(formatter.Format(parser.Parse("\"x1\""))); -
branches/2965_CancelablePersistence/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs
r15583 r16433 228 228 AssertEqualAfterSimplification("(- (factor a 2.0 3.0) (binfactor a x0 2.0))", "(factor a 0.0 3.0)"); 229 229 #endregion 230 231 #region abs 232 AssertEqualAfterSimplification("(abs 2.0)", "2.0"); 233 AssertEqualAfterSimplification("(abs -2.0)", "2.0"); // constant folding 234 AssertEqualAfterSimplification("(abs (exp (variable 2.0 x)))", "(exp (variable 2.0 x)))"); // exp is always positive 235 AssertEqualAfterSimplification("(abs (exp (variable 2.0 x)))", "(exp (variable 2.0 x)))"); // exp is always positive 236 AssertEqualAfterSimplification("(abs (sqr (variable 2.0 a)))", "(sqr (variable 2.0 a))"); // sqr is always positive 237 AssertEqualAfterSimplification("(abs (sqrt (variable 2.0 a)))", "(sqrt (variable 2.0 a))"); // sqrt is always positive (for our cases) 238 AssertEqualAfterSimplification("(abs (cuberoot (variable 2.0 a)))", "(cuberoot (variable 2.0 a))"); // cuberoot is always positive (for our cases) 239 240 AssertEqualAfterSimplification("(* (abs (variable 2.0 x)) 2.0)", "(abs (variable 4.0 x))"); // can multiply positive constants into abs 241 AssertEqualAfterSimplification("(* (abs (variable 2.0 x)) -2.0)", "(* (abs (variable 4.0 x)) -1.0)"); // for negative constants keep the sign 242 243 AssertEqualAfterSimplification("(abs (* (variable 1.0 a) (variable 2.0 b)))", "(* (abs (variable 1.0 a)) (abs (variable 1.0 b)) 2.0))"); 244 AssertEqualAfterSimplification("(abs (/ (variable 1.0 a) (variable 2.0 b)))", "(/ (abs (variable 1.0 a)) (abs (variable 2.0 b))))"); 245 #endregion 246 247 #region square and sqrt 248 AssertEqualAfterSimplification("(sqr (sqrt (variable 2.0 x)))", "(variable 2.0 x)"); 249 AssertEqualAfterSimplification("(sqrt (sqr (variable 2.0 x)))", "(variable 2.0 x)"); 250 AssertEqualAfterSimplification("(sqr (abs (variable 2.0 a)))", "(sqr (variable 2.0 a))"); 251 AssertEqualAfterSimplification("(sqr (exp (variable 2.0 x)))", "(exp (variable 4.0 x))"); 252 253 AssertEqualAfterSimplification("(sqr (* (variable 2.0 a) (variable 3.0 b) (variable 4.0 c)))", 254 "(* (sqr (variable 1.0 a)) (sqr (variable 1.0 b)) (sqr (variable 1.0 c)) 576)"); // 2²*3²*4² 255 #endregion 256 257 #region cube and cuberoot 258 AssertEqualAfterSimplification("(cube (cuberoot (variable 2.0 x)))", "(variable 2.0 x)"); 259 AssertEqualAfterSimplification("(cuberoot (cube (variable 2.0 x)))", "(variable 2.0 x)"); 260 AssertEqualAfterSimplification("(cube (exp (variable 2.0 x)))", "(exp (variable 6.0 x))"); 261 262 AssertEqualAfterSimplification("(sqr (cube (variable 2.0 x)))", "(pow (variable 2.0 x) 6)"); 263 AssertEqualAfterSimplification("(cube (sqr (variable 2.0 x)))", "(pow (variable 2.0 x) 6)"); 264 #endregion 265 266 #region AQ 267 AssertEqualAfterSimplification("(* (aq (variable 1.0 x) (variable 1.0 y)) 2.0)", "(aq (variable 2.0 x) (variable 1.0 y))"); 268 AssertEqualAfterSimplification("(/ (aq (variable 1.0 x) (variable 1.0 y)) 2.0)", "(aq (variable 0.5 x) (variable 1.0 y))"); 269 270 #endregion 230 271 } 231 272 -
branches/2965_CancelablePersistence/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r16207 r16433 583 583 <Compile Include="HeuristicLab.Persistence-3.3\UseCases.cs" /> 584 584 <Compile Include="HeuristicLab.PluginInfraStructure-3.3\TypeExtensionsTest.cs" /> 585 <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\ClassificationVariableImpactCalculationTest.cs" /> 586 <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\IntervalTest.cs" /> 587 <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\RegressionVariableImpactCalculationTest.cs" /> 585 588 <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\ThresholdCalculatorsTest.cs" /> 586 589 <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\OnlineCalculatorPerformanceTest.cs" /> 587 590 <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\StatisticCalculatorsTest.cs" /> 588 <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\VariableImpactCalculationTest.cs" />589 591 <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\DeriveTest.cs" /> 590 592 <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\InfixExpressionParserTest.cs" /> 593 <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\IntervalInterpreterTest.cs" /> 591 594 <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs" /> 592 595 <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculatorTest.cs" />
Note: See TracChangeset
for help on using the changeset viewer.