Index: branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicDataAnalysisProblem.cs
===================================================================
--- branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicDataAnalysisProblem.cs	(revision 10263)
+++ branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicDataAnalysisProblem.cs	(revision 10268)
@@ -84,6 +84,6 @@
       get { return (IValueParameter<T>)Parameters[ProblemDataParameterName]; }
     }
-    public IValueParameter<ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter {
-      get { return (IValueParameter<ISymbolicDataAnalysisGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
+    public IValueParameter<GESymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter {
+      get { return (IValueParameter<GESymbolicExpressionGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
     }
     public IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
@@ -134,5 +134,5 @@
     }
 
-    public ISymbolicDataAnalysisGrammar SymbolicExpressionTreeGrammar {
+    public GESymbolicExpressionGrammar SymbolicExpressionTreeGrammar {
       get { return SymbolicExpressionTreeGrammarParameter.Value; }
       set { SymbolicExpressionTreeGrammarParameter.Value = value; }
@@ -174,14 +174,4 @@
     [StorableHook(HookType.AfterDeserialization)]
     private void AfterDeserialization() {
-      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName)) {
-        Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, ApplyLinearScalingParameterDescription, new BoolValue(false)));
-        ApplyLinearScalingParameter.Hidden = true;
-
-        //it is assumed that for all symbolic regression algorithms linear scaling was set to true
-        //there is no possibility to determine the previous value of the parameter as it was stored in the evaluator
-        if (GetType().Name.Contains("SymbolicRegression"))
-          ApplyLinearScaling.Value = true;
-      }
-
       RegisterEventHandlers();
     }
@@ -194,5 +184,5 @@
       : base(evaluator, solutionCreator) {
       Parameters.Add(new ValueParameter<T>(ProblemDataParameterName, ProblemDataParameterDescription, problemData));
-      Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription));
+      Parameters.Add(new ValueParameter<GESymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription));
       Parameters.Add(new ValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, SymoblicExpressionTreeInterpreterParameterDescription));
       //Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, MaximumSymbolicExpressionTreeDepthParameterDescription));
@@ -213,5 +203,5 @@
       ApplyLinearScalingParameter.Hidden = true;
 
-      SymbolicExpressionTreeGrammar = new TypeCoherentExpressionGrammar();
+      SymbolicExpressionTreeGrammar = new GESymbolicExpressionGrammar(problemData.AllowedInputVariables, problemData.AllowedInputVariables.Count() * 3);
       SymbolicExpressionTreeInterpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter();
 
@@ -225,19 +215,17 @@
     }
 
+    private void DeregisterGrammarHandler() {
+      SymbolicExpressionTreeGrammarParameter.ValueChanged -= SymbolicExpressionTreeGrammarParameter_ValueChanged;
+    }
+    private void RegisterGrammarHandler() {
+      SymbolicExpressionTreeGrammarParameter.ValueChanged += SymbolicExpressionTreeGrammarParameter_ValueChanged;
+    }
+
     protected virtual void UpdateGrammar() {
-      //SymbolicExpressionTreeGrammar.MaximumFunctionArguments = MaximumFunctionArguments.Value;
-      //SymbolicExpressionTreeGrammar.MaximumFunctionDefinitions = MaximumFunctionDefinitions.Value;
-      foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>()) {
-        if (!varSymbol.Fixed) {
-          varSymbol.AllVariableNames = ProblemData.InputVariables.Select(x => x.Value);
-          varSymbol.VariableNames = ProblemData.AllowedInputVariables;
-        }
-      }
-      foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) {
-        if (!varSymbol.Fixed) {
-          varSymbol.AllVariableNames = ProblemData.InputVariables.Select(x => x.Value);
-          varSymbol.VariableNames = ProblemData.AllowedInputVariables;
-        }
-      }
+      DeregisterGrammarHandler();
+      // create a new grammar instance with the correct allowed input variables
+      SymbolicExpressionTreeGrammarParameter.Value =
+        new GESymbolicExpressionGrammar(ProblemData.AllowedInputVariables, ProblemData.AllowedInputVariables.Count() * 3);
+      RegisterGrammarHandler();
     }
 
@@ -257,5 +245,5 @@
       ProblemDataParameter.Value.Changed += (object sender, EventArgs e) => OnProblemDataChanged();
 
