Changeset 17319
- Timestamp:
- 10/04/19 16:56:04 (5 years ago)
- Location:
- branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/IntervalEvaluatorAutoDiffTest.cs
r17318 r17319 151 151 { "y", new Interval(1, 2) }, 152 152 { "z", new Interval(0, 1) }, 153 { "eps", new Interval(1e-10, 1) } 153 154 }; 154 155 var r = eval.Evaluate(t, intervals, paramNodes, out double[] lg, out double[] ug); … … 174 175 Assert.AreEqual(1, r.UpperBound); 175 176 176 Assert.AreEqual(0, lg[0]); // z 177 Assert.AreEqual(0.5 * Math.Sqrt(2), ug[0], 1e-5); 177 Assert.AreEqual(double.NaN, lg[0]); // z 178 Assert.AreEqual(0.5, ug[0], 1e-5); 179 180 t = parser.Parse("sqrt(eps)"); 181 paramNodes = t.IterateNodesPostfix().Where(n => n.SubtreeCount == 0).ToArray(); 182 r = eval.Evaluate(t, intervals, paramNodes, out lg, out ug); 183 184 Assert.AreEqual(0.5 * Math.Sqrt(1e-10), lg[0], 1e-6); // z --> lim x -> 0 (sqrt(x)) = 0 185 Assert.AreEqual(0.5, ug[0], 1e-5); 178 186 } 179 187 … … 207 215 Assert.AreEqual(1.0 / 3.0 * Math.Pow(2, 1.0 / 3.0), ug[0], 1e-5); 208 216 209 t = parser.Parse(" sqrt(z)");217 t = parser.Parse("cuberoot(z)"); 210 218 paramNodes = t.IterateNodesPostfix().Where(n => n.SubtreeCount == 0).ToArray(); 211 219 r = eval.Evaluate(t, intervals, paramNodes, out lg, out ug); … … 213 221 Assert.AreEqual(1.0, r.UpperBound); 214 222 215 Assert.AreEqual( 0.0, lg[0]); // z223 Assert.AreEqual(double.NaN, lg[0]); // z 216 224 Assert.AreEqual(1.0 / 3.0, ug[0], 1e-5); 217 225 } -
branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/IntervalEvaluatorTest.cs
r17318 r17319 210 210 } 211 211 212 [TestMethod] 213 [TestCategory("Problems.DataAnalysis.Symbolic")] 214 [TestProperty("Time", "short")] 215 public void IntervalEvaluatorSqrt() { 216 EvaluateTest("sqrt(x1)", new Interval(0, 1), new Dictionary<string, Interval>() { {"x1", new Interval(0, 1) }}); 217 } 212 218 213 219 … … 219 225 var evaluator = new IntervalEvaluator(); 220 226 var intervals = new Dictionary<string, Interval>() { 221 {"x", new Interval(1, 2) } 227 {"x", new Interval(1, 2) }, 228 {"unit", new Interval(0, 1) }, 222 229 }; 223 230 224 231 var t = parser.Parse("SQR(EXP(CUBE((2.10981074965936*'x'))))"); 225 var r = evaluator.Evaluate(t, intervals); 226 AssertInterval(143638040.396283, 1.81198989971641E+65, r); 232 AssertInterval(143638040.396283, 1.81198989971641E+65, evaluator.Evaluate(t, intervals)); 233 234 235 t = parser.Parse("sqrt(unit)"); 236 AssertInterval(0, 1, evaluator.Evaluate(t, intervals)); 237 227 238 } 228 239
Note: See TracChangeset
for help on using the changeset viewer.