Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprEvaluator.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprEvaluator.cs	(revision 11857)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprEvaluator.cs	(revision 11857)
@@ -0,0 +1,60 @@
+﻿using System;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Operators;
+using HeuristicLab.Parameters;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.Problems.GrammaticalOptimization {
+  // this type is not storable because we use a func<ITree,double> for evaluation, which references back to the original grammatical optimization problem
+  [NonDiscoverableType]
+  [Item("GenericSymbExprEvaluator", "Evaluator for grammatical optimization problems (using a symbolic expression tree encoding).")]
+  public class GenericSymbExprEvaluator : SingleSuccessorOperator, IGenericSymbExprEvaluator {
+    public event Action<string, double> SolutionEvaluated;
+
+    public ILookupParameter<DoubleValue> QualityParameter {
+      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
+    }
+    public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
+      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters["SymbolicExpressionTree"]; }
+    }
+
+    private Func<string, double> evalFunc;
+    private Func<ISymbolicExpressionTree, string> toStringFunc;
+
+    public GenericSymbExprEvaluator(GenericSymbExprEvaluator original, Cloner cloner)
+      : base(original, cloner) {
+      this.evalFunc = original.evalFunc;
+    }
+
+    public GenericSymbExprEvaluator(Func<ISymbolicExpressionTree, string> toStringFunc, Func<string, double> evalFunc)
+      : base() {
+      Parameters.Add(new LookupParameter<DoubleValue>("Quality"));
+      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>("SymbolicExpressionTree"));
+      this.evalFunc = evalFunc;
+      this.toStringFunc = toStringFunc;
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new GenericSymbExprEvaluator(this, cloner);
+    }
+
+    public override IOperation Apply() {
+      var tree = SymbolicExpressionTreeParameter.ActualValue;
+      var sentence = toStringFunc(tree);
+      var q = evalFunc(sentence);
+      QualityParameter.ActualValue = new DoubleValue(q);
+
+      RaiseSolutionEvaluated(sentence, q);
+
+      return base.Apply();
+    }
+
+    private void RaiseSolutionEvaluated(string sentence, double quality) {
+      var handler = SolutionEvaluated;
+      if (handler != null) handler(sentence, quality);
+    }
+  }
+}
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprGrammar.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprGrammar.cs	(revision 11857)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprGrammar.cs	(revision 11857)
@@ -0,0 +1,104 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.Problems.GrammaticalOptimization {
+  [NonDiscoverableType]
+  [StorableClass]
+  [Item("GenericSymbExprGrammar", "Represents a general grammar for grammatical optimization problems.")]
+  public class GenericSymbExprGrammar : SymbolicExpressionGrammar {
+    [StorableClass]
+    [Item("GenericSymbol", "")]
+    public sealed class GenericSymbol : Symbol {
+      private readonly int minimumArity = 1;
+      private readonly int maximumArity = byte.MaxValue;
+
+      public override int MinimumArity { get { return minimumArity; } }
+      public override int MaximumArity { get { return maximumArity; } }
+
+      [StorableConstructor]
+      private GenericSymbol(bool deserializing) : base(deserializing) { }
+      private GenericSymbol(GenericSymbol original, Cloner cloner) : base(original, cloner) { }
+      public override IDeepCloneable Clone(Cloner cloner) {
+        return new GenericSymbol(this, cloner);
+      }
+      public GenericSymbol(char s, int minArity, int maxArity)
+        : base(s.ToString(), string.Empty) {
+        this.minimumArity = minArity;
+        this.maximumArity = maxArity;
+      }
+    }
+
+    [StorableConstructor]
+    public GenericSymbExprGrammar(bool deserializing) : base(deserializing) { }
+
+    public GenericSymbExprGrammar(SymbolicExpressionGrammar original, Cloner cloner) : base(original, cloner) { }
+
+    public GenericSymbExprGrammar(IGrammar grammar)
+      : base(ItemAttribute.GetName(typeof(GenericSymbExprGrammar)), ItemAttribute.GetDescription(typeof(GenericSymbExprGrammar))) {
+
+      var ntSymbs = new List<GenericSymbol>();
+      var tSymbs = new List<GenericSymbol>();
+      // for terminal and nonterminal symbol in the grammar create a symbol class
+      // for non-terminals set the arity and the allowed children
+      // for terminals set arity to 0 and allowed children to empty
+      foreach (var nt in grammar.NonTerminalSymbols) {
+        var ntSymb = CreateSymbol(grammar, nt);
+        AddSymbol(ntSymb);
+        SetSubtreeCount(ntSymb, ntSymb.MinimumArity, ntSymb.MaximumArity);
+        ntSymbs.Add(ntSymb);
+      }
+      foreach (var t in grammar.TerminalSymbols) {
+        var tSymb = new GenericSymbol(t, 0, 0);
+        AddSymbol(tSymb);
+        SetSubtreeCount(tSymb, 0, 0);
+        tSymbs.Add(tSymb);
+      }
+
+      Func<char, GenericSymbol> findSymb = (char s) => {
+        var selectedSymb = ntSymbs.SingleOrDefault(symb => symb.Name == s.ToString());
+        if (selectedSymb != null) return selectedSymb;
+        return tSymbs.SingleOrDefault(symb => symb.Name == s.ToString());
+      };
+
+      // set the sentence symbol as the allowed start symbol
+      AddAllowedChildSymbol(StartSymbol, findSymb(grammar.SentenceSymbol));
+
+      foreach (var nt in ntSymbs) {
+        // either all alts are only a single symbol 
+        // or all alts only use a single symbol (see assertion in CreateSymbol)
+        var alts = grammar.GetAlternatives(nt.Name[0]); // all symbols only have a single character name
+        Debug.Assert(alts.All(alt => alt.Length == 1 || alt.Distinct().Count() == 1));
+
+        foreach (var alt in alts) {
+          Debug.Assert(alt.All(ch => ch == alt[0]));
+          AddAllowedChildSymbol(nt, findSymb(alt.First()));
+        }
+      }
+    }
+
+    private GenericSymbol CreateSymbol(IGrammar g, char s) {
+
+      var minArity = g.GetAlternatives(s).Select(alt => alt.Length).Min();
+      var maxArity = g.GetAlternatives(s).Select(alt => alt.Length).Max();
+      // either the min and max arity is 1 or the alternatives all use the same symbol (hl doesn't know about dependencies between positions in the alternative
+      Debug.Assert(
+        (minArity == 1 && maxArity == 1) ||
+        g.GetAlternatives(s).Select(alt => alt.Distinct()).All(alt => alt.Count() == 1));
+      var symb = new GenericSymbol(s, minArity, maxArity);
+      return symb;
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new GenericSymbExprGrammar(this, cloner);
+    }
+  }
+}
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprProblem.cs	(revision 11857)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/GenericSymbExprProblem.cs	(revision 11857)
@@ -0,0 +1,80 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.Problems.GrammaticalOptimization {
+  [NonDiscoverableType]
+  [StorableClass]
+  [Item("GenericSymbExprProblem", "Represents grammatical optimization problems (using a symbolic expression tree encoding).")]
+  public class GenericSymbExprProblem : SingleObjectiveHeuristicOptimizationProblem<IGenericSymbExprEvaluator, ISymbolicExpressionTreeCreator> {
+    #region string consts
+    private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
+    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
+    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
+
+    #endregion
+
+    #region parameter properties
+    public IValueParameter<ISymbolicExpressionTreeGrammar> SymbolicExpressionTreeGrammarParameter {
+      get { return (IValueParameter<ISymbolicExpressionTreeGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
+    }
+    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
+      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
+    }
+    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
+      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
+    }
+    #endregion
+
+
+    #region properties
+
+    public ISymbolicExpressionTreeGrammar SymbolicExpressionTreeGrammar {
+      get { return SymbolicExpressionTreeGrammarParameter.Value; }
+      set { SymbolicExpressionTreeGrammarParameter.Value = value; }
+    }
+    public IntValue MaximumSymbolicExpressionTreeDepth {
+      get { return MaximumSymbolicExpressionTreeDepthParameter.Value; }
+    }
+    public IntValue MaximumSymbolicExpressionTreeLength {
+      get { return MaximumSymbolicExpressionTreeLengthParameter.Value; }
+    }
+    public new GenericSymbExprEvaluator Evaluator {
+      get { return (GenericSymbExprEvaluator)base.Evaluator; }
+    }
+
+    #endregion
+    [StorableConstructor]
+    public GenericSymbExprProblem(bool deserializing) : base(deserializing) { }
+
+    public GenericSymbExprProblem(GenericSymbExprProblem original, Cloner cloner) : base(original, cloner) { }
+
+    public GenericSymbExprProblem(ISymbolicExpressionTreeProblem problem)
+      : base(new GenericSymbExprEvaluator(problem.ConvertTreeToSentence, problem.Evaluate), new ProbabilisticTreeCreator()) {
+      var grammar = new GenericSymbExprGrammar(problem.TreeBasedGPGrammar);
+      Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, grammar));
+      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, new IntValue(50)));
+      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, new IntValue(15)));
+
+      Maximization = new BoolValue(true);
+      BestKnownQuality = new DoubleValue(1.0);
+
+      Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new GenericSymbExprProblem(this, cloner);
+    }
+  }
+}
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj	(revision 11857)
@@ -64,4 +64,12 @@
       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     </Reference>