-      SymbolicExpressionTreeGrammarParameter.ValueChanged += new EventHandler(SymbolicExpressionTreeGrammarParameter_ValueChanged);
+      RegisterGrammarHandler();
 
       //MaximumFunctionArguments.ValueChanged += new EventHandler(ArchitectureParameterValue_ValueChanged);
@@ -272,8 +260,4 @@
 
     private void SymbolicExpressionTreeGrammarParameter_ValueChanged(object sender, EventArgs e) {
-      UpdateGrammar();
-    }
-
-    private void ArchitectureParameterValue_ValueChanged(object sender, EventArgs e) {
       UpdateGrammar();
     }
Index: branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicExpressionGrammar.cs
===================================================================
--- branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicExpressionGrammar.cs	(revision 10268)
+++ branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicExpressionGrammar.cs	(revision 10268)
@@ -0,0 +1,150 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2013 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.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Random;
+using Variable = HeuristicLab.Core.Variable;
+
+namespace HeuristicLab.Problems.GrammaticalEvolution {
+  [StorableClass]
+  [Item("GESymbolicExpressionGrammar", "Represents a grammar for functional expressions for grammatical evolution.")]
+  public class GESymbolicExpressionGrammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar {
+    [StorableConstructor]
+    protected GESymbolicExpressionGrammar(bool deserializing) : base(deserializing) { }
+    protected GESymbolicExpressionGrammar(GESymbolicExpressionGrammar original, Cloner cloner) : base(original, cloner) { }
+    public GESymbolicExpressionGrammar()
+      : base(ItemAttribute.GetName(typeof(GESymbolicExpressionGrammar)), ItemAttribute.GetDescription(typeof(GESymbolicExpressionGrammar))) {
+      // empty ctor is necessary to allow creation of new GEGrammars from the GUI.
+      // the problem creates a new correctly configured grammar when the grammar is set
+    }
+    internal GESymbolicExpressionGrammar(IEnumerable<string> variableNames, int nConstants)
+      : base(ItemAttribute.GetName(typeof(GESymbolicExpressionGrammar)), ItemAttribute.GetDescription(typeof(GESymbolicExpressionGrammar))) {
+      // this ctor is called by the problem as only the problem knows the allowed input variables
+      Initialize(variableNames, nConstants);
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new GESymbolicExpressionGrammar(this, cloner);
+    }
+
+    private void Initialize(IEnumerable<string> variableNames, int nConstants) {
+      #region symbol declaration
+      var add = new Addition();
+      var sub = new Subtraction();
+      var mul = new Multiplication();
+      var div = new Division();
+      var mean = new Average();
+      var log = new Logarithm();
+      var pow = new Power();
+      var square = new Square();
+      var root = new Root();
+      var sqrt = new SquareRoot();
+      var exp = new Exponential();
+
+      // we use our own random number generator here because we assume 
+      // that grammars are only initialized once when setting the grammar in the problem.
+      // This means everytime the grammar parameter in the problem is changed
+      // we initialize the constants to new values
+      var rand = new MersenneTwister();
+      // warm up
+      for (int i = 0; i < 1000; i++) rand.NextDouble();
+
+      var constants = new List<Constant>(nConstants);
+      for (int i = 0; i < nConstants; i++) {
+        var constVal = rand.NextDouble() * 20.0 - 10.0;
+        var constant = new Constant();
+        constant.Name = string.Format("{0:0.000}", constVal);
+        constant.MinValue = constVal;
+        constant.MaxValue = constVal;
+        constant.ManipulatorSigma = 0.0;
+        constant.ManipulatorMu = 0.0;
+        constant.MultiplicativeManipulatorSigma = 0.0;
+        constants.Add(constant);
+      }
+
+      var variables = new List<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>();
+      foreach (var variableName in variableNames) {
+        var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable();
+        variableSymbol.Name = variableName;
+        variableSymbol.WeightManipulatorMu = 0.0;
+        variableSymbol.WeightManipulatorSigma = 0.0;
+        variableSymbol.WeightMu = 1.0;
+        variableSymbol.WeightSigma = 0.0;
+        variableSymbol.MultiplicativeWeightManipulatorSigma = 0.0;
+        variableSymbol.AllVariableNames = new[] { variableName };
+        variableSymbol.VariableNames = new[] { variableName };
+        variables.Add(variableSymbol);
+      }
+
+      #endregion
+
+      AddSymbol(add);
+      AddSymbol(sub);
+      AddSymbol(mul);
+      AddSymbol(div);
+      AddSymbol(mean);
+      AddSymbol(log);
+      AddSymbol(pow);
+      AddSymbol(square);
+      AddSymbol(root);
+      AddSymbol(sqrt);
+      AddSymbol(exp);
+      constants.ForEach(AddSymbol);
+      variables.ForEach(AddSymbol);
+
+      #region subtree count configuration
+      SetSubtreeCount(add, 2, 2);
+      SetSubtreeCount(sub, 2, 2);
+      SetSubtreeCount(mul, 2, 2);
+      SetSubtreeCount(div, 2, 2);
+      SetSubtreeCount(mean, 2, 2);
+      SetSubtreeCount(log, 1, 1);
+      SetSubtreeCount(pow, 2, 2);
+      SetSubtreeCount(square, 1, 1);
+      SetSubtreeCount(root, 2, 2);
+      SetSubtreeCount(sqrt, 1, 1);
+      SetSubtreeCount(exp, 1, 1);
+      constants.ForEach((c) => SetSubtreeCount(c, 0, 0));
+      variables.ForEach((v) => SetSubtreeCount(v, 0, 0));
+      #endregion
+
+      var functions = new ISymbol[] { add, sub, mul, div, mean, log, pow, root, square, sqrt };
+      var terminalSymbols = variables.Concat<ISymbol>(constants);
+      var allSymbols = functions.Concat(terminalSymbols);
+
+      #region allowed child symbols configuration
+      foreach (var s in allSymbols) {
+        AddAllowedChildSymbol(StartSymbol, s);
+      }
+      foreach (var parentSymb in functions)
+        foreach (var childSymb in allSymbols) {
+          AddAllowedChildSymbol(parentSymb, childSymb);
+        }
+
+      #endregion
+    }
+  }
+}
Index: branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicRegressionSingleObjectiveProblem.cs
===================================================================
--- branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicRegressionSingleObjectiveProblem.cs	(revision 10263)
+++ branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/GESymbolicRegressionSingleObjectiveProblem.cs	(revision 10268)
@@ -73,5 +73,4 @@
 
       RegisterEventHandlers();
