Changeset 17217 for branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/AutoDiffIntervalInterpreterTest.cs
- Timestamp:
- 08/13/19 19:05:35 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/AutoDiffIntervalInterpreterTest.cs
r17212 r17217 40 40 } 41 41 42 private void EvaluateTest(string expression, Interval expectedResult, IDictionary<string, Interval> variableRanges = null, double lowerDelta = 0, double upperDelta = 0) {42 private void EvaluateTest(string expression, Interval expectedResult, IDictionary<string, Interval> variableRanges = null, double lowerDelta = 1e-6, double upperDelta = 1e-6) { 43 43 var parser = new InfixExpressionParser(); 44 44 var tree = parser.Parse(expression); … … 105 105 EvaluateTest("cos(x1+x2)", new Interval(-1, 1)); 106 106 EvaluateTest("cos(x1+x2)", new Interval(-1, 1), variableRanges); 107 EvaluateTest("cos(1+2)", new Interval(Math. Sin(3 + Math.PI / 2), Math.Sin(3 + Math.PI / 2)));107 EvaluateTest("cos(1+2)", new Interval(Math.Cos(3), Math.Cos(3))); 108 108 109 109 var localVarRanges = new Dictionary<string, Interval>(); … … 182 182 EvaluateTest("sqr(x)", new Interval(Math.Pow(3, 2), Math.Pow(8, 2))); 183 183 } 184 185 186 187 [TestMethod] 188 [TestCategory("Problems.DataAnalysis")] 189 [TestProperty("Time", "short")] 190 public void TestDivisionAndSqr() { 191 Dictionary<string, Interval> dataIntervals = new Dictionary<string, Interval>() { 192 {"R", new Interval(0.2, 0.5) }, 193 {"r", new Interval(0.5, 0.8) }, 194 }; 195 196 EvaluateTest("R*R", new Interval(0.2 * 0.2, 0.5 * 0.5), dataIntervals); 197 EvaluateTest("sqr(R)", new Interval(0.2 * 0.2, 0.5 * 0.5), dataIntervals); 198 199 EvaluateTest("r*r", new Interval(0.5 * 0.5, 0.8 * 0.8), dataIntervals); 200 EvaluateTest("sqr(r)", new Interval(0.5 * 0.5, 0.8 * 0.8), dataIntervals); 201 202 EvaluateTest("R/r", new Interval(0.2 / 0.8, 0.5 / 0.5), dataIntervals); 203 204 EvaluateTest("R/(r*r)", new Interval(0.2 / (0.8 * 0.8), 0.5 / (0.5 * 0.5)), dataIntervals); 205 EvaluateTest("R/sqr(r)", new Interval(0.2 / (0.8 * 0.8), 0.5 / (0.5 * 0.5)), dataIntervals); 206 207 EvaluateTest("R*R/sqr(r)", new Interval(0.2 * 0.2 / (0.8 * 0.8), 0.5 * 0.5 / (0.5 * 0.5)), dataIntervals); 208 EvaluateTest("sqr(R)/sqr(r)", new Interval(0.2 * 0.2 / (0.8 * 0.8), 0.5 * 0.5 / (0.5 * 0.5)), dataIntervals); 209 EvaluateTest("sqr(R/r)", new Interval(0.2 * 0.2 / (0.8 * 0.8), 0.5 * 0.5 / (0.5 * 0.5)), dataIntervals); 210 } 184 211 } 185 212 }
Note: See TracChangeset
for help on using the changeset viewer.