+    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
+    </Reference>
     <Reference Include="HeuristicLab.Selection-3.3">
       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Selection-3.3.dll</HintPath>
@@ -69,6 +77,11 @@
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="GenericSymbExprEvaluator.cs" />
+    <Compile Include="GenericSymbExprGrammar.cs" />
+    <Compile Include="GenericSymbExprProblem.cs" />
+    <Compile Include="IGenericSymbExprEvaluator.cs" />
     <Compile Include="OffspringSelectionGP.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/IGenericSymbExprEvaluator.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/IGenericSymbExprEvaluator.cs	(revision 11857)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/IGenericSymbExprEvaluator.cs	(revision 11857)
@@ -0,0 +1,9 @@
+﻿using HeuristicLab.Core;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Optimization;
+
+namespace HeuristicLab.Problems.GrammaticalOptimization {
+  public interface IGenericSymbExprEvaluator : ISingleObjectiveEvaluator, ISymbolicExpressionTreeOperator {
+    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; } 
+  }
+}
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj	(revision 11857)
@@ -95,8 +95,4 @@
     <Compile Include="Sequence.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="TreeRepresentation\GenericSymbExprGrammar.cs" />
-    <Compile Include="TreeRepresentation\GenericSymbExprProblem.cs" />
-    <Compile Include="TreeRepresentation\GrammaticalOptimizationEvaluator.cs" />
-    <Compile Include="TreeRepresentation\IGrammaticalOptimizationEvaluator.cs" />
     <Compile Include="TreeRepresentation\ISymbolicExpressionTreeProblem.cs" />
   </ItemGroup>
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/EvenParityProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/EvenParityProblem.cs	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/EvenParityProblem.cs	(revision 11857)
@@ -29,5 +29,5 @@
     public EvenParityProblem() {
       this.grammar = new Grammar(grammarString);
-      this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
+      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
     }
 
