Index: trunk/sources/HeuristicLab.StructureIdentification/Manipulation/ChangeNodeTypeManipulation.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Manipulation/ChangeNodeTypeManipulation.cs	(revision 237)
+++ trunk/sources/HeuristicLab.StructureIdentification/Manipulation/ChangeNodeTypeManipulation.cs	(revision 238)
@@ -30,4 +30,5 @@
 using HeuristicLab.Constraints;
 using HeuristicLab.Functions;
+using System.Diagnostics;
 
 namespace HeuristicLab.StructureIdentification {
@@ -85,5 +86,5 @@
           // updating the variable is not necessary because it stays the same
         }
-        if(!gardener.IsValidTree(root)) throw new InvalidProgramException();
+        Debug.Assert(gardener.IsValidTree(root));
         // size and height stays the same when changing a terminal so no need to update the variables
         // schedule an operation to initialize the new terminal
@@ -119,6 +120,5 @@
         treeHeight.Data = gardener.GetTreeHeight(root); // must recalculate height because we can't know wether the manipulated branch was the deepest branch
         // check if whole tree is ok
-        if(!gardener.IsValidTree(root))
-          throw new InvalidProgramException();
+        Debug.Assert(gardener.IsValidTree(root));
         // return a composite operation that initializes all created sub-trees
         return gardener.CreateInitializationOperation(uninitializedBranches, scope);
Index: trunk/sources/HeuristicLab.StructureIdentification/Manipulation/CutOutNodeManipulation.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Manipulation/CutOutNodeManipulation.cs	(revision 237)
+++ trunk/sources/HeuristicLab.StructureIdentification/Manipulation/CutOutNodeManipulation.cs	(revision 238)
@@ -28,4 +28,5 @@
 using System;
 using HeuristicLab.Functions;
+using System.Diagnostics;
 
 namespace HeuristicLab.StructureIdentification {
@@ -77,7 +78,5 @@
           // update the variable
           scope.GetVariable(scope.TranslateName("FunctionTree")).Value = root;
-          if (!gardener.IsValidTree(root)) {
-            throw new InvalidProgramException();
-          }
+          Debug.Assert(gardener.IsValidTree(root));
           // we reused a sub-tree so we don't have to schedule initialization operations
           return null;
@@ -90,7 +89,5 @@
           // update the variable
           scope.GetVariable(scope.TranslateName("FunctionTree")).Value = newTree;
-          if (!gardener.IsValidTree(newTree)) {
-            throw new InvalidProgramException();
-          }
+          Debug.Assert(gardener.IsValidTree(newTree));
           // schedule an operation to initialize the whole tree
           return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(newTree), scope);
@@ -108,7 +105,5 @@
         parent.RemoveSubTree(childIndex);
         parent.InsertSubTree(childIndex, selectedChild);
-        if (!gardener.IsValidTree(root)) {
-          throw new InvalidProgramException();
-        }
+        Debug.Assert(gardener.IsValidTree(root));
         // update the size and height of our tree
         GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);
@@ -129,7 +124,5 @@
         GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);
         GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(root);
-        if (!gardener.IsValidTree(root)) {
-          throw new InvalidProgramException();
-        }
+        Debug.Assert(gardener.IsValidTree(root));
         // schedule an initialization operation for the new function-tree
         return gardener.CreateInitializationOperation(gardener.GetAllSubTrees(newFunctionTree), scope);
Index: trunk/sources/HeuristicLab.StructureIdentification/Manipulation/DeleteSubTreeManipulation.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Manipulation/DeleteSubTreeManipulation.cs	(revision 237)
+++ trunk/sources/HeuristicLab.StructureIdentification/Manipulation/DeleteSubTreeManipulation.cs	(revision 238)
@@ -27,4 +27,5 @@
 using HeuristicLab.Random;
 using HeuristicLab.Functions;