-      ConfigureGrammarSymbols();
       InitializeOperators();
       UpdateEstimationLimits();
@@ -84,11 +83,7 @@
 
     private void RegisterEventHandlers() {
-      SymbolicExpressionTreeGrammarParameter.ValueChanged += (o, e) => ConfigureGrammarSymbols();
+      // nothing to do
     }
 
-    private void ConfigureGrammarSymbols() {
-      var grammar = SymbolicExpressionTreeGrammar as TypeCoherentExpressionGrammar;
-      if (grammar != null) grammar.ConfigureAsDefaultRegressionGrammar();
-    }
 
     private void InitializeOperators() {
Index: branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/IGESymbolicDataAnalysisProblem.cs
===================================================================
--- branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/IGESymbolicDataAnalysisProblem.cs	(revision 10263)
+++ branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Symbolic/IGESymbolicDataAnalysisProblem.cs	(revision 10268)
@@ -23,8 +23,11 @@
 using HeuristicLab.Data;
 using HeuristicLab.Optimization;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+using HeuristicLab.Problems.GrammaticalEvolution;
 
-namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
+namespace HeuristicLab.Problems.GrammaticalEvolution {
   public interface IGESymbolicDataAnalysisProblem : IDataAnalysisProblem, IHeuristicOptimizationProblem {
-    IValueParameter<ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter { get; }
+    IValueParameter<GESymbolicExpressionGrammar> SymbolicExpressionTreeGrammarParameter { get; }
     IValueParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicExpressionTreeInterpreterParameter { get; }
     //IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter { get; }
@@ -36,5 +39,5 @@
     IFixedValueParameter<IntRange> ValidationPartitionParameter { get; }
 
-    ISymbolicDataAnalysisGrammar SymbolicExpressionTreeGrammar { get; set; }
+    GESymbolicExpressionGrammar SymbolicExpressionTreeGrammar { get; set; }
     ISymbolicDataAnalysisExpressionTreeInterpreter SymbolicExpressionTreeInterpreter { get; set; }
     //IntValue MaximumSymbolicExpressionTreeDepth { get; }