@@ -70,5 +70,5 @@
     }
 
-    public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
+    public IGrammar TreeBasedGPGrammar { get; private set; }
     public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
       var sb = new StringBuilder();
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/HardPalindromeProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/HardPalindromeProblem.cs	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/HardPalindromeProblem.cs	(revision 11857)
@@ -21,5 +21,5 @@
     public HardPalindromeProblem() {
       this.grammar = new Grammar(grammarString);
-      this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
+      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
     }
 
@@ -54,5 +54,5 @@
     }
 
-    public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
+    public IGrammar TreeBasedGPGrammar { get; private set; }
     public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
       var sb = new StringBuilder();
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/PalindromeProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/PalindromeProblem.cs	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/PalindromeProblem.cs	(revision 11857)
@@ -23,5 +23,5 @@
     public PalindromeProblem() {
       this.grammar = new Grammar(grammarString);
-      this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
+      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
     }
 
@@ -96,5 +96,5 @@
     }
 
-    public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
+    public IGrammar TreeBasedGPGrammar { get; private set; }
     public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
       var sb = new StringBuilder();
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalPairProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalPairProblem.cs	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalPairProblem.cs	(revision 11857)
@@ -23,5 +23,5 @@
     public RoyalPairProblem() {
       this.grammar = new Grammar(grammarString);
-      this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
+      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
       // TODO: allow configuration of the number of symbols
     }
@@ -46,9 +46,8 @@
     }
 
-    public IEnumerable<Feature> GetFeatures(string phrase)
-    {
+    public IEnumerable<Feature> GetFeatures(string phrase) {
       throw new NotImplementedException();
     }
-    public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
+    public IGrammar TreeBasedGPGrammar { get; private set; }
     public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
       var sb = new StringBuilder();
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalSymbolProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalSymbolProblem.cs	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalSymbolProblem.cs	(revision 11857)
@@ -25,5 +25,5 @@
     public RoyalSymbolProblem() {
       this.grammar = new Grammar(grammarString);
-      this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
+      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
       //TODO: allow configuration of the number of symbols
     }
@@ -51,5 +51,5 @@
     }
 
