Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/13/19 19:05:35 (5 years ago)
Author:
gkronber
Message:

#2994: more test cases to understand specific problems when optimizing with constraints

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/AutoDiffIntervalInterpreterTest.cs

    r17212 r17217  
    4040    }
    4141
    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) {
    4343      var parser = new InfixExpressionParser();
    4444      var tree = parser.Parse(expression);
     
    105105      EvaluateTest("cos(x1+x2)", new Interval(-1, 1));
    106106      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)));
    108108
    109109      var localVarRanges = new Dictionary<string, Interval>();
     
    182182      EvaluateTest("sqr(x)", new Interval(Math.Pow(3, 2), Math.Pow(8, 2)));
    183183    }
     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    }
    184211  }
    185212}
Note: See TracChangeset for help on using the changeset viewer.