Index: /trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HL3TreeEvaluator.cs
===================================================================
--- /trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HL3TreeEvaluator.cs	(revision 2225)
+++ /trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HL3TreeEvaluator.cs	(revision 2226)
@@ -22,4 +22,5 @@
 using System;
 using System.Diagnostics;
+using HeuristicLab.Modeling; // double.IsAlmost extension
 
 namespace HeuristicLab.GP.StructureIdentification {
@@ -29,6 +30,4 @@
   /// </summary>
   public class HL3TreeEvaluator : TreeEvaluatorBase {
-
-
     protected override double EvaluateBakedCode() {
       Instr currInstr = codeArr[PC++];
@@ -36,5 +35,5 @@
         case EvaluatorSymbolTable.VARIABLE: {
             int row = sampleIndex + currInstr.i_arg1;
-            if (row < 0 || row >= dataset.Rows) return double.NaN;
+            if (row < 0 || row >= dataset.Rows) throw new InvalidOperationException("Out of range access to dataset row: " + row);
             else return currInstr.d_arg0 * dataset.GetValue(row, currInstr.i_arg0);
           }
@@ -44,5 +43,5 @@
         case EvaluatorSymbolTable.DIFFERENTIAL: {
             int row = sampleIndex + currInstr.i_arg1;
-            if (row < 0 || row >= dataset.Rows) return double.NaN;
+            if (row < 0 || row >= dataset.Rows) throw new InvalidOperationException("Out of range access to dataset row: " + row);
             else if (row < 1) return 0.0;
             else {
@@ -117,19 +116,18 @@
             return Math.Tan(EvaluateBakedCode());
           }
-        case EvaluatorSymbolTable.AND: { // only defined for inputs 1 and 0
+        case EvaluatorSymbolTable.AND: {
             double result = EvaluateBakedCode();
             for (int i = 1; i < currInstr.arity; i++) {
-              if (result == 0.0) SkipBakedCode();
+              if (result < 0.0) SkipBakedCode();
               else {
                 result = EvaluateBakedCode();
               }
-              Debug.Assert(result == 0.0 || result == 1.0);
             }
-            return result;
+            return Math.Sign(result);
           }
         case EvaluatorSymbolTable.EQU: {
             double x = EvaluateBakedCode();
             double y = EvaluateBakedCode();
-            if (Math.Abs(x - y) < EPSILON) return 1.0; else return 0.0;
+            if (x.IsAlmost(y)) return 1.0; else return -1.0;
           }
         case EvaluatorSymbolTable.GT: {
@@ -137,11 +135,10 @@
             double y = EvaluateBakedCode();
             if (x > y) return 1.0;
-            else return 0.0;
+            else return -1.0;
           }
-        case EvaluatorSymbolTable.IFTE: { // only defined for condition 0 or 1
+        case EvaluatorSymbolTable.IFTE: {
             double condition = EvaluateBakedCode();
-            Debug.Assert(condition == 0.0 || condition == 1.0);
             double result;
-            if (condition == 0.0) {
+            if (condition < 0.0) {
               result = EvaluateBakedCode(); SkipBakedCode();
             } else {
@@ -154,26 +151,30 @@
             double y = EvaluateBakedCode();
             if (x < y) return 1.0;
-            else return 0.0;
+            else return -1.0;
           }
-        case EvaluatorSymbolTable.NOT: { // only defined for inputs 0 or 1
-            double result = EvaluateBakedCode();
-            Debug.Assert(result == 0.0 || result == 1.0);
-            return Math.Abs(result - 1.0);
+        case EvaluatorSymbolTable.NOT: {
+            return -EvaluateBakedCode();
           }
-        case EvaluatorSymbolTable.OR: { // only defined for inputs 0 or 1
+        case EvaluatorSymbolTable.OR: {
             double result = EvaluateBakedCode();
             for (int i = 1; i < currInstr.arity; i++) {
-              if (result > 0.0) SkipBakedCode();
+              if (result >= 0.0) SkipBakedCode();
               else {
                 result = EvaluateBakedCode();
-                Debug.Assert(result == 0.0 || result == 1.0);
               }
             }
-            return result;
+            return Math.Sign(result);
           }
-        case EvaluatorSymbolTable.XOR: { // only defined for inputs 0 or 1
+        case EvaluatorSymbolTable.XOR: {
             double x = EvaluateBakedCode();
             double y = EvaluateBakedCode();
-            return Math.Abs(x - y);
+            if (x > y) {
+              double tmp = x;
+              x = y;
+              y = tmp;
+            }
+            // invariant y >= x 
+            if (y < 0.0 || x > 0.0) return -1.0;
+            else return 1.0;
           }
         default: {
Index: /trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs
===================================================================
--- /trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs	(revision 2225)
+++ /trunk/sources/HeuristicLab.LinearRegression/3.2/LinearRegressionOperator.cs	(revision 2226)
@@ -26,4 +26,5 @@
 using HeuristicLab.Data;
 using HeuristicLab.DataAnalysis;
+using HeuristicLab.Modeling;
 using HeuristicLab.GP;
 using HeuristicLab.GP.StructureIdentification;
@@ -54,11 +55,7 @@
       double[] coefficients = CalculateCoefficients(inputMatrix, targetVector);
       IFunctionTree tree = CreateModel(coefficients, allowedColumns.Select(i => dataset.GetVariableName(i)).ToList());
-      
+
       scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("LinearRegressionModel"), new GeneticProgrammingModel(tree)));
       return null;
-    }
-
-    private bool IsAlmost(double x, double y) {
-      return Math.Abs(x - y) < 1.0E-12;
     }
 
@@ -125,6 +122,6 @@
       for (int i = 0; i < dataset.Columns; i++) {
         if (i == targetVariable) continue;
-        if (!IsAlmost(dataset.GetMinimum(i, start, end), 0.0) ||
-            !IsAlmost(dataset.GetMaximum(i, start, end), 0.0))
+        if (!dataset.GetMinimum(i, start, end).IsAlmost(0.0) ||
+            !dataset.GetMaximum(i, start, end).IsAlmost(0.0))
           allowedColumns.Add(i);
       }
Index: /trunk/sources/HeuristicLab.Modeling/3.2/DoubleExtensions.cs
===================================================================
--- /trunk/sources/HeuristicLab.Modeling/3.2/DoubleExtensions.cs	(revision 2226)
+++ /trunk/sources/HeuristicLab.Modeling/3.2/DoubleExtensions.cs	(revision 2226)
@@ -0,0 +1,29 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+namespace HeuristicLab.Modeling {
+  public static class DoubleExtensions {
+    public static bool IsAlmost(this double x, double y) {
+      return Math.Abs(x - y) < 1.0E-12;
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj	(revision 2225)
+++ /trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj	(revision 2226)
@@ -83,4 +83,5 @@
   <ItemGroup>
     <Compile Include="ClassificationProblemInjector.cs" />
+    <Compile Include="DoubleExtensions.cs" />
     <Compile Include="VariableImpactCalculatorBase.cs" />
     <Compile Include="VariableEvaluationImpactCalculator.cs" />
Index: /trunk/sources/HeuristicLab.Modeling/3.2/SimpleEvaluatorBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Modeling/3.2/SimpleEvaluatorBase.cs	(revision 2225)
+++ /trunk/sources/HeuristicLab.Modeling/3.2/SimpleEvaluatorBase.cs	(revision 2226)
@@ -31,8 +31,4 @@
 
     public abstract double Evaluate(double[,] values);
-
-    protected static bool IsAlmost(double x, double y) {
-      return Math.Abs(x - y) < 1.0E-12;
-    }
   }
 }
Index: /trunk/sources/HeuristicLab.Modeling/3.2/SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Modeling/3.2/SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.cs	(revision 2225)
+++ /trunk/sources/HeuristicLab.Modeling/3.2/SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.cs	(revision 2226)
@@ -53,5 +53,5 @@
       double range = Statistics.Range(originalValues);
       if (double.IsInfinity(range)) throw new ArgumentException("Range of elements in values is infinity");
-      if (IsAlmost(range, 0.0)) throw new ArgumentException("Range of elements in values is zero");
+      if (range.IsAlmost(0.0)) throw new ArgumentException("Range of elements in values is zero");
 
       for (int i = 0; i < values.GetLength(0); i++) {
Index: /trunk/sources/HeuristicLab.Modeling/3.2/SimpleVarianceAccountedForEvaluator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Modeling/3.2/SimpleVarianceAccountedForEvaluator.cs	(revision 2225)
+++ /trunk/sources/HeuristicLab.Modeling/3.2/SimpleVarianceAccountedForEvaluator.cs	(revision 2226)
@@ -69,6 +69,6 @@
       double errorsVariance = Statistics.Variance(errors);
       double originalsVariance = Statistics.Variance(originalTargetVariableValues);
-      if (IsAlmost(originalsVariance, 0.0))
-        if (IsAlmost(errorsVariance, 0.0)) {
+      if (originalsVariance.IsAlmost(0.0))
+        if (errorsVariance.IsAlmost(0.0)) {
           return 1.0;
         } else {
Index: /trunk/sources/HeuristicLab.Modeling/3.2/VariableEvaluationImpactCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Modeling/3.2/VariableEvaluationImpactCalculator.cs	(revision 2225)
+++ /trunk/sources/HeuristicLab.Modeling/3.2/VariableEvaluationImpactCalculator.cs	(revision 2226)
@@ -64,5 +64,5 @@
     protected override double[] PostProcessImpacts(double[] impacts) {
       double mseSum = impacts.Sum();
-      if (IsAlmost(mseSum, 0.0)) mseSum = 1.0;
+      if (mseSum.IsAlmost(0.0)) mseSum = 1.0;
       for (int i = 0; i < impacts.Length; i++) {
         impacts[i] = impacts[i] / mseSum;
