Changeset 17319


Ignore:
Timestamp:
10/04/19 16:56:04 (10 days ago)
Author:
gkronber
Message:

#2994: recheck cbrt() and sqrt() autoDiff tests

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  
    151151        { "y", new Interval(1, 2) },
    152152        { "z", new Interval(0, 1) },
     153        { "eps", new Interval(1e-10, 1) }           
    153154      };
    154155      var r = eval.Evaluate(t, intervals, paramNodes, out double[] lg, out double[] ug);
     
    174175      Assert.AreEqual(1, r.UpperBound);
    175176
    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);
    178186    }
    179187
     
    207215      Assert.AreEqual(1.0 / 3.0 * Math.Pow(2, 1.0 / 3.0), ug[0], 1e-5);
    208216
    209       t = parser.Parse("sqrt(z)");
     217      t = parser.Parse("cuberoot(z)");
    210218      paramNodes = t.IterateNodesPostfix().Where(n => n.SubtreeCount == 0).ToArray();
    211219      r = eval.Evaluate(t, intervals, paramNodes, out lg, out ug);
     
    213221      Assert.AreEqual(1.0, r.UpperBound);
    214222
    215       Assert.AreEqual(0.0, lg[0]); // z
     223      Assert.AreEqual(double.NaN, lg[0]); // z
    216224      Assert.AreEqual(1.0 / 3.0, ug[0], 1e-5);
    217225    }
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/IntervalEvaluatorTest.cs

    r17318 r17319  
    210210    }
    211211
     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    }
    212218
    213219
     
    219225      var evaluator = new IntervalEvaluator();
    220226      var intervals = new Dictionary<string, Interval>() {
    221         {"x", new Interval(1, 2) }
     227        {"x", new Interval(1, 2) },
     228        {"unit", new Interval(0, 1) },
    222229      };
    223230
    224231      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
    227238    }
    228239
Note: See TracChangeset for help on using the changeset viewer.