Index: /branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/IntervalCalculationComparison.cs
===================================================================
--- /branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/IntervalCalculationComparison.cs	(revision 17291)
+++ /branches/2994-AutoDiffForIntervals/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis-3.4/IntervalCalculationComparison.cs	(revision 17291)
@@ -0,0 +1,88 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Random;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  [TestClass]
+  public class IntervalCalculationComparison {
+    [TestMethod]
+    [TestCategory("Problems.DataAnalysis")]
+    [TestProperty("Time", "short")]
+    public void TestIntervalCalculationForRandomExpressions() {
+      var grammar = new TypeCoherentExpressionGrammar();
+      grammar.ConfigureAsDefaultRegressionGrammar();
+      // activate supported symbols
+      grammar.Symbols.First(s => s is Square).Enabled = true;
+      grammar.Symbols.First(s => s is SquareRoot).Enabled = true;
+      grammar.Symbols.First(s => s is Cube).Enabled = true;
+      grammar.Symbols.First(s => s is CubeRoot).Enabled = true;
+
+      var varSy = (Variable)grammar.Symbols.First(s => s is Variable);
+      varSy.AllVariableNames = new string[] { "x", "y" };
+      varSy.VariableNames = varSy.AllVariableNames;
+      varSy.WeightMu = 1.0;
+      varSy.WeightSigma = 1.0;
+      var rand = new FastRandom(1234);
+      var eval1 = new IntervalEvaluator();
+      var eval2 = new IntervalInterpreter();
+
+      IDictionary<string, Interval> posIntervals = new Dictionary<string, Interval>() {
+        { "x", new Interval(1, 2) },
+        { "y", new Interval(0, 1) }
+      };
+      IDictionary<string, Interval> negIntervals = new Dictionary<string, Interval>() {
+        { "x", new Interval(-2, -1) },
+        { "y", new Interval(-1, 0) }
+      };
+      IDictionary<string, Interval> fullIntervals = new Dictionary<string, Interval>() {
+        { "x", new Interval(-2, 2) },
+        { "y", new Interval(-1, 1) }
+      };
+      IDictionary<string, Interval> specialIntervals = new Dictionary<string, Interval>() {
+        { "x", new Interval(1, double.PositiveInfinity) },
+        { "y", new Interval(double.NegativeInfinity, double.PositiveInfinity) }
+      };
+
+      var formatter = new InfixExpressionFormatter();
+      foreach (var interval in new[] { posIntervals, negIntervals, fullIntervals, specialIntervals }) {
+        int N = 10000;
+        var sb = new StringBuilder();
+        int i = 0;
+        while (i < N) {
+          var t = ProbabilisticTreeCreator.Create(rand, grammar, maxTreeLength: 5, maxTreeDepth: 5);
+          var r1 = eval1.Evaluate(t, interval);
+          var r2 = eval2.GetSymbolicExpressionTreeInterval(t, interval);
+          // Console.WriteLine(formatter.Format(t));
+
+          if (double.IsNaN(r1.LowerBound) && double.IsNaN(r2.LowerBound) && double.IsNaN(r1.UpperBound) && double.IsNaN(r2.UpperBound)) continue;
+
+          if (!double.IsNaN(r1.LowerBound) && !double.IsNaN(r2.LowerBound))
+            if ((double.IsPositiveInfinity(r1.LowerBound) && !double.IsPositiveInfinity(r2.LowerBound)) ||
+              (double.IsNegativeInfinity(r1.LowerBound) && !double.IsNegativeInfinity(r2.LowerBound)) ||
+               (Math.Abs(r1.LowerBound - r2.LowerBound) > Math.Abs(r1.LowerBound * 1e-4))
+              ) {
+              sb.AppendLine($"{r1} <> {r2} for {formatter.Format(t)} x={interval["x"]} y={interval["y"]}");
+            }
+          if (!double.IsNaN(r1.UpperBound) && !double.IsNaN(r2.UpperBound))
+            if ((double.IsPositiveInfinity(r1.UpperBound) && !double.IsPositiveInfinity(r2.UpperBound)) ||
+              (double.IsNegativeInfinity(r1.UpperBound) && !double.IsNegativeInfinity(r2.UpperBound)) ||
+               (Math.Abs(r1.UpperBound - r2.UpperBound) > Math.Abs(r1.UpperBound * 1e-4))
+              ) {
+              sb.AppendLine($"{r1} <> {r2} for {formatter.Format(t)} x={interval["x"]} y={interval["y"]}");
+            }
+          i++;
+        }
+        if (sb.Length > 0) {
+          Console.WriteLine(sb.ToString());
+          Assert.Fail("There were different interval calculation results");
+        }
+      }
+    }
+  }
+}
