Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarEditorView.cs	(revision 6387)
@@ -178,5 +178,5 @@
       VisualSymbolicExpressionTreeNode clickedNode = (VisualSymbolicExpressionTreeNode)sender;
       var selectedNode = clickedNode.SymbolicExpressionTreeNode;
-      if (selectedNode.SubtreesCount == 0) {
+      if (selectedNode.SubtreeCount == 0) {
         if (!selectedSymbolicExpressionTreeNodes.Contains(selectedNode))
           selectedSymbolicExpressionTreeNodes.Add(selectedNode);
@@ -349,4 +349,14 @@
   [NonDiscoverableType]
   internal class DummySymbol : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     public DummySymbol(DummySymbol original, Cloner cloner) : base(original, cloner) { }
     public DummySymbol(string name) : base(name, "DummySymbol for views") { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs	(revision 6387)
@@ -262,5 +262,5 @@
 
       //draw terminal node
-      if (node.SubtreesCount == 0) {
+      if (node.SubtreeCount == 0) {
         graphics.FillRectangle(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
         graphics.DrawRectangle(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
@@ -280,7 +280,7 @@
       //calculate areas for the subtrees according to their tree size and call drawFunctionTree
       Point connectFrom = new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y + visualTreeNode.Height);
-      int[] xBoundaries = new int[node.SubtreesCount + 1];
+      int[] xBoundaries = new int[node.SubtreeCount + 1];
       xBoundaries[0] = x;
-      for (int i = 0; i < node.SubtreesCount; i++) {
+      for (int i = 0; i < node.SubtreeCount; i++) {
         xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.GetSubtree(i).GetLength()) / (node.GetLength() - 1));
         DrawFunctionTree(node.GetSubtree(i), graphics, xBoundaries[i], y + height,
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionSymbolFrequencyAnalyzer.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionSymbolFrequencyAnalyzer.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionSymbolFrequencyAnalyzer.cs	(revision 6387)
@@ -126,5 +126,5 @@
           string symbolName;
           if (aggregateDifferentNumberOfSubtrees) symbolName = node.Symbol.Name;
-          else symbolName = node.Symbol.Name + "-" + node.SubtreesCount;
+          else symbolName = node.Symbol.Name + "-" + node.SubtreeCount;
           if (symbolFrequencies.ContainsKey(symbolName)) symbolFrequencies[symbolName] += 1;
           else symbolFrequencies.Add(symbolName, 1);
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Compiler/SymbolicExpressionTreeCompiler.cs	(revision 6387)
@@ -62,5 +62,5 @@
       foreach (var node in branch.IterateNodesPrefix()) {
         Instruction instr = new Instruction();
-        int subtreesCount = node.SubtreesCount;
+        int subtreesCount = node.SubtreeCount;
         if (subtreesCount > 255) throw new ArgumentException("Number of subtrees is too big (>255)");
         instr.nArguments = (byte)subtreesCount;
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs	(revision 6387)
@@ -133,6 +133,6 @@
       if (newChild == null) {
         // make sure that one subtree can be removed and that only the last subtree is removed 
-        return parent.Grammar.GetMinimumSubtreeCount(parent.Symbol) < parent.SubtreesCount &&
-          cutPoint.ChildIndex == parent.SubtreesCount - 1;
+        return parent.Grammar.GetMinimumSubtreeCount(parent.Symbol) < parent.SubtreeCount &&
+          cutPoint.ChildIndex == parent.SubtreeCount - 1;
       } else {
         // check syntax constraints of direct parent - child relation
@@ -146,6 +146,6 @@
             result &&
             parent.Grammar.ContainsSymbol(n.Symbol) &&
-            n.SubtreesCount >= parent.Grammar.GetMinimumSubtreeCount(n.Symbol) &&
-            n.SubtreesCount <= parent.Grammar.GetMaximumSubtreeCount(n.Symbol);
+            n.SubtreeCount >= parent.Grammar.GetMinimumSubtreeCount(n.Symbol) &&
+            n.SubtreeCount <= parent.Grammar.GetMaximumSubtreeCount(n.Symbol);
         });
         return result;
@@ -169,7 +169,7 @@
           }
           // add one additional extension point if the number of sub trees for the symbol is not full
-          if (n.SubtreesCount < n.Grammar.GetMaximumSubtreeCount(n.Symbol)) {
+          if (n.SubtreeCount < n.Grammar.GetMaximumSubtreeCount(n.Symbol)) {
             // empty extension point
-            internalCrossoverPoints.Add(new CutPoint(n, n.SubtreesCount));
+            internalCrossoverPoints.Add(new CutPoint(n, n.SubtreeCount));
           }
         }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbol.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbol.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbol.cs	(revision 6387)
@@ -30,4 +30,7 @@
     bool Fixed { get; set; }
 
+    int MinimumArity { get; }
+    int MaximumArity { get; }
+
     event EventHandler Changed;
   }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs	(revision 6387)
@@ -39,5 +39,5 @@
 
     IEnumerable<ISymbolicExpressionTreeNode> Subtrees { get; }
-    int SubtreesCount { get; }
+    int SubtreeCount { get; }
     ISymbolicExpressionTreeNode GetSubtree(int index);
     int IndexOfSubtree(ISymbolicExpressionTreeNode tree);
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs	(revision 6387)
@@ -143,5 +143,5 @@
     private void AddSymbolToDictionaries(ISymbol symbol) {
       symbols.Add(symbol.Name, symbol);
-      symbolSubtreeCount.Add(symbol.Name, Tuple.Create(0, 0));
+      symbolSubtreeCount.Add(symbol.Name, Tuple.Create(symbol.MinimumArity, symbol.MaximumArity));
       RegisterSymbolEvents(symbol);
     }
@@ -315,9 +315,15 @@
     protected void SetSubtreeCount(ISymbol symbol, int minimumSubtreeCount, int maximumSubtreeCount) {
       var groupSymbol = symbol as GroupSymbol;
-      if (groupSymbol != null)
-        foreach (ISymbol s in groupSymbol.Flatten().Where(s => !(s is GroupSymbol)))
+      if (groupSymbol != null) {
+        var symbols = groupSymbol.Flatten().Where(s => !(s is GroupSymbol));
+        if (symbols.Any(s => s.MinimumArity > minimumSubtreeCount)) throw new ArgumentException("Invalid minimum subtree count " + minimumSubtreeCount + " for " + symbol);
+        if (symbols.Any(s => s.MaximumArity < maximumSubtreeCount)) throw new ArgumentException("Invalid minimum subtree count " + minimumSubtreeCount + " for " + symbol);
+        foreach (ISymbol s in symbols)
           SetSubTreeCountInDictionaries(s, minimumSubtreeCount, maximumSubtreeCount);
-      else
+      } else {
+        if (symbol.MinimumArity > minimumSubtreeCount) throw new ArgumentException("Invalid minimum subtree count " + minimumSubtreeCount + " for " + symbol);
+        if (symbol.MaximumArity < maximumSubtreeCount) throw new ArgumentException("Invalid minimum subtree count " + minimumSubtreeCount + " for " + symbol);
         SetSubTreeCountInDictionaries(symbol, minimumSubtreeCount, maximumSubtreeCount);
+      }
 
       ClearCaches();
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs	(revision 6387)
@@ -126,5 +126,5 @@
     public virtual void ShakeLocalParameters(IRandom random, double shakingFactor) { }
 
-    public int SubtreesCount {
+    public int SubtreeCount {
       get {
         if (subtrees == null) return 0;
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Argument.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Argument.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Argument.cs	(revision 6387)
@@ -32,4 +32,14 @@
     public const string ArgumentName = "Argument";
     public const string ArgumentDescription = "Symbol that represents a function argument.";
+    private const int minimumArity = 0;
+    private const int maximumArity = 0;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [Storable]
     private int argumentIndex;
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Defun.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Defun.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Defun.cs	(revision 6387)
@@ -32,4 +32,13 @@
     public const string DefunName = "Defun";
     public const string DefunDescription = "Symbol that represents a function defining node.";
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
 
     [StorableConstructor]
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/GroupSymbol.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/GroupSymbol.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/GroupSymbol.cs	(revision 6387)
@@ -28,4 +28,14 @@
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
   public sealed class GroupSymbol : Symbol {
+    private const int minimumArity = 0;
+    private const int maximumArity = 0;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     private ObservableSet<ISymbol> symbols;
     public IObservableSet<ISymbol> SymbolsCollection {
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunction.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunction.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunction.cs	(revision 6387)
@@ -32,4 +32,13 @@
     public const string InvokeFunctionName = "InvokeFunction";
     public const string InvokeFunctionDescription = "Symbol that the invocation of another function.";
+    private const int minimumArity = 0;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
 
     [Storable]
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/ProgramRootSymbol.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/ProgramRootSymbol.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/ProgramRootSymbol.cs	(revision 6387)
@@ -29,4 +29,13 @@
     public const string ProgramRootSymbolName = "ProgramRootSymbol";
     public const string ProgramRootSymbolDescription = "Special symbol that represents the program root node of a symbolic expression tree.";
+    private const int minimumArity = 1;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
 
     [StorableConstructor]
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/StartSymbol.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/StartSymbol.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/StartSymbol.cs	(revision 6387)
@@ -29,7 +29,18 @@
     public const string StartSymbolName = "StartSymbol";
     public const string StartSymbolDescription = "Special symbol that represents the starting node of the result producing branch of a symbolic expression tree.";
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
 
     [StorableConstructor]
-    private StartSymbol(bool deserializing) : base(deserializing) { }
+    private StartSymbol(bool deserializing)
+      : base(deserializing) {
+    }
     private StartSymbol(StartSymbol original, Cloner cloner) : base(original, cloner) { }
     public StartSymbol() : base(StartSymbol.StartSymbolName, StartSymbol.StartSymbolDescription) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Symbol.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Symbol.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Symbol.cs	(revision 6387)
@@ -73,4 +73,7 @@
       get { return false; }
     }
+
+    public abstract int MinimumArity { get; }
+    public abstract int MaximumArity { get; }
     #endregion
 
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs	(revision 6387)
@@ -27,7 +27,16 @@
 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
   public static class Grammars {
-
     [StorableClass]
     private class Addition : Symbol {
+      private const int minimumArity = 1;
+      private const int maximumArity = byte.MaxValue;
+
+      public override int MinimumArity {
+        get { return minimumArity; }
+      }
+      public override int MaximumArity {
+        get { return maximumArity; }
+      }
+
       [StorableConstructor]
       protected Addition(bool deserializing) : base(deserializing) { }
@@ -41,4 +50,14 @@
     [StorableClass]
     private class Subtraction : Symbol {
+      private const int minimumArity = 1;
+      private const int maximumArity = byte.MaxValue;
+
+      public override int MinimumArity {
+        get { return minimumArity; }
+      }
+      public override int MaximumArity {
+        get { return maximumArity; }
+      }
+
       [StorableConstructor]
       protected Subtraction(bool deserializing) : base(deserializing) { }
@@ -52,4 +71,14 @@
     [StorableClass]
     private class Multiplication : Symbol {
+      private const int minimumArity = 1;
+      private const int maximumArity = byte.MaxValue;
+
+      public override int MinimumArity {
+        get { return minimumArity; }
+      }
+      public override int MaximumArity {
+        get { return maximumArity; }
+      }
+
       [StorableConstructor]
       protected Multiplication(bool deserializing) : base(deserializing) { }
@@ -63,4 +92,14 @@
     [StorableClass]
     private class Division : Symbol {
+      private const int minimumArity = 1;
+      private const int maximumArity = byte.MaxValue;
+
+      public override int MinimumArity {
+        get { return minimumArity; }
+      }
+      public override int MaximumArity {
+        get { return maximumArity; }
+      }
+
       [StorableConstructor]
       protected Division(bool deserializing) : base(deserializing) { }
@@ -74,4 +113,14 @@
     [StorableClass]
     private class Terminal : Symbol {
+      private const int minimumArity = 0;
+      private const int maximumArity = 0;
+
+      public override int MinimumArity {
+        get { return minimumArity; }
+      }
+      public override int MaximumArity {
+        get { return maximumArity; }
+      }
+
       [StorableConstructor]
       protected Terminal(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Util.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Util.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Util.cs	(revision 6387)
@@ -122,5 +122,5 @@
 
         foreach (var argTreenode in defunTreeNode.IterateNodesPrefix().OfType<ArgumentTreeNode>()) {
-          Assert.IsTrue(argTreenode.SubtreesCount == 0);
+          Assert.IsTrue(argTreenode.SubtreeCount == 0);
           Assert.IsTrue(((Argument)argTreenode.Symbol).ArgumentIndex < arity);
         }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/IfFoodAhead.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/IfFoodAhead.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/IfFoodAhead.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("IfFoodAhead", "Represents the if-food-ahead symbol in a artificial ant expression.")]
   public sealed class IfFoodAhead : Symbol {
+    private const int minimumArity = 2;
+    private const int maximumArity = 3;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private IfFoodAhead(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Left.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Left.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Left.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Left", "Represents the turn-left symbol in a artificial ant expression.")]
   public sealed class Left : Symbol {
+    private const int minimumArity = 0;
+    private const int maximumArity = 0;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Left(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Move.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Move.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Move.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Move", "Represents the move-forward symbol in a artificial ant expression.")]
   public sealed class Move : Symbol {
+    private const int minimumArity = 0;
+    private const int maximumArity = 0;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Move(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Prog2.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Prog2.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Prog2.cs	(revision 6387)
@@ -29,4 +29,14 @@
   [Item("Prog2", "Represents the sequence symbol with 2 sub-trees in a artificial ant expression.")]
   public sealed class Prog2 : Symbol {
+    private const int minimumArity = 2;
+    private const int maximumArity = 2;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Prog2(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Prog3.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Prog3.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Prog3.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Prog3", "Represents the sequence symbol with 3 sub-trees in a artificial ant expression.")]
   public sealed class Prog3 : Symbol {
+    private const int minimumArity = 3;
+    private const int maximumArity = 3;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Prog3(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Right.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Right.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Right.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Right", "Represents the turn-right symbol in a artificial ant expression.")]
   public sealed class Right : Symbol {
+    private const int minimumArity = 0;
+    private const int maximumArity = 0;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Right(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs	(revision 6387)
@@ -108,11 +108,11 @@
     private double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree) {
       // remove old ADFs
-      while (tempTree.Root.SubtreesCount > 1) tempTree.Root.RemoveSubtree(1);
+      while (tempTree.Root.SubtreeCount > 1) tempTree.Root.RemoveSubtree(1);
       // clone ADFs of source tree
-      for (int i = 1; i < sourceTree.Root.SubtreesCount; i++) {
+      for (int i = 1; i < sourceTree.Root.SubtreeCount; i++) {
         tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone());
       }
       var start = tempTree.Root.GetSubtree(0);
-      while (start.SubtreesCount > 0) start.RemoveSubtree(0);
+      while (start.SubtreeCount > 0) start.RemoveSubtree(0);
       start.AddSubtree((ISymbolicExpressionTreeNode)node.Clone());
       var interpreter = Content.Model.Interpreter;
@@ -123,5 +123,5 @@
 
     private void SwitchNode(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode oldBranch, ISymbolicExpressionTreeNode newBranch) {
-      for (int i = 0; i < root.SubtreesCount; i++) {
+      for (int i = 0; i < root.SubtreeCount; i++) {
         if (root.GetSubtree(i) == oldBranch) {
           root.RemoveSubtree(i);
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationModel.cs	(revision 6387)
@@ -130,8 +130,8 @@
       if (startNode.GetSubtree(0).Symbol is Addition) {
         var addNode = startNode.GetSubtree(0);
-        if (addNode.SubtreesCount == 2 && addNode.GetSubtree(0).Symbol is Multiplication && addNode.GetSubtree(1).Symbol is Constant) {
+        if (addNode.SubtreeCount == 2 && addNode.GetSubtree(0).Symbol is Multiplication && addNode.GetSubtree(1).Symbol is Constant) {
           alphaTreeNode = addNode.GetSubtree(1) as ConstantTreeNode;
           var mulNode = addNode.GetSubtree(0);
-          if (mulNode.SubtreesCount == 2 && mulNode.GetSubtree(1).Symbol is Constant) {
+          if (mulNode.SubtreeCount == 2 && mulNode.GetSubtree(1).Symbol is Constant) {
             betaTreeNode = mulNode.GetSubtree(1) as ConstantTreeNode;
           }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs	(revision 6387)
@@ -97,11 +97,11 @@
     private double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree) {
       // remove old ADFs
-      while (tempTree.Root.SubtreesCount > 1) tempTree.Root.RemoveSubtree(1);
+      while (tempTree.Root.SubtreeCount > 1) tempTree.Root.RemoveSubtree(1);
       // clone ADFs of source tree
-      for (int i = 1; i < sourceTree.Root.SubtreesCount; i++) {
+      for (int i = 1; i < sourceTree.Root.SubtreeCount; i++) {
         tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone());
       }
       var start = tempTree.Root.GetSubtree(0);
-      while (start.SubtreesCount > 0) start.RemoveSubtree(0);
+      while (start.SubtreeCount > 0) start.RemoveSubtree(0);
       start.AddSubtree((ISymbolicExpressionTreeNode)node.Clone());
       var interpreter = Content.Model.Interpreter;
@@ -112,5 +112,5 @@
 
     private void SwitchNode(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode oldBranch, ISymbolicExpressionTreeNode newBranch) {
-      for (int i = 0; i < root.SubtreesCount; i++) {
+      for (int i = 0; i < root.SubtreeCount; i++) {
         if (root.GetSubtree(i) == oldBranch) {
           root.RemoveSubtree(i);
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionModel.cs	(revision 6387)
@@ -79,8 +79,8 @@
       if (startNode.GetSubtree(0).Symbol is Addition) {
         var addNode = startNode.GetSubtree(0);
-        if (addNode.SubtreesCount == 2 && addNode.GetSubtree(0).Symbol is Multiplication && addNode.GetSubtree(1).Symbol is Constant) {
+        if (addNode.SubtreeCount == 2 && addNode.GetSubtree(0).Symbol is Multiplication && addNode.GetSubtree(1).Symbol is Constant) {
           alphaTreeNode = addNode.GetSubtree(1) as ConstantTreeNode;
           var mulNode = addNode.GetSubtree(0);
-          if (mulNode.SubtreesCount == 2 && mulNode.GetSubtree(1).Symbol is Constant) {
+          if (mulNode.SubtreeCount == 2 && mulNode.GetSubtree(1).Symbol is Constant) {
             betaTreeNode = mulNode.GetSubtree(1) as ConstantTreeNode;
           }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs	(revision 6387)
@@ -71,9 +71,9 @@
 
     protected override void OnModelChanged(EventArgs e) {
+      RecalculateResults();
       base.OnModelChanged(e);
-      RecalculateResults();
     }
 
-    protected override void RecalculateResults() {
+    protected new void RecalculateResults() {
       ModelLength = Model.SymbolicExpressionTree.Length;
       ModelDepth = Model.SymbolicExpressionTree.Depth;
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs	(revision 6387)
@@ -95,5 +95,5 @@
           List<ISymbolicExpressionTreeNode> nodeList = Content.Model.SymbolicExpressionTree.Root.GetSubtree(0).IterateNodesPrefix().ToList();
           foreach (var parent in nodeList) {
-            for (int subTreeIndex = 0; subTreeIndex < parent.SubtreesCount; subTreeIndex++) {
+            for (int subTreeIndex = 0; subTreeIndex < parent.SubtreeCount; subTreeIndex++) {
               var child = parent.GetSubtree(subTreeIndex);
               if (!(child.Symbol is Constant) && nodeImpacts[child].IsAlmost(0.0)) {
@@ -105,5 +105,5 @@
 
         // show only interesting part of solution 
-        if (tree.Root.SubtreesCount > 1)
+        if (tree.Root.SubtreeCount > 1)
           this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB + ADFs
         else
@@ -130,5 +130,5 @@
       var tree = Content.Model.SymbolicExpressionTree;
       foreach (SymbolicExpressionTreeNode treeNode in tree.IterateNodesPostfix()) {
-        for (int i = 0; i < treeNode.SubtreesCount; i++) {
+        for (int i = 0; i < treeNode.SubtreeCount; i++) {
           ISymbolicExpressionTreeNode subTree = treeNode.GetSubtree(i);
           // only allow to replace nodes for which a replacement value is known (replacement value for ADF nodes are not available)
@@ -137,5 +137,5 @@
 
             // show only interesting part of solution 
-            if (tree.Root.SubtreesCount > 1)
+            if (tree.Root.SubtreeCount > 1)
               this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB + ADFs
             else
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs	(revision 6387)
@@ -88,5 +88,5 @@
       StringBuilder builder = new StringBuilder();
       builder.Append("(" + tree.ToString());
-      for (int i = 0; i < tree.SubtreesCount; i++) {
+      for (int i = 0; i < tree.SubtreeCount; i++) {
         builder.Append(" " + GetTextualRepresentationFromSubtreeOfDepth(tree.GetSubtree(i), d - 1));
       }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs	(revision 6387)
@@ -73,5 +73,5 @@
       FormatBegin(node, strBuilder);
 
-      if (node.SubtreesCount > 0) {
+      if (node.SubtreeCount > 0) {
         strBuilder.Append(FormatRecursively(node.GetSubtree(0)));
       }
@@ -91,5 +91,5 @@
         strBuilder.Append(@" \left( ");
       } else if (node.Symbol is Subtraction) {
-        if (node.SubtreesCount == 1) {
+        if (node.SubtreeCount == 1) {
           strBuilder.Append(@"- \left(");
         } else {
@@ -98,5 +98,5 @@
       } else if (node.Symbol is Multiplication) {
       } else if (node.Symbol is Division) {
-        if (node.SubtreesCount == 1) {
+        if (node.SubtreeCount == 1) {
           strBuilder.Append(@" \cfrac{1}{");
         } else {
@@ -105,6 +105,6 @@
       } else if (node.Symbol is Average) {
         // skip output of (1/1) if only one subtree
-        if (node.SubtreesCount > 1) {
-          strBuilder.Append(@" \cfrac{1}{" + node.SubtreesCount + @"}");
+        if (node.SubtreeCount > 1) {
+          strBuilder.Append(@" \cfrac{1}{" + node.SubtreeCount + @"}");
         }
         strBuilder.Append(@" \left(");
@@ -246,7 +246,7 @@
       } else if (node.Symbol is Division) {
         strBuilder.Append("} ");
-        if (node.SubtreesCount > 1)
+        if (node.SubtreeCount > 1)
           strBuilder.Append("{1} ");
-        for (int i = 1; i < node.SubtreesCount; i++) {
+        for (int i = 1; i < node.SubtreeCount; i++) {
           strBuilder.Append(" } ");
         }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs	(revision 6387)
@@ -106,5 +106,5 @@
 
       if (symbol is Addition) {
-        for (int i = 0; i < node.SubtreesCount; i++) {
+        for (int i = 0; i < node.SubtreeCount; i++) {
           if (i > 0) stringBuilder.Append("+");
           stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));
@@ -112,5 +112,5 @@
       } else if (symbol is And) {
         stringBuilder.Append("((");
-        for (int i = 0; i < node.SubtreesCount; i++) {
+        for (int i = 0; i < node.SubtreeCount; i++) {
           if (i > 0) stringBuilder.Append("&");
           stringBuilder.Append("((");
@@ -121,7 +121,7 @@
       } else if (symbol is Average) {
         stringBuilder.Append("(1/");
-        stringBuilder.Append(node.SubtreesCount);
+        stringBuilder.Append(node.SubtreeCount);
         stringBuilder.Append(")*(");
-        for (int i = 0; i < node.SubtreesCount; i++) {
+        for (int i = 0; i < node.SubtreeCount; i++) {
           if (i > 0) stringBuilder.Append("+");
           stringBuilder.Append("(");
@@ -138,5 +138,5 @@
         stringBuilder.Append(")");
       } else if (symbol is Division) {
-        if (node.SubtreesCount == 1) {
+        if (node.SubtreeCount == 1) {
           stringBuilder.Append("1/");
           stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
@@ -144,5 +144,5 @@
           stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
           stringBuilder.Append("/(");
-          for (int i = 1; i < node.SubtreesCount; i++) {
+          for (int i = 1; i < node.SubtreeCount; i++) {
             if (i > 1) stringBuilder.Append("*");
             stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));
@@ -187,5 +187,5 @@
         stringBuilder.Append(")");
       } else if (symbol is Multiplication) {
-        for (int i = 0; i < node.SubtreesCount; i++) {
+        for (int i = 0; i < node.SubtreeCount; i++) {
           if (i > 0) stringBuilder.Append("*");
           stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));
@@ -197,5 +197,5 @@
       } else if (symbol is Or) {
         stringBuilder.Append("((");
-        for (int i = 0; i < node.SubtreesCount; i++) {
+        for (int i = 0; i < node.SubtreeCount; i++) {
           if (i > 0) stringBuilder.Append("|");
           stringBuilder.Append("((");
@@ -209,10 +209,10 @@
         stringBuilder.Append(")");
       } else if (symbol is Subtraction) {
-        if (node.SubtreesCount == 1) {
+        if (node.SubtreeCount == 1) {
           stringBuilder.Append("-1*");
           stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
         } else {
           stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
-          for (int i = 1; i < node.SubtreesCount; i++) {
+          for (int i = 1; i < node.SubtreeCount; i++) {
             stringBuilder.Append("-");
             stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs	(revision 6387)
@@ -64,5 +64,5 @@
     private ISymbolicExpressionTreeNode MacroExpand(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode node, IList<ISymbolicExpressionTreeNode> argumentTrees) {
       List<ISymbolicExpressionTreeNode> subtrees = new List<ISymbolicExpressionTreeNode>(node.Subtrees);
-      while (node.SubtreesCount > 0) node.RemoveSubtree(0);
+      while (node.SubtreeCount > 0) node.RemoveSubtree(0);
       if (node.Symbol is InvokeFunction) {
         var invokeSym = node.Symbol as InvokeFunction;
@@ -901,5 +901,5 @@
         // x0 * x1 * .. * xn * -1 => x0 * x1 * .. * -xn
         var lastSubTree = x.Subtrees.Last();
-        x.RemoveSubtree(x.SubtreesCount - 1);
+        x.RemoveSubtree(x.SubtreeCount - 1);
         x.AddSubtree(Negate(lastSubTree)); // last is maybe a constant, prefer to negate the constant
       } else {
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Addition.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Addition.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Addition.cs	(revision 6387)
@@ -22,10 +22,20 @@
 using HeuristicLab.Common;
 using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
   [StorableClass]
   [Item("Addition", "Symbol that represents the + operator.")]
   public sealed class Addition : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Addition(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/And.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/And.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/And.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("And", "Symbol that represents the boolean AND operator.")]
   public sealed class And : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private And(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Average.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Average.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Average.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Average", "Symbol that represents the average (arithmetic mean) function.")]
   public sealed class Average : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Average(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Constant.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Constant.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Constant.cs	(revision 6387)
@@ -88,5 +88,15 @@
     }
 
+    private const int minimumArity = 0;
+    private const int maximumArity = 0;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
     #endregion
+
     [StorableConstructor]
     private Constant(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Cosine.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Cosine.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Cosine.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Cosine", "Symbol that represents the cosine function.")]
   public sealed class Cosine : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Cosine(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Derivative.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Derivative.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Derivative.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Derivative", "Represents the derivative over the specified subtree.")]
   public sealed class Derivative : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Derivative(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Division.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Division.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Division.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Division", "Symbol that represents the / operator.")]
   public sealed class Division : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Division(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Exponential.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Exponential.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Exponential.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Exponential", "Symbol that represents the exponential function.")]
   public sealed class Exponential : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Exponential(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/GreaterThan.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/GreaterThan.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/GreaterThan.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("GreaterThan", "Symbol that represents a greater than relation.")]
   public sealed class GreaterThan : Symbol {
+    private const int minimumArity = 2;
+    private const int maximumArity = 2;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private GreaterThan(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/IfThenElse.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/IfThenElse.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/IfThenElse.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("IfThenElse", "Symbol that represents a conditional operator.")]
   public sealed class IfThenElse : Symbol {
+    private const int minimumArity = 3;
+    private const int maximumArity = 3;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private IfThenElse(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Integral.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Integral.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Integral.cs	(revision 6387)
@@ -27,4 +27,14 @@
   [Item("Integral", "Represents the integral over the specified subtree.")]
   public sealed class Integral : LaggedSymbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Integral(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LessThan.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LessThan.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LessThan.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("LessThan", "Symbol that represents a less than relation.")]
   public sealed class LessThan : Symbol {
+    private const int minimumArity = 2;
+    private const int maximumArity = 2;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private LessThan(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Logarithm.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Logarithm.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Logarithm.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Logarithm", "Symbol that represents the logarithm function.")]
   public sealed class Logarithm : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Logarithm(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Multiplication.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Multiplication.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Multiplication.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Multiplication", "Symbol that represents the * operator.")]
   public sealed class Multiplication : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Multiplication(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Not.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Not.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Not.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Not", "Symbol that represents the boolean NOT operator.")]
   public sealed class Not : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Not(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Or.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Or.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Or.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Or", "Symbol that represents the boolean OR operator.")]
   public sealed class Or : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Or(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Power.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Power.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Power.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Power", "Symbol that represents the power function.")]
   public sealed class Power : Symbol {
+    private const int minimumArity = 2;
+    private const int maximumArity = 2;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Power(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Root.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Root.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Root.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Root", "Symbol that represents the n-th root function.")]
   public sealed class Root : Symbol {
+    private const int minimumArity = 2;
+    private const int maximumArity = 2;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Root(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Sine.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Sine.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Sine.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Sine", "Symbol that represents the sine function.")]
   public sealed class Sine : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Sine(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Subtraction.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Subtraction.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Subtraction.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Subtraction", "Symbol that represents the - operator.")]
   public sealed class Subtraction : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = byte.MaxValue;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Subtraction(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Tangent.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Tangent.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Tangent.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("Tangent", "Symbol that represents the tangent trigonometric function.")]
   public sealed class Tangent : Symbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private Tangent(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/TimeLag.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/TimeLag.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/TimeLag.cs	(revision 6387)
@@ -28,4 +28,14 @@
   [Item("TimeLag", "Represents a symblol whose evaluation is shifted.")]
   public sealed class TimeLag : LaggedSymbol {
+    private const int minimumArity = 1;
+    private const int maximumArity = 1;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
+
     [StorableConstructor]
     private TimeLag(bool deserializing) : base(deserializing) { }
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs	(revision 6387)
@@ -100,5 +100,16 @@
       }
     }
+
+    private const int minimumArity = 0;
+    private const int maximumArity = 0;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
     #endregion
+
     [StorableConstructor]
     protected Variable(bool deserializing)
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs	(revision 6387)
@@ -138,4 +138,14 @@
       }
     }
+
+    private const int minimumArity = 2;
+    private const int maximumArity = 2;
+
+    public override int MinimumArity {
+      get { return minimumArity; }
+    }
+    public override int MaximumArity {
+      get { return maximumArity; }
+    }
     #endregion
 
Index: /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs
===================================================================
--- /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs	(revision 6386)
+++ /branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs	(revision 6387)
@@ -118,13 +118,13 @@
 
     protected override void OnProblemDataChanged(EventArgs e) {
+      RecalculateResults();
       base.OnProblemDataChanged(e);
-      RecalculateResults();
     }
     protected override void OnModelChanged(EventArgs e) {
+      RecalculateResults();
       base.OnModelChanged(e);
-      RecalculateResults();
     }
 
-    protected virtual void RecalculateResults() {
+    protected void RecalculateResults() {
       double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values
       IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes);