+using System.Diagnostics;
 
 namespace HeuristicLab.StructureIdentification {
@@ -61,7 +62,5 @@
         IFunctionTree newTree = gardener.CreateBalancedRandomTree(1, 1);
         // check if the tree is ok
-        if(!gardener.IsValidTree(newTree)) {
-          throw new InvalidOperationException();
-        }
+        Debug.Assert(gardener.IsValidTree(newTree));
         // update sizes to match the new tree
         GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(newTree);
@@ -86,7 +85,5 @@
         // and find the first one that doesn't fit. At this position we insert a new randomly initialized subtree of matching type (gkronber 25.12.07)
 
-        if(!gardener.IsValidTree(root)) {
-          throw new InvalidOperationException();
-        }
+        Debug.Assert(gardener.IsValidTree(root));
         GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);
         GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(root);
@@ -99,7 +96,5 @@
         IFunctionTree newFunctionTree = gardener.CreateRandomTree(allowedFunctions, 1, 1);
         parent.InsertSubTree(childIndex, newFunctionTree);
-        if(!gardener.IsValidTree(root)) {
-          throw new InvalidProgramException();
-        }
+        Debug.Assert(gardener.IsValidTree(root));
         GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);
         GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(root);
Index: trunk/sources/HeuristicLab.StructureIdentification/Manipulation/SubstituteSubTreeManipulation.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Manipulation/SubstituteSubTreeManipulation.cs	(revision 237)
+++ trunk/sources/HeuristicLab.StructureIdentification/Manipulation/SubstituteSubTreeManipulation.cs	(revision 238)
@@ -28,4 +28,5 @@
 using HeuristicLab.Random;
 using HeuristicLab.Functions;
+using System.Diagnostics;
 
 namespace HeuristicLab.StructureIdentification {
@@ -61,7 +62,5 @@
         // => create a new random tree
         IFunctionTree newTree = gardener.CreateRandomTree(gardener.AllFunctions, maxTreeSize, maxTreeHeight);
-        if(!gardener.IsValidTree(newTree)) {
-          throw new InvalidProgramException();
-        }
+        Debug.Assert(gardener.IsValidTree(newTree));
 
         // update the variables in the scope with the new values
@@ -94,8 +93,5 @@
         parent.InsertSubTree(childIndex, newTree);
 
-        if(!gardener.IsValidTree(root)) {
-          throw new InvalidProgramException();
-        }
-
+        Debug.Assert(gardener.IsValidTree(root));
         // update the values of treeSize and treeHeight
         GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);
Index: trunk/sources/HeuristicLab.StructureIdentification/Recombination/SizeFairCrossOver.cs
===================================================================
--- trunk/sources/HeuristicLab.StructureIdentification/Recombination/SizeFairCrossOver.cs	(revision 237)
+++ trunk/sources/HeuristicLab.StructureIdentification/Recombination/SizeFairCrossOver.cs	(revision 238)
@@ -30,4 +30,5 @@
 using HeuristicLab.Constraints;
 using HeuristicLab.Functions;
+using System.Diagnostics;
 
 namespace HeuristicLab.StructureIdentification {
@@ -95,9 +96,6 @@
 
       // check if the new tree is valid and if the size of is still in the allowed bounds
-      if(!gardener.IsValidTree(newTree) ||
-        newTreeHeight > maxTreeHeight ||
-        newTreeSize > maxTreeSize) {
-        throw new InvalidProgramException();
-      }
+      Debug.Assert(gardener.IsValidTree(newTree) &&
+        newTreeHeight <= maxTreeHeight && newTreeSize <= maxTreeSize);
       return gardener.CreateInitializationOperation(newBranches, child);
     }
@@ -165,5 +163,5 @@
           //  - go down in tree1 => the tree that is inserted becomes smaller
           //  - however we have to get lucky to solve the 'allowed sub-trees' problem
-          if(tree1Height == 1 || (tree0Level>0 && random.Next(2) == 0)) {
+          if(tree1Height == 1 || (tree0Level > 0 && random.Next(2) == 0)) {
             // go up in tree0 
             tree0Level--;