-    public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
+    public IGrammar TreeBasedGPGrammar { get; private set; }
     public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
       var sb = new StringBuilder();
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs	(revision 11857)
@@ -35,5 +35,5 @@
     public SantaFeAntProblem() {
       this.grammar = new Grammar(grammarString);
-      this.SymbolicExpressionGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
+      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
     }
 
@@ -129,5 +129,5 @@
     }
 
-    public ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; private set; }
+    public IGrammar TreeBasedGPGrammar { get; private set; }
     public string ConvertTreeToSentence(ISymbolicExpressionTree tree) {
       var sb = new StringBuilder();
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SymbolicRegressionPoly10Problem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SymbolicRegressionPoly10Problem.cs	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SymbolicRegressionPoly10Problem.cs	(revision 11857)
@@ -47,10 +47,5 @@
     //           E c E f E j
 
-    private SymbolicExpressionGrammar symbExprGrammar;
-    public ISymbolicExpressionGrammar SymbolicExpressionGrammar {
-      get {
-        return symbExprGrammar;
-      }
-    }
+    public IGrammar TreeBasedGPGrammar { get; private set; }
 
     private readonly IGrammar grammar;
@@ -62,5 +57,5 @@
     public SymbolicRegressionPoly10Problem() {
       this.grammar = new Grammar(grammarString);
-      this.symbExprGrammar = new GenericSymbExprGrammar(new Grammar(hlGrammarString));
+      this.TreeBasedGPGrammar = new Grammar(hlGrammarString);
 
       this.N = 500;
Index: anches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/GenericSymbExprGrammar.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/GenericSymbExprGrammar.cs	(revision 11856)
+++ 	(revision )
@@ -1,104 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.PluginInfrastructure;
-
-namespace HeuristicLab.Problems.GrammaticalOptimization {
-  [NonDiscoverableType]
-  [StorableClass]
-  [Item("GenericSymbExprGrammar", "Represents a general grammar for grammatical optimization problems.")]
-  public class GenericSymbExprGrammar : SymbolicExpressionGrammar {
-    [StorableClass]
-    [Item("GenericSymbol", "")]
-    public sealed class GenericSymbol : Symbol {
-      private readonly int minimumArity = 1;
-      private readonly int maximumArity = byte.MaxValue;
-
-      public override int MinimumArity { get { return minimumArity; } }
-      public override int MaximumArity { get { return maximumArity; } }
-
-      [StorableConstructor]
-      private GenericSymbol(bool deserializing) : base(deserializing) { }
-      private GenericSymbol(GenericSymbol original, Cloner cloner) : base(original, cloner) { }
-      public override IDeepCloneable Clone(Cloner cloner) {
-        return new GenericSymbol(this, cloner);
-      }
-      public GenericSymbol(char s, int minArity, int maxArity)
-        : base(s.ToString(), string.Empty) {
-        this.minimumArity = minArity;
-        this.maximumArity = maxArity;
-      }
-    }
-
-    [StorableConstructor]
-    public GenericSymbExprGrammar(bool deserializing) : base(deserializing) { }
-
-    public GenericSymbExprGrammar(SymbolicExpressionGrammar original, Cloner cloner) : base(original, cloner) { }
-
-    public GenericSymbExprGrammar(IGrammar grammar)
-      : base(ItemAttribute.GetName(typeof(GenericSymbExprGrammar)), ItemAttribute.GetDescription(typeof(GenericSymbExprGrammar))) {
-
-      var ntSymbs = new List<GenericSymbol>();
-      var tSymbs = new List<GenericSymbol>();
-      // for terminal and nonterminal symbol in the grammar create a symbol class
-      // for non-terminals set the arity and the allowed children
-      // for terminals set arity to 0 and allowed children to empty
-      foreach (var nt in grammar.NonTerminalSymbols) {
-        var ntSymb = CreateSymbol(grammar, nt);
-        AddSymbol(ntSymb);
-        SetSubtreeCount(ntSymb, ntSymb.MinimumArity, ntSymb.MaximumArity);
-        ntSymbs.Add(ntSymb);
-      }
-      foreach (var t in grammar.TerminalSymbols) {
-        var tSymb = new GenericSymbol(t, 0, 0);
-        AddSymbol(tSymb);
-        SetSubtreeCount(tSymb, 0, 0);
-        tSymbs.Add(tSymb);
-      }
-
-      Func<char, GenericSymbol> findSymb = (char s) => {
-        var selectedSymb = ntSymbs.SingleOrDefault(symb => symb.Name == s.ToString());
-        if (selectedSymb != null) return selectedSymb;
-        return tSymbs.SingleOrDefault(symb => symb.Name == s.ToString());
-      };
-
-      // set the sentence symbol as the allowed start symbol
-      AddAllowedChildSymbol(StartSymbol, findSymb(grammar.SentenceSymbol));
-
-      foreach (var nt in ntSymbs) {
-        // either all alts are only a single symbol 
-        // or all alts only use a single symbol (see assertion in CreateSymbol)
-        var alts = grammar.GetAlternatives(nt.Name[0]); // all symbols only have a single character name
-        Debug.Assert(alts.All(alt => alt.Length == 1 || alt.Distinct().Count() == 1));
-
-        foreach (var alt in alts) {
-          Debug.Assert(alt.All(ch => ch == alt[0]));
-          AddAllowedChildSymbol(nt, findSymb(alt.First()));
-        }
-      }
-    }
-
-    private GenericSymbol CreateSymbol(IGrammar g, char s) {
-
-      var minArity = g.GetAlternatives(s).Select(alt => alt.Length).Min();
-      var maxArity = g.GetAlternatives(s).Select(alt => alt.Length).Max();
-      // either the min and max arity is 1 or the alternatives all use the same symbol (hl doesn't know about dependencies between positions in the alternative
-      Debug.Assert(
-        (minArity == 1 && maxArity == 1) ||
-        g.GetAlternatives(s).Select(alt => alt.Distinct()).All(alt => alt.Count() == 1));
-      var symb = new GenericSymbol(s, minArity, maxArity);
-      return symb;
-    }
-
-    public override IDeepCloneable Clone(Cloner cloner) {
-      return new GenericSymbExprGrammar(this, cloner);
-    }
-  }
-}
Index: anches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/GenericSymbExprProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/GenericSymbExprProblem.cs	(revision 11856)
+++ 	(revision )
@@ -1,79 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
-using HeuristicLab.Optimization;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.PluginInfrastructure;
-
-namespace HeuristicLab.Problems.GrammaticalOptimization {
-  [NonDiscoverableType]
-  [StorableClass]
-  [Item("GenericSymbExprProblem", "Represents grammatical optimization problems (using a symbolic expression tree encoding).")]
-  public class GenericSymbExprProblem : SingleObjectiveHeuristicOptimizationProblem<IGrammaticalOptimizationEvaluator, ISymbolicExpressionTreeCreator> {
-    #region string consts
-    private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
-    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
-    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
-
-    #endregion
-
-    #region parameter properties
-    public IValueParameter<ISymbolicExpressionTreeGrammar> SymbolicExpressionTreeGrammarParameter {
-      get { return (IValueParameter<ISymbolicExpressionTreeGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
-    }
-    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
-      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
-    }
-    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
-      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
-    }
-    #endregion
-
-
-    #region properties
-
-    public ISymbolicExpressionTreeGrammar SymbolicExpressionTreeGrammar {
-      get { return SymbolicExpressionTreeGrammarParameter.Value; }
-      set { SymbolicExpressionTreeGrammarParameter.Value = value; }
-    }
-    public IntValue MaximumSymbolicExpressionTreeDepth {
-      get { return MaximumSymbolicExpressionTreeDepthParameter.Value; }
-    }
-    public IntValue MaximumSymbolicExpressionTreeLength {
-      get { return MaximumSymbolicExpressionTreeLengthParameter.Value; }
-    }
-    public new GrammaticalOptimizationEvaluator Evaluator {
-      get { return (GrammaticalOptimizationEvaluator)base.Evaluator; }
-    }
-
-    #endregion
-    [StorableConstructor]
-    public GenericSymbExprProblem(bool deserializing) : base(deserializing) { }
-
-    public GenericSymbExprProblem(GenericSymbExprProblem original, Cloner cloner) : base(original, cloner) { }
-
-    public GenericSymbExprProblem(ISymbolicExpressionTreeProblem problem)
-      : base(new GrammaticalOptimizationEvaluator(problem.ConvertTreeToSentence, problem.Evaluate), new ProbabilisticTreeCreator()) {
-      Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>(SymbolicExpressionTreeGrammarParameterName, problem.SymbolicExpressionGrammar));
-      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, new IntValue(50)));
-      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, new IntValue(15)));
-
-      Maximization = new BoolValue(true);
-      BestKnownQuality = new DoubleValue(1.0);
-
-      Operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
-    }
-
-    public override IDeepCloneable Clone(Cloner cloner) {
-      return new GenericSymbExprProblem(this, cloner);
-    }
-  }
-}
Index: anches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/GrammaticalOptimizationEvaluator.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/GrammaticalOptimizationEvaluator.cs	(revision 11856)
+++ 	(revision )
@@ -1,60 +1,0 @@
-﻿using System;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
-using HeuristicLab.Operators;
-using HeuristicLab.Parameters;
-using HeuristicLab.PluginInfrastructure;
-
-namespace HeuristicLab.Problems.GrammaticalOptimization {
-  // this type is not storable because we use a func<ITree,double> for evaluation, which references back to the original grammatical optimization problem
-  [NonDiscoverableType]
-  [Item("GrammaticalOptimizationEvaluator", "Evaluator for grammatical optimization problems (using a symbolic expression tree encoding).")]
-  public class GrammaticalOptimizationEvaluator : SingleSuccessorOperator, IGrammaticalOptimizationEvaluator {
-    public event Action<string, double> SolutionEvaluated;
-
-    public ILookupParameter<DoubleValue> QualityParameter {
-      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
-    }
-    public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
-      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters["SymbolicExpressionTree"]; }
-    }
-
-    private Func<string, double> evalFunc;
-    private Func<ISymbolicExpressionTree, string> toStringFunc;
-
-    public GrammaticalOptimizationEvaluator(GrammaticalOptimizationEvaluator original, Cloner cloner)
-      : base(original, cloner) {
-      this.evalFunc = original.evalFunc;
-    }
-
-    public GrammaticalOptimizationEvaluator(Func<ISymbolicExpressionTree, string> toStringFunc, Func<string, double> evalFunc)
-      : base() {
-      Parameters.Add(new LookupParameter<DoubleValue>("Quality"));
-      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>("SymbolicExpressionTree"));
-      this.evalFunc = evalFunc;
-      this.toStringFunc = toStringFunc;
-    }
-
-    public override IDeepCloneable Clone(Cloner cloner) {
-      return new GrammaticalOptimizationEvaluator(this, cloner);
-    }
-
-    public override IOperation Apply() {
-      var tree = SymbolicExpressionTreeParameter.ActualValue;
-      var sentence = toStringFunc(tree);
-      var q = evalFunc(sentence);
-      QualityParameter.ActualValue = new DoubleValue(q);
-
-      RaiseSolutionEvaluated(sentence, q);
-
-      return base.Apply();
-    }
-
-    private void RaiseSolutionEvaluated(string sentence, double quality) {
-      var handler = SolutionEvaluated;
-      if (handler != null) handler(sentence, quality);
-    }
-  }
-}
Index: anches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/IGrammaticalOptimizationEvaluator.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/IGrammaticalOptimizationEvaluator.cs	(revision 11856)
+++ 	(revision )
@@ -1,18 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
-using HeuristicLab.Optimization;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.PluginInfrastructure;
-
-namespace HeuristicLab.Problems.GrammaticalOptimization {
-  public interface IGrammaticalOptimizationEvaluator : ISingleObjectiveEvaluator, ISymbolicExpressionTreeOperator {
-    ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; } 
-  }
-}
Index: /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/ISymbolicExpressionTreeProblem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/ISymbolicExpressionTreeProblem.cs	(revision 11856)
+++ /branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/TreeRepresentation/ISymbolicExpressionTreeProblem.cs	(revision 11857)
@@ -8,6 +8,5 @@
   // represents a grammatical optimization problem that can also be used with tree-based GP in HeuristicLab
   public interface ISymbolicExpressionTreeProblem : IProblem {
-    ISymbolicExpressionGrammar SymbolicExpressionGrammar { get; } // grammar for HL GP
-
+    IGrammar TreeBasedGPGrammar { get; } // grammar for HL GP
     string ConvertTreeToSentence(ISymbolicExpressionTree tree);
   }
