Index: trunk/sources/HeuristicLab.Functions/BakedTreeEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.Functions/BakedTreeEvaluator.cs	(revision 423)
+++ trunk/sources/HeuristicLab.Functions/BakedTreeEvaluator.cs	(revision 424)
@@ -27,8 +27,10 @@
 using HeuristicLab.Core;
 using System.Xml;
+using System.Diagnostics;
 
 namespace HeuristicLab.Functions {
   internal class BakedTreeEvaluator : IEvaluator {
     private const int MAX_TREE_SIZE = 4096;
+    private const double EPSILON = 1.0e-7;
 
     private class Instr {
@@ -175,12 +177,12 @@
             return Math.Tan(EvaluateBakedCode());
           }
-        case EvaluatorSymbolTable.AND: {
+        case EvaluatorSymbolTable.AND: { // only defined for inputs 1 and 0
             double result = 1.0;
             // have to evaluate all sub-trees, skipping would probably not lead to a big gain because 
             // we have to iterate over the linear structure anyway
             for(int i = 0; i < currInstr.arity; i++) {
-              double x = Math.Round(EvaluateBakedCode());
-              if(x == 0 || x == 1.0) result *= x;
-              else result = double.NaN;
+              double x = EvaluateBakedCode();
+              Debug.Assert(x == 0.0 || x == 1.0);
+              result *= x;
             }
             return result;
@@ -189,5 +191,5 @@
             double x = EvaluateBakedCode();
             double y = EvaluateBakedCode();
-            if(x == y) return 1.0; else return 0.0;
+            if(Math.Abs(x - y) < EPSILON) return 1.0; else return 0.0;
           }
         case EvaluatorSymbolTable.GT: {
@@ -197,11 +199,11 @@
             else return 0.0;
           }
-        case EvaluatorSymbolTable.IFTE: {
-            double condition = Math.Round(EvaluateBakedCode());
-            double x = EvaluateBakedCode();
-            double y = EvaluateBakedCode();
-            if(condition < .5) return x;
-            else if(condition >= .5) return y;
-            else return double.NaN;
+        case EvaluatorSymbolTable.IFTE: { // only defined for condition 0 or 1
+            double condition = EvaluateBakedCode();
+            Debug.Assert(condition == 0.0 || condition == 1.0);
+            double x = EvaluateBakedCode();
+            double y = EvaluateBakedCode();
+            if(condition == 0.0) return x;
+            else return y;
           }
         case EvaluatorSymbolTable.LT: {
@@ -211,27 +213,23 @@
             else return 0.0;
           }
-        case EvaluatorSymbolTable.NOT: {
-            double result = Math.Round(EvaluateBakedCode());
+        case EvaluatorSymbolTable.NOT: { // only defined for inputs 0 or 1
+            double result = EvaluateBakedCode();
+            Debug.Assert(result == 0.0 || result == 1.0);
             if(result == 0.0) return 1.0;
-            else if(result == 1.0) return 0.0;
-            else return double.NaN;
-          }
-        case EvaluatorSymbolTable.OR: {
+            else return 0.0;
+          }
+        case EvaluatorSymbolTable.OR: { // only defined for inputs 0 or 1
             double result = 0.0; // default is false
             for(int i = 0; i < currInstr.arity; i++) {
-              double x = Math.Round(EvaluateBakedCode());
-              if(x == 1.0 && result == 0.0) result = 1.0; // found first true (1.0) => set to true
-              else if(x != 0.0) result = double.NaN; // if it was not true it can only be false (0.0) all other cases are undefined => (NaN)
+              double x = EvaluateBakedCode();
+              Debug.Assert(x == 0.0 || x == 1.0);
+              if(x == 1.0) result = 1.0;
             }
             return result;
           }
-        case EvaluatorSymbolTable.XOR: {
-            double x = Math.Round(EvaluateBakedCode());
-            double y = Math.Round(EvaluateBakedCode());
-            if(x == 0.0 && y == 0.0) return 0.0;
-            if(x == 1.0 && y == 0.0) return 1.0;
-            if(x == 0.0 && y == 1.0) return 1.0;
-            if(x == 1.0 && y == 1.0) return 0.0;
-            return double.NaN;
+        case EvaluatorSymbolTable.XOR: { // only defined for inputs 0 or 1
+            double x = EvaluateBakedCode();
+            double y = EvaluateBakedCode();
+            return Math.Abs(x - y);
           }
         default: {
