Index: branches/HeuristicLab.Problems.GrammaticalOptimization/GrammaticalOptimization.sln
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/GrammaticalOptimization.sln	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/GrammaticalOptimization.sln	(revision 11981)
@@ -21,4 +21,41 @@
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{8B4C199E-C08B-479E-9B82-6AE5B113459E}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HeuristicLab", "HeuristicLab", "{FE0B0799-C3D4-407C-9DD2-899BCDA7AB9A}"
+	ProjectSection(SolutionItems) = preProject
+		HeuristicLab\ALGLIB-3.7.0.dll = HeuristicLab\ALGLIB-3.7.0.dll
+		HeuristicLab\AutoDiff-1.0.dll = HeuristicLab\AutoDiff-1.0.dll
+		HeuristicLab\HeuristicLab.Algorithms.Bandits.dll = HeuristicLab\HeuristicLab.Algorithms.Bandits.dll
+		HeuristicLab\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll = HeuristicLab\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll
+		HeuristicLab\HeuristicLab.Algorithms.GeneticProgramming.dll = HeuristicLab\HeuristicLab.Algorithms.GeneticProgramming.dll
+		HeuristicLab\HeuristicLab.Algorithms.GrammaticalOptimization.dll = HeuristicLab\HeuristicLab.Algorithms.GrammaticalOptimization.dll
+		HeuristicLab\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll = HeuristicLab\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll
+		HeuristicLab\HeuristicLab.Analysis-3.3.dll = HeuristicLab\HeuristicLab.Analysis-3.3.dll
+		HeuristicLab\HeuristicLab.Collections-3.3.dll = HeuristicLab\HeuristicLab.Collections-3.3.dll
+		HeuristicLab\HeuristicLab.Common-3.3.dll = HeuristicLab\HeuristicLab.Common-3.3.dll
+		HeuristicLab\HeuristicLab.Common.dll = HeuristicLab\HeuristicLab.Common.dll
+		HeuristicLab\HeuristicLab.Common.Resources-3.3.dll = HeuristicLab\HeuristicLab.Common.Resources-3.3.dll
+		HeuristicLab\HeuristicLab.Core-3.3.dll = HeuristicLab\HeuristicLab.Core-3.3.dll
+		HeuristicLab\HeuristicLab.Data-3.3.dll = HeuristicLab\HeuristicLab.Data-3.3.dll
+		HeuristicLab\HeuristicLab.Distributions.dll = HeuristicLab\HeuristicLab.Distributions.dll
+		HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll = HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll
+		HeuristicLab\HeuristicLab.Operators-3.3.dll = HeuristicLab\HeuristicLab.Operators-3.3.dll
+		HeuristicLab\HeuristicLab.Operators.Programmable-3.3.dll = HeuristicLab\HeuristicLab.Operators.Programmable-3.3.dll
+		HeuristicLab\HeuristicLab.Optimization-3.3.dll = HeuristicLab\HeuristicLab.Optimization-3.3.dll
+		HeuristicLab\HeuristicLab.Optimization.Operators-3.3.dll = HeuristicLab\HeuristicLab.Optimization.Operators-3.3.dll
+		HeuristicLab\HeuristicLab.ParallelEngine-3.3.dll = HeuristicLab\HeuristicLab.ParallelEngine-3.3.dll
+		HeuristicLab\HeuristicLab.Parameters-3.3.dll = HeuristicLab\HeuristicLab.Parameters-3.3.dll
+		HeuristicLab\HeuristicLab.Persistence-3.3.dll = HeuristicLab\HeuristicLab.Persistence-3.3.dll
+		HeuristicLab\HeuristicLab.PluginInfrastructure-3.3.dll = HeuristicLab\HeuristicLab.PluginInfrastructure-3.3.dll
+		HeuristicLab\HeuristicLab.Problems.DataAnalysis-3.4.dll = HeuristicLab\HeuristicLab.Problems.DataAnalysis-3.4.dll
+		HeuristicLab\HeuristicLab.Problems.GrammaticalOptimization.dll = HeuristicLab\HeuristicLab.Problems.GrammaticalOptimization.dll
+		HeuristicLab\HeuristicLab.Problems.GrammaticalOptimization.SymbReg.dll = HeuristicLab\HeuristicLab.Problems.GrammaticalOptimization.SymbReg.dll
+		HeuristicLab\HeuristicLab.Problems.Instances-3.3.dll = HeuristicLab\HeuristicLab.Problems.Instances-3.3.dll
+		HeuristicLab\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll = HeuristicLab\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll
+		HeuristicLab\HeuristicLab.Random-3.3.dll = HeuristicLab\HeuristicLab.Random-3.3.dll
+		HeuristicLab\HeuristicLab.Selection-3.3.dll = HeuristicLab\HeuristicLab.Selection-3.3.dll
+		HeuristicLab\HeuristicLab.SequentialEngine-3.3.dll = HeuristicLab\HeuristicLab.SequentialEngine-3.3.dll
+		HeuristicLab\HeuristicLab.Tracing-3.3.dll = HeuristicLab\HeuristicLab.Tracing-3.3.dll
+	EndProjectSection
 EndProject
 Global
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/Policies/UCTPolicy.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/Policies/UCTPolicy.cs	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.Bandits/Policies/UCTPolicy.cs	(revision 11981)
@@ -19,5 +19,4 @@
     public int SelectAction(Random random, IEnumerable<IBanditPolicyActionInfo> actionInfos) {
       var myActionInfos = actionInfos.OfType<DefaultPolicyActionInfo>();
-      int bestAction = -1;
       double bestQ = double.NegativeInfinity;
       int totalTries = myActionInfos.Sum(a => a.Tries);
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GeneticProgramming/HeuristicLab.Algorithms.GeneticProgramming.csproj	(revision 11981)
@@ -31,54 +31,67 @@
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll</HintPath>
     </Reference>
     <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
+      <HintPath>..\HeuristicLab\HeuristicLab.Analysis-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Collections-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Collections-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Common-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Common-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Core-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Core-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Data-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Data-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
+    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Operators-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Operators-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Optimization-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Optimization-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.ParallelEngine-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.ParallelEngine-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.ParallelEngine-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.ParallelEngine-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Parameters-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\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>
+      <HintPath>..\HeuristicLab\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>
+      <HintPath>..\HeuristicLab\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Selection-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Selection-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Selection-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Selection-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.SequentialEngine-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.SequentialEngine-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
     </Reference>
     <Reference Include="System" />
@@ -98,5 +111,5 @@
   <ItemGroup>
     <ProjectReference Include="..\HeuristicLab.Algorithms.GrammaticalOptimization\HeuristicLab.Algorithms.GrammaticalOptimization.csproj">
-      <Project>{eea07488-1a51-412a-a52c-53b754a628b3}</Project>
+      <Project>{EEA07488-1A51-412A-A52C-53B754A628B3}</Project>
       <Name>HeuristicLab.Algorithms.GrammaticalOptimization</Name>
     </ProjectReference>
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization.csproj
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization.csproj	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization.csproj	(revision 11981)
@@ -39,17 +39,12 @@
   <ItemGroup>
     <Compile Include="ISequentialDecisionPolicy.cs" />
-    <Compile Include="SequentialDecisionPolicies\GenericContextualGrammarPolicy.cs" />
     <Compile Include="SequentialDecisionPolicies\GenericFunctionApproximationGrammarPolicy.cs" />
     <Compile Include="SequentialDecisionPolicies\GenericGrammarPolicy.cs" />
-    <Compile Include="SequentialDecisionPolicies\GenericTDPolicy.cs" />
     <Compile Include="SequentialDecisionPolicies\GrammarPolicy.cs" />
     <Compile Include="SequentialDecisionPolicies\IGrammarPolicy.cs" />
     <Compile Include="SequentialDecisionPolicies\RandomPolicy.cs" />
-    <Compile Include="SequentialDecisionPolicies\TDPolicy.cs" />
     <Compile Include="SolverBase.cs" />
     <Compile Include="ISolver.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Solvers\AlternativesContextSampler.cs" />
-    <Compile Include="Solvers\AlternativesSampler.cs" />
     <Compile Include="Solvers\ExhaustiveBreadthFirstSearch.cs" />
     <Compile Include="Solvers\ExhaustiveDepthFirstSearch.cs" />
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/GenericContextualGrammarPolicy.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/GenericContextualGrammarPolicy.cs	(revision 11980)
+++ 	(revision )
@@ -1,163 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.ExceptionServices;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading;
-using System.Threading.Tasks;
-using HeuristicLab.Common;
-using HeuristicLab.Problems.GrammaticalOptimization;
-
-namespace HeuristicLab.Algorithms.Bandits.GrammarPolicies {
-  public sealed class GenericContextualGrammarPolicy : IGrammarPolicy {
-    private Dictionary<string, IBanditPolicyActionInfo> stateInfo; // stores the necessary information for bandit policies for each state (=canonical phrase)
-    private HashSet<string> done;
-    private readonly bool useCanonicalPhrases;
-    private readonly IProblem problem;
-    private readonly IBanditPolicy banditPolicy;
-
-    public GenericContextualGrammarPolicy(IProblem problem, IBanditPolicy banditPolicy, bool useCanonicalPhrases = false) {
-      this.useCanonicalPhrases = useCanonicalPhrases;
-      this.problem = problem;
-      this.banditPolicy = banditPolicy;
-      this.stateInfo = new Dictionary<string, IBanditPolicyActionInfo>();
-      this.done = new HashSet<string>();
-    }
-
-    private IBanditPolicyActionInfo[] activeAfterStates; // don't allocate each time
-    private int[] actionIndexMap; // don't allocate each time
-
-    public bool TrySelect(Random random, string curState, IEnumerable<string> afterStates, out int selectedStateIdx) {
-      // fail if all states are done (corresponding state infos are disabled)
-      if (afterStates.All(s => Done(s))) {
-        // fail because all follow states have already been visited => also disable the current state (if we can be sure that it has been fully explored)
-        MarkAsDone(curState);
-
-        selectedStateIdx = -1;
-        return false;
-      }
-
-      // determine active actions (not done yet) and create an array to map the selected index back to original actions
-      if (activeAfterStates == null || activeAfterStates.Length < afterStates.Count()) {
-        activeAfterStates = new IBanditPolicyActionInfo[afterStates.Count()];
-        actionIndexMap = new int[afterStates.Count()];
-      }
-      var idx = 0; int originalIdx = 0;
-      foreach (var afterState in afterStates) {
-        if (!Done(afterState)) {
-          activeAfterStates[idx] = GetStateInfo(afterState);
-          actionIndexMap[idx] = originalIdx;
-          idx++;
-        }
-        originalIdx++;
-      }
-
-      selectedStateIdx = actionIndexMap[banditPolicy.SelectAction(random, activeAfterStates.Take(idx))];
-
-      return true;
-    }
-
-
-    private IBanditPolicyActionInfo GetStateInfo(string state) {
-      var s = Context(state);
-      IBanditPolicyActionInfo info;
-      if (!stateInfo.TryGetValue(s, out info)) {
-        info = banditPolicy.CreateActionInfo();
-        stateInfo[s] = info;
-      }
-      return info;
-    }
-
-    private string Context(string state) {
-      // var cutOff = problem.Grammar.IsTerminal(state) ? 0 : 2;
-      // var contextLen = 7;
-      // var firstPos = Math.Max(0, state.Length - contextLen - cutOff);
-      // var lastPos = Math.Max(0, Math.Min(state.Length, state.Length - cutOff));
-      // var context = state.Substring(firstPos, (lastPos - firstPos));
-      var contextLen = 5;
-      var firstPos = Math.Max(0, state.Length - contextLen);
-      var lastPos = Math.Min(state.Length, firstPos + contextLen);
-      var context = state.Substring(firstPos, (lastPos - firstPos));
-      return context + Regex.Matches(state, "(?=" + Regex.Escape(context) + ")").Count;
-
-
-      //var lastPlusPos = Math.Max(0, state.LastIndexOf('+') + 1);
-      //var context = state.Substring(lastPlusPos);
-      //return context + Regex.Matches(state, "(?=" + Regex.Escape(context) + ")").Count; 
-    }
-
-    public void UpdateReward(IEnumerable<string> stateTrajectory, double reward) {
-      foreach (var state in stateTrajectory) {
-        GetStateInfo(state).UpdateReward(reward);
-
-        // only the last state can be terminal
-        if (problem.Grammar.IsTerminal(state)) {
-          MarkAsDone(state);
-        }
-      }
-    }
-
-
-    public void Reset() {
-      stateInfo.Clear();
-      done.Clear();
-    }
-
-    public int GetTries(string state) {
-      var s = Context(state);
-      if (stateInfo.ContainsKey(s)) return stateInfo[s].Tries;
-      else return 0;
-    }
-
-    public double GetValue(string state) {
-      var s = Context(state);
-      if (stateInfo.ContainsKey(s)) return stateInfo[s].Value;
-      else return 0.0; // TODO: check alternatives
-    }
-
-    // the canonical states for the value function (banditInfos) and the done set must be distinguished
-    // sequences of different length could have the same canonical representation and can have the same value (banditInfo)
-    // however, if the canonical representation of a state is shorter than we must not mark the canonical state as done when all possible derivations from the initial state have been explored
-    // eg. in the ant problem the canonical representation for ...lllA is ...rA
-    // even though all possible derivations (of limited length) of lllA have been visited we must not mark the state rA as done
-    private void MarkAsDone(string state) {
-      var s = CanonicalState(state);
-      // when the lengths of the canonical string and the original string are the same we also disable the actions
-      // always disable terminals
-      Debug.Assert(s.Length <= state.Length);
-      if (s.Length == state.Length || problem.Grammar.IsTerminal(state)) {
-        Debug.Assert(!done.Contains(s));
-        done.Add(s);
-      } else {
-        // for non-terminals where the canonical string is shorter than the original string we can only disable the canonical representation for all states in the same level
-        Debug.Assert(!done.Contains(s + state.Length));
-        done.Add(s + state.Length); // encode the original length of the state, states in the same level of the tree are treated as equivalent
-      }
-    }
-
-    // symmetric to MarkDone
-    private bool Done(string state) {
-      var s = CanonicalState(state);
-      if (s.Length == state.Length || problem.Grammar.IsTerminal(state)) {
-        return done.Contains(s);
-      } else {
-        // it is not necessary to visit states if the canonical representation has already been fully explored
-        if (done.Contains(s)) return true;
-        if (done.Contains(s + state.Length)) return true;
-        for (int i = 1; i < state.Length; i++) {
-          if (done.Contains(s + i)) return true;
-        }
-        return false;
-      }
-    }
-
-    private string CanonicalState(string state) {
-      if (useCanonicalPhrases) {
-        return problem.CanonicalRepresentation(state);
-      } else
-        return state;
-    }
-  }
-}
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/GenericFunctionApproximationGrammarPolicy.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/GenericFunctionApproximationGrammarPolicy.cs	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/GenericFunctionApproximationGrammarPolicy.cs	(revision 11981)
@@ -60,19 +60,8 @@
         originalIdx++;
       }
-
-      
-      /*
-      const double beta = 10;
-      var w = from idx in Enumerable.Range(0, maxIdx)
-              let afterStateQ = activeAfterStates[idx]
-              select Math.Exp(beta * afterStateQ);
-
-      var bestAction = Enumerable.Range(0, maxIdx).SampleProportional(random, w);
-      selectedStateIdx = actionIndexMap[bestAction];
-      Debug.Assert(selectedStateIdx >= 0);
-      */
       
       
-      if (random.NextDouble() < 0.5) {
+      // TODO: policy should be a parameter of the function approximation policy
+      if (random.NextDouble() < 0.2) {
         selectedStateIdx = actionIndexMap[random.Next(maxIdx)];
       } else {
@@ -139,6 +128,4 @@
     private void UpdateWeights(string state, double reward) {
       double delta = reward - GetValue(state);
-      // delta /= problem.GetFeatures(state).Count();
-      //const double alpha = 0.001;
       foreach (var feature in problem.GetFeatures(state)) {
         featureTries[feature.Id] = GetFeatureTries(feature.Id) + 1;
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/GenericTDPolicy.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/GenericTDPolicy.cs	(revision 11980)
+++ 	(revision )
@@ -1,153 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using HeuristicLab.Algorithms.Bandits.BanditPolicies;
-using HeuristicLab.Common;
-using HeuristicLab.Problems.GrammaticalOptimization;
-
-namespace HeuristicLab.Algorithms.Bandits.GrammarPolicies {
-  public sealed class GenericTDPolicy : IGrammarPolicy {
-    private Dictionary<string, IBanditPolicyActionInfo> stateInfo; // stores the necessary information for bandit policies for each state (=canonical phrase)
-    private HashSet<string> done;
-    private readonly bool useCanonicalPhrases;
-    private readonly IProblem problem;
-    private readonly IBanditPolicy banditPolicy;
-
-    public GenericTDPolicy(IProblem problem, bool useCanonicalPhrases = false) {
-      this.useCanonicalPhrases = useCanonicalPhrases;
-      this.problem = problem;
-      this.banditPolicy = new EpsGreedyPolicy(0.1);
-      this.stateInfo = new Dictionary<string, IBanditPolicyActionInfo>();
-      this.done = new HashSet<string>();
-    }
-
-    private IBanditPolicyActionInfo[] activeAfterStates; // don't allocate each time
-    private int[] actionIndexMap; // don't allocate each time
-
-    public bool TrySelect(Random random, string curState, IEnumerable<string> afterStates, out int selectedStateIdx) {
-      // fail if all states are done (corresponding state infos are disabled)
-      if (afterStates.All(s => Done(s))) {
-        // fail because all follow states have already been visited => also disable the current state (if we can be sure that it has been fully explored)
-        MarkAsDone(curState);
-
-        selectedStateIdx = -1;
-        return false;
-      }
-
-      // determine active actions (not done yet) and create an array to map the selected index back to original actions
-      if (activeAfterStates == null || activeAfterStates.Length < afterStates.Count()) {
-        activeAfterStates = new IBanditPolicyActionInfo[afterStates.Count()];
-        actionIndexMap = new int[afterStates.Count()];
-      }
-      var idx = 0; int originalIdx = 0;
-      foreach (var afterState in afterStates) {
-        if (!Done(afterState)) {
-          activeAfterStates[idx] = GetStateInfo(afterState);
-          actionIndexMap[idx] = originalIdx;
-          idx++;
-        }
-        originalIdx++;
-      }
-
-      selectedStateIdx = actionIndexMap[banditPolicy.SelectAction(random, activeAfterStates.Take(idx))];
-      
-      
-      GetStateInfo(curState).UpdateReward(afterStates.Select(s=>GetStateInfo(s).Value).Max());
-
-      return true;
-    }
-
-
-
-    private IBanditPolicyActionInfo GetStateInfo(string state) {
-      var s = CanonicalState(state);
-      IBanditPolicyActionInfo info;
-      if (!stateInfo.TryGetValue(s, out info)) {
-        info = banditPolicy.CreateActionInfo();
-        stateInfo[s] = info;
-      }
-      return info;
-    }
-
-    public void UpdateReward(IEnumerable<string> stateTrajectory, double reward) {
-
-      foreach (var state in stateTrajectory.Zip(stateTrajectory.Skip(1), Tuple.Create)) {
-        var parent = state.Item1;
-        var child = state.Item2;
-
-        // only the last state can be terminal
-        if (problem.Grammar.IsTerminal(child)) {
-          MarkAsDone(child);
-        }
-        // GetStateInfo(parent).UpdateReward(GetValue(child));
-
-      }
-
-      GetStateInfo(stateTrajectory.Last()).UpdateReward(reward);
-    }
-
-
-    public void Reset() {
-      stateInfo.Clear();
-      done.Clear();
-    }
-
-    public int GetTries(string state) {
-      var s = CanonicalState(state);
-      if (stateInfo.ContainsKey(s)) return stateInfo[s].Tries;
-      else return 0;
-    }
-
-    public double GetValue(string state) {
-      var s = CanonicalState(state);
-      if (stateInfo.ContainsKey(s)) return stateInfo[s].Value;
-      else return 0.0; // TODO: check alternatives
-    }
-
-    // the canonical states for the value function (banditInfos) and the done set must be distinguished
-    // sequences of different length could have the same canonical representation and can have the same value (banditInfo)
-    // however, if the canonical representation of a state is shorter than we must not mark the canonical state as done when all possible derivations from the initial state have been explored
-    // eg. in the ant problem the canonical representation for ...lllA is ...rA
-    // even though all possible derivations (of limited length) of lllA have been visited we must not mark the state rA as done
-    private void MarkAsDone(string state) {
-      var s = CanonicalState(state);
-      // when the lengths of the canonical string and the original string are the same we also disable the actions
-      // always disable terminals
-      Debug.Assert(s.Length <= state.Length);
-      if (s.Length == state.Length || problem.Grammar.IsTerminal(state)) {
-        Debug.Assert(!done.Contains(s));
-        done.Add(s);
-      } else {
-        // for non-terminals where the canonical string is shorter than the original string we can only disable the canonical representation for all states in the same level
-        Debug.Assert(!done.Contains(s + state.Length));
-        done.Add(s + state.Length); // encode the original length of the state, states in the same level of the tree are treated as equivalent
-      }
-    }
-
-    // symmetric to MarkDone
-    private bool Done(string state) {
-      var s = CanonicalState(state);
-      if (s.Length == state.Length || problem.Grammar.IsTerminal(state)) {
-        return done.Contains(s);
-      } else {
-        // it is not necessary to visit states if the canonical representation has already been fully explored
-        if (done.Contains(s)) return true;
-        if (done.Contains(s + state.Length)) return true;
-        for (int i = 1; i < state.Length; i++) {
-          if (done.Contains(s + i)) return true;
-        }
-        return false;
-      }
-    }
-
-    private string CanonicalState(string state) {
-      if (useCanonicalPhrases) {
-        return problem.CanonicalRepresentation(state);
-      } else
-        return state;
-    }
-  }
-}
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/TDPolicy.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/SequentialDecisionPolicies/TDPolicy.cs	(revision 11980)
+++ 	(revision )
@@ -1,98 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Diagnostics;
-using System.Linq;
-using System.Security.Policy;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using HeuristicLab.Algorithms.Bandits.BanditPolicies;
-using HeuristicLab.Common;
-using HeuristicLab.Problems.GrammaticalOptimization;
-
-namespace HeuristicLab.Algorithms.Bandits.GrammarPolicies {
-  public class TDPolicy : GrammarPolicy {
-
-    private readonly HashSet<string> done;
-    private readonly Dictionary<string, double> v;
-    private IGrammarPolicy epsGreedy;
-
-    public TDPolicy(IProblem problem, bool useCanonicalRepresentation = false)
-      : base(problem, useCanonicalRepresentation) {
-      this.done = new HashSet<string>();
-      this.v = new Dictionary<string, double>();
-      this.epsGreedy = new GenericGrammarPolicy(problem, new EpsGreedyPolicy(0.1), useCanonicalRepresentation);
-    }
-
-    public override bool TrySelect(Random random, string curState, IEnumerable<string> afterStates, out int selectedStateIdx) {
-      // only select states that are not yet done
-      afterStates = afterStates.Where(a => !done.Contains(CanonicalState(a.ToString()))).ToArray();
-      if (!afterStates.Any()) {
-        // fail because all follow states have already been visited => also disable the current state
-        done.Add(CanonicalState(curState));
-        selectedStateIdx = -1;
-        return false;
-      }
-      throw new NotImplementedException(); // TODO: remap indices of reduced action enumerable to indices of original enumerable (see genericgrammarpolicy)
-
-      //return epsGreedy.TrySelect(random, curState, afterStates, out selectedState);
-
-      var bestQ = double.NegativeInfinity;
-      int idx = -1;
-      selectedStateIdx = -1;
-      foreach (var state in afterStates) {
-        idx++;
-        // try each state at least once
-        if (GetTries(state) == 0) {
-          selectedStateIdx = idx;
-          return true;
-        }
-        var q = V(state);
-        if (q > bestQ) {
-          bestQ = q;
-          selectedStateIdx = idx;
-        }
-      }
-
-      Debug.Assert(selectedStateIdx > -1);
-      return true;
-    }
-
-    private double V(string state) {
-      var s = CanonicalState(state);
-      if (v.ContainsKey(s)) return v[s];
-      else return 0.0;
-    }
-
-    public override void UpdateReward(IEnumerable<string> stateTrajectory, double reward) {
-      base.UpdateReward(stateTrajectory, reward);
-      epsGreedy.UpdateReward(stateTrajectory, reward);
-      // the last state could be terminal
-      var lastState = stateTrajectory.Last();
-      if (problem.Grammar.IsTerminal(lastState)) done.Add(CanonicalState(lastState));
-
-      v[CanonicalState(lastState)] = V(lastState) + 1.0 / GetTries(lastState) * (reward - V(lastState));
-
-      foreach (var p in stateTrajectory.Zip(stateTrajectory.Skip(1), Tuple.Create).Reverse()) {
-        var cur = p.Item1;
-        var next = p.Item2;
-
-        v[CanonicalState(cur)] = V(cur) + 1.0 / GetTries(cur) * (V(next) - V(cur));
-        //v[CanonicalState(cur.ToString())] = V(cur) + 0.1 * (V(next) - V(cur));
-      }
-
-    }
-
-    public override double GetValue(string state) {
-      return V(state);
-    }
-
-    public override void Reset() {
-      base.Reset();
-      epsGreedy.Reset();
-      v.Clear();
-      done.Clear();
-    }
-  }
-}
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/Solvers/AlternativesContextSampler.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/Solvers/AlternativesContextSampler.cs	(revision 11980)
+++ 	(revision )
@@ -1,118 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Algorithms.Bandits;
-using HeuristicLab.Common;
-using HeuristicLab.Problems.GrammaticalOptimization;
-
-namespace HeuristicLab.Algorithms.GrammaticalOptimization {
-  public class AlternativesContextSampler {
-    public event Action<string, double> FoundNewBestSolution;
-    public event Action<string, double> SolutionEvaluated;
-
-    private readonly int maxLen;
-    private readonly IProblem problem;
-    private readonly Random random;
-    private readonly int contextLen;
-    private readonly IBanditPolicy policy;
-
-    public AlternativesContextSampler(IProblem problem, Random random, int maxLen, int contextLen, IBanditPolicy policy) {
-      this.maxLen = maxLen;
-      this.problem = problem;
-      this.random = random;
-      this.contextLen = contextLen;
-      this.policy = policy;
-    }
-
-    public void Run(int maxIterations) {
-      double bestQuality = double.MinValue;
-      InitPolicies(problem.Grammar);
-      for (int i = 0; i < maxIterations; i++) {
-        var sentence = SampleSentence(problem.Grammar).ToString();
-        var quality = problem.Evaluate(sentence) / problem.BestKnownQuality(maxLen);
-        DistributeReward(quality);
-
-        RaiseSolutionEvaluated(sentence, quality);
-
-        if (quality > bestQuality) {
-          bestQuality = quality;
-          RaiseFoundNewBestSolution(sentence, quality);
-        }
-      }
-    }
-
-
-    private Dictionary<string, IBanditPolicyActionInfo[]> contextActionInfos;
-    private List<Tuple<string, int>> updateChain;
-
-    private void InitPolicies(IGrammar grammar) {
-      this.contextActionInfos = new Dictionary<string, IBanditPolicyActionInfo[]>();
-      this.updateChain = new List<Tuple<string, int>>();
-    }
-
-    private Sequence SampleSentence(IGrammar grammar) {
-      updateChain.Clear();
-      return CompleteSentence(grammar, new Sequence(grammar.SentenceSymbol));
-    }
-
-    public Sequence CompleteSentence(IGrammar g, Sequence phrase) {
-      if (phrase.Length > maxLen) throw new ArgumentException();
-      if (g.MinPhraseLength(phrase) > maxLen) throw new ArgumentException();
-      bool done = phrase.IsTerminal; // terminal phrase means we are done
-      while (!done) {
-        char nt = phrase.FirstNonTerminal;
-
-        int maxLenOfReplacement = maxLen - (phrase.Length - 1); // replacing aAb with maxLen 4 means we can only use alternatives with a minPhraseLen <= 2
-        Debug.Assert(maxLenOfReplacement > 0);
-
-        var alts = g.GetAlternatives(nt);
-        Sequence selectedAlt;
-        // if the choice is restricted then one of the allowed alternatives is selected randomly
-        if (alts.Any(alt => g.MinPhraseLength(alt) > maxLenOfReplacement)) {
-          var allowedAlts = alts.Where(alt => g.MinPhraseLength(alt) <= maxLenOfReplacement);
-          Debug.Assert(allowedAlts.Any());
-          // replace nt with random alternative
-          selectedAlt = allowedAlts.SelectRandom(random);
-        } else {
-          // all alts are allowed => select using bandit policy
-          var ntIdx = phrase.FirstNonTerminalIndex;
-          var startIdx = Math.Max(0, ntIdx - contextLen);
-          var endIdx = Math.Min(startIdx + contextLen, ntIdx);
-          var lft = phrase.Subsequence(startIdx, endIdx - startIdx + 1).ToString();
-          lft = problem.CanonicalRepresentation(lft);
-          if (!contextActionInfos.ContainsKey(lft)) {
-            contextActionInfos.Add(lft, g.GetAlternatives(nt).Select(_ => policy.CreateActionInfo()).ToArray());
-          }
-          var selectedAltIdx = policy.SelectAction(random, contextActionInfos[lft]);
-          selectedAlt = alts.ElementAt(selectedAltIdx);
-          updateChain.Add(Tuple.Create(lft, selectedAltIdx));
-        }
-
-        // replace nt with alt
-        phrase.ReplaceAt(phrase.FirstNonTerminalIndex, 1, selectedAlt);
-
-        done = phrase.IsTerminal; // terminal phrase means we are done
-      }
-      return phrase;
-    }
-
-    private void DistributeReward(double reward) {
-      foreach (var e in updateChain) {
-        var lft = e.Item1;
-        var action = e.Item2;
-        contextActionInfos[lft][action].UpdateReward(reward);
-      }
-    }
-
-    private void RaiseSolutionEvaluated(string sentence, double quality) {
-      var handler = SolutionEvaluated;
-      if (handler != null) handler(sentence, quality);
-    }
-    private void RaiseFoundNewBestSolution(string sentence, double quality) {
-      var handler = FoundNewBestSolution;
-      if (handler != null) handler(sentence, quality);
-    }
-  }
-}
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/Solvers/AlternativesSampler.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.GrammaticalOptimization/Solvers/AlternativesSampler.cs	(revision 11980)
+++ 	(revision )
@@ -1,112 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using HeuristicLab.Algorithms.Bandits;
-using HeuristicLab.Common;
-using HeuristicLab.Problems.GrammaticalOptimization;
-
-namespace HeuristicLab.Algorithms.GrammaticalOptimization {
-  public class AlternativesSampler {
-    public event Action<string, double> FoundNewBestSolution;
-    public event Action<string, double> SolutionEvaluated;
-
-    private readonly int maxLen;
-    private readonly Random random;
-    private readonly IProblem problem;
-    private readonly IBanditPolicy policy;
-
-    public AlternativesSampler(IProblem problem, IBanditPolicy policy, int maxLen) {
-      this.problem = problem;
-      this.maxLen = maxLen;
-      this.random = new Random();
-      this.policy = policy;
-    }
-
-    public void Run(int maxIterations) {
-      double bestQuality = double.MinValue;
-      InitPolicies(problem.Grammar);
-      for (int i = 0; i < maxIterations; i++) {
-        var sentence = SampleSentence(problem.Grammar).ToString();
-        var quality = problem.Evaluate(sentence) / problem.BestKnownQuality(maxLen);
-        DistributeReward(quality);
-
-        RaiseSolutionEvaluated(sentence, quality);
-
-        if (quality > bestQuality) {
-          bestQuality = quality;
-          RaiseFoundNewBestSolution(sentence, quality);
-        }
-      }
-    }
-
-
-    private Dictionary<char, IBanditPolicyActionInfo[]> ntActionInfos;
-    private List<Tuple<char, int>> updateChain;
-
-    private void InitPolicies(IGrammar grammar) {
-      this.ntActionInfos = new Dictionary<char, IBanditPolicyActionInfo[]>();
-      this.updateChain = new List<Tuple<char, int>>();
-      foreach (var nt in grammar.NonTerminalSymbols) {
-        ntActionInfos.Add(nt, grammar.GetAlternatives(nt).Select(_ => policy.CreateActionInfo()).ToArray());
-      }
-    }
-
-    private Sequence SampleSentence(IGrammar grammar) {
-      updateChain.Clear();
-      return CompleteSentence(grammar, new Sequence(grammar.SentenceSymbol));
-    }
-
-    public Sequence CompleteSentence(IGrammar g, Sequence phrase) {
-      if (phrase.Length > maxLen) throw new ArgumentException();
-      if (g.MinPhraseLength(phrase) > maxLen) throw new ArgumentException();
-      bool done = phrase.IsTerminal; // terminal phrase means we are done
-      while (!done) {
-        char nt = phrase.FirstNonTerminal;
-
-        int maxLenOfReplacement = maxLen - (phrase.Length - 1); // replacing aAb with maxLen 4 means we can only use alternatives with a minPhraseLen <= 2
-        Debug.Assert(maxLenOfReplacement > 0);
-
-        var alts = g.GetAlternatives(nt);
-        Sequence selectedAlt;
-        // if the choice is restricted then one of the allowed alternatives is selected randomly
-        if (alts.Any(alt => g.MinPhraseLength(alt) > maxLenOfReplacement)) {
-          var allowedAlts = alts.Where(alt => g.MinPhraseLength(alt) <= maxLenOfReplacement);
-          Debug.Assert(allowedAlts.Any());
-          // replace nt with random alternative
-          selectedAlt = allowedAlts.SelectRandom(random);
-        } else {
-          // all alts are allowed => select using bandit policy
-          var selectedAltIdx = policy.SelectAction(random, ntActionInfos[nt]);
-          selectedAlt = alts.ElementAt(selectedAltIdx);
-          updateChain.Add(Tuple.Create(nt, selectedAltIdx));
-        }
-
-        // replace nt with alt
-        phrase.ReplaceAt(phrase.FirstNonTerminalIndex, 1, selectedAlt);
-
-        done = phrase.IsTerminal; // terminal phrase means we are done
-      }
-      return phrase;
-    }
-
-
-    private void DistributeReward(double reward) {
-      foreach (var e in updateChain) {
-        var nt = e.Item1;
-        var action = e.Item2;
-        ntActionInfos[nt][action].UpdateReward(reward);
-      }
-    }
-
-    private void RaiseSolutionEvaluated(string sentence, double quality) {
-      var handler = SolutionEvaluated;
-      if (handler != null) handler(sentence, quality);
-    }
-    private void RaiseFoundNewBestSolution(string sentence, double quality) {
-      var handler = FoundNewBestSolution;
-      if (handler != null) handler(sentence, quality);
-    }
-  }
-}
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Common/ConsoleEx.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Common/ConsoleEx.cs	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Common/ConsoleEx.cs	(revision 11981)
@@ -10,4 +10,5 @@
 namespace HeuristicLab.Common {
   // for controlling console colors
+  // see output of Solvers (PrintStats)
   // http://stackoverflow.com/questions/25274019/strange-setconsolescreenbufferinfoex-behavior
   public class ConsoleEx {
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Common/ExpressionExtender.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Common/ExpressionExtender.cs	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Common/ExpressionExtender.cs	(revision 11981)
@@ -11,4 +11,5 @@
 namespace HeuristicLab.Algorithms.Bandits {
   // helper to create canonical forms of expressions
+  // NOTE: Not implemented yet (see unit test for divisions)
   // TODO: change symbolicregressionpoly10problem to use this class
   // this does not support expressions with constants (in transformations we assume constant opt is used)
@@ -30,4 +31,5 @@
 
     public string CanonicalRepresentation(string phrase) {
+      throw new NotImplementedException();
       InitLex(phrase);
       var e = CanonicalExpr();
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/HeuristicLab.Distributions.csproj
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/HeuristicLab.Distributions.csproj	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Distributions/HeuristicLab.Distributions.csproj	(revision 11981)
@@ -31,6 +31,7 @@
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="ALGLIB-3.7.0">
-      <HintPath>..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>
+    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\ALGLIB-3.7.0.dll</HintPath>
     </Reference>
     <Reference Include="System" />
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.Bandits/HeuristicLab.Problems.Bandits.csproj
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.Bandits/HeuristicLab.Problems.Bandits.csproj	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.Bandits/HeuristicLab.Problems.Bandits.csproj	(revision 11981)
@@ -31,6 +31,7 @@
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="ALGLIB-3.7.0">
-      <HintPath>..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>
+    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\ALGLIB-3.7.0.dll</HintPath>
     </Reference>
     <Reference Include="System" />
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/HeuristicLab.Problems.GrammaticalOptimization.SymbReg.csproj
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/HeuristicLab.Problems.GrammaticalOptimization.SymbReg.csproj	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/HeuristicLab.Problems.GrammaticalOptimization.SymbReg.csproj	(revision 11981)
@@ -33,30 +33,36 @@
     <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\ALGLIB-3.7.0.dll</HintPath>
+      <HintPath>..\HeuristicLab\ALGLIB-3.7.0.dll</HintPath>
     </Reference>
-    <Reference Include="AutoDiff-1.0">
-      <HintPath>..\..\..\trunk\sources\bin\AutoDiff-1.0.dll</HintPath>
+    <Reference Include="AutoDiff-1.0, Version=1.0.0.14388, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\AutoDiff-1.0.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Common-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Common-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Core-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Core-3.3.dll</HintPath>
     </Reference>
     <Reference Include="HeuristicLab.Data-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
+      <HintPath>..\HeuristicLab\HeuristicLab.Data-3.3.dll</HintPath>
     </Reference>
     <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
+      <HintPath>..\HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
+    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Problems.Instances-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath>
     </Reference>
     <Reference Include="System" />
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/SymbolicRegressionProblem.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/SymbolicRegressionProblem.cs	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.SymbReg/SymbolicRegressionProblem.cs	(revision 11981)
@@ -158,5 +158,4 @@
     public double OptimizeConstantsAndEvaluate(string sentence) {
       AutoDiff.Term func;
-      int pos = 0;
       int n = x.GetLength(0);
       int m = x.GetLength(1);
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/ExpressionInterpreter.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/ExpressionInterpreter.cs	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/ExpressionInterpreter.cs	(revision 11981)
@@ -80,7 +80,6 @@
         } else {
           NewSy();
-          throw new NotImplementedException();
-          // var e = Expr(d, erc);
-          // r = Not(r) * e + r * Not(e); // xor = (!x AND y) OR (x AND !y)
+          var e = Expr(d, erc);
+          r = Not(r) * e + r * Not(e); // xor = (!x AND y) OR (x AND !y)
         }
         curSy = CurSy();
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj	(revision 11981)
@@ -34,42 +34,18 @@
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
+      <HintPath>..\HeuristicLab\HeuristicLab.Common-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Common-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
+    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\HeuristicLab\HeuristicLab.Core-3.3.dll</HintPath>
     </Reference>
-    <Reference Include="HeuristicLab.Core-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
-    </Reference>
-    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
-    </Reference>
-    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
-    </Reference>
-    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
-    </Reference>
-    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
-    </Reference>
-    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
-    </Reference>
-    <Reference Include="HeuristicLab.Persistence-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
-    </Reference>
-    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
+      <HintPath>..\HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
-    <Reference Include="System.Drawing" />
   </ItemGroup>
   <ItemGroup>
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs	(revision 11981)
@@ -140,21 +140,6 @@
       var isTerminal = grammar.IsTerminal(phrase);
 
-
       yield return new Feature(isTerminal + ToString(), 1.0);
-      //if (phrase.Length > 0) {
-      //  var ant = new Ant(recordTrail: true);
-      //  int pos = 0;
-      //  Run(ant, phrase, ref pos, true);
-      //  //yield return new Feature("food", ant.FoodEaten);
-      //  yield return new Feature(ant.Trail, 1.0);
-      //}
-      //yield return new Feature(isTerminal + "const", 0.0);
-      //yield return new Feature(isTerminal.ToString() + phrase.Length, 1.0);
-      //int ntIdx;
-      //for (ntIdx = 0; ntIdx < phrase.Length; ntIdx++) if (grammar.IsNonTerminal(phrase[ntIdx])) break;
-      //for (int l = ntIdx-2; l >= 0; l--) {
-      //  yield return new Feature(phrase.Substring(l, ntIdx-l-1), 1.0);
-      //}
-      //
+     
       yield return new Feature("$" + (phrase.Length > 0 ? phrase[0] : ' '), 1.0);
       if (!isTerminal) {
@@ -166,22 +151,6 @@
         }
       }
-      // var d = 0;
-      // var ls = 0;
-      // var rs = 0;
-      // var qs = 0;
-      // foreach (var ch in phrase) if (ch == 'l') { d--; ls++; } else if (ch == 'r') { d++; rs++; } else if (ch == '?') qs++;
-      // yield return new Feature(isTerminal + "D" + Math.Abs(d), 1.0);
-      // yield return new Feature(isTerminal + "R" + rs, 1.0);
-      // yield return new Feature(isTerminal + "L" + ls, 1.0);
-      // yield return new Feature(isTerminal + "?" + qs, 1.0);
-
+    
       yield return new Feature(phrase, 1.0);
-      //for (int i = 0; i < phrase.Length; i++)
-      //  yield return new Feature(i.ToString() + phrase[i].ToString(), 1.0);
-      // yield return new Feature("Length", phrase.Length); // 
-      // foreach (var pair in phrase.Zip(phrase.Skip(1), Tuple.Create)) {
-      //   yield return new Feature(pair.Item1.ToString() + pair.Item2, 1.0);
-      // }
-      // number of occurances for each symbol
     }
 
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Main.csproj
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Main.csproj	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Main.csproj	(revision 11981)
@@ -48,23 +48,7 @@
       <Name>HeuristicLab.Algorithms.Bandits</Name>
     </ProjectReference>
-    <ProjectReference Include="..\HeuristicLab.Algorithms.GeneticProgramming\HeuristicLab.Algorithms.GeneticProgramming.csproj">
-      <Project>{14BEC23F-63FD-4954-B8AE-E2F4962E9B57}</Project>
-      <Name>HeuristicLab.Algorithms.GeneticProgramming</Name>
-    </ProjectReference>
     <ProjectReference Include="..\HeuristicLab.Algorithms.GrammaticalOptimization\HeuristicLab.Algorithms.GrammaticalOptimization.csproj">
       <Project>{eea07488-1a51-412a-a52c-53b754a628b3}</Project>
       <Name>HeuristicLab.Algorithms.GrammaticalOptimization</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\HeuristicLab.Common\HeuristicLab.Common.csproj">
-      <Project>{3A2FBBCB-F9DF-4970-87F3-F13337D941AD}</Project>
-      <Name>HeuristicLab.Common</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\HeuristicLab.Distributions\HeuristicLab.Distributions.csproj">
-      <Project>{31171165-E16F-4A1A-A8AB-25C6AB3A71B9}</Project>
-      <Name>HeuristicLab.Distributions</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\HeuristicLab.Problems.GrammaticalOptimization.SymbReg\HeuristicLab.Problems.GrammaticalOptimization.SymbReg.csproj">
-      <Project>{17A7A380-86CE-482D-8D22-CBD70CC97F0D}</Project>
-      <Name>HeuristicLab.Problems.GrammaticalOptimization.SymbReg</Name>
     </ProjectReference>
     <ProjectReference Include="..\HeuristicLab.Problems.GrammaticalOptimization\HeuristicLab.Problems.GrammaticalOptimization.csproj">
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Program.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Program.cs	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/Main/Program.cs	(revision 11981)
@@ -1,24 +1,20 @@
 using System;
-using System.Collections.Generic;
 using System.Diagnostics;
 using System.Globalization;
-using System.Runtime.Remoting.Messaging;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using HeuristicLab.Algorithms.Bandits;
 using HeuristicLab.Algorithms.Bandits.BanditPolicies;
-using HeuristicLab.Algorithms.Bandits.GrammarPolicies;
-using HeuristicLab.Algorithms.Bandits.Models;
-using HeuristicLab.Algorithms.GeneticProgramming;
 using HeuristicLab.Algorithms.GrammaticalOptimization;
-using HeuristicLab.Common;
 using HeuristicLab.Problems.GrammaticalOptimization;
-using HeuristicLab.Problems.GrammaticalOptimization.SymbReg;
-using BoltzmannExplorationPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.BoltzmannExplorationPolicy;
-using EpsGreedyPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.EpsGreedyPolicy;
-using IProblem = HeuristicLab.Problems.GrammaticalOptimization.IProblem;
-using RandomPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.RandomPolicy;
-using UCTPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.UCTPolicy;
+
+// NOTES: gkronber
+// TODO: feature extraction for full symbolic expressions and experiment for all benchmark problems
+// TODO: why does GaussianThompsonSampling work so well with MCTS for the artificial ant problem?
+// TODO: research thompson sampling for max bandit?
+// TODO: verify TA implementation using example from the original paper      
+// TODO: implement thompson sampling for gaussian mixture models
+// TODO: gleichzeitige modellierung von transformierter zielvariable (y, 1/y, log(y), exp(y), sqrt(y), ...)
+// TODO: vergleich bei complete-randomly mÃ¶glichst kurze sÃ€tze generieren vs. einfach zufÃ€llig alternativen wÃ€hlen
+// TODO: reward discounting (fÃŒr verÃ€nderliche reward distributions ÃŒber zeit). speziellen unit-test dafÃŒr erstellen
+// TODO: constant optimization 
+
 
 namespace Main {
@@ -27,259 +23,49 @@
       CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
 
-      //RunDemo();
-      //RunGpDemo();
-      // RunGridTest();
-      //RunGpGridTest();
-      RunFunApproxTest();
+      RunDemo();
     }
 
-    private static void RunGridTest() {
-      int maxIterations = 200000; // for poly-10 with 50000 evaluations no successful try with hl yet
-      //var globalRandom = new Random(31415);
-      var localRandSeed = new Random().Next();
-      var reps = 20;
-
-      var policyFactories = new Func<IBanditPolicy>[]
-        {
-         //() => new RandomPolicy(), 
-         // () => new ActiveLearningPolicy(),  
-         //() => new EpsGreedyPolicy(0.01, (aInfo)=> aInfo.MaxReward, "max"), 
-         //() => new EpsGreedyPolicy(0.05, (aInfo)=> aInfo.MaxReward, "max"), 
-         //() => new EpsGreedyPolicy(0.1, (aInfo)=> aInfo.MaxReward, "max"), 
-         //() => new EpsGreedyPolicy(0.2, (aInfo)=> aInfo.MaxReward, "max"), 
-         ////() => new GaussianThompsonSamplingPolicy(), 
-         //() => new GaussianThompsonSamplingPolicy(true), 
-         //() => new GenericThompsonSamplingPolicy(new GaussianModel(0.5, 10, 1)), 
-         //() => new GenericThompsonSamplingPolicy(new GaussianModel(0.5, 10, 1, 1)), 
-         ////() => new BernoulliThompsonSamplingPolicy(),
-         //() => new GenericThompsonSamplingPolicy(new BernoulliModel(1, 1)), 
-         //() => new EpsGreedyPolicy(0.01), 
-         //() => new EpsGreedyPolicy(0.05), 
-         //() => new EpsGreedyPolicy(0.1), 
-         //() => new EpsGreedyPolicy(0.2), 
-         //() => new EpsGreedyPolicy(0.5), 
-         //() => new UCTPolicy(0.01),
-         //() => new UCTPolicy(0.05),
-         //() => new UCTPolicy(0.1),
-         //() => new UCTPolicy(0.5),
-         //() => new UCTPolicy(1),
-         //() => new UCTPolicy(2),
-         //() => new UCTPolicy( 5),
-         //() => new UCTPolicy( 10),
-         //() => new ModifiedUCTPolicy(0.01),
-         //() => new ModifiedUCTPolicy(0.05),
-         //() => new ModifiedUCTPolicy(0.1),
-         //() => new ModifiedUCTPolicy(0.5),
-         //() => new ModifiedUCTPolicy(1),
-         //() => new ModifiedUCTPolicy(2),
-         //() => new ModifiedUCTPolicy( 5),
-         //() => new ModifiedUCTPolicy( 10),
-         //() => new UCB1Policy(), 
-         //() => new UCB1TunedPolicy(), 
-         //() => new UCBNormalPolicy(), 
-         //() => new BoltzmannExplorationPolicy(1),
-         //() => new BoltzmannExplorationPolicy(10),
-         //() => new BoltzmannExplorationPolicy(20),
-         //() => new BoltzmannExplorationPolicy(100),
-         //() => new BoltzmannExplorationPolicy(200),
-         //() => new BoltzmannExplorationPolicy(500),
-         // () => new ChernoffIntervalEstimationPolicy( 0.01), 
-         // () => new ChernoffIntervalEstimationPolicy( 0.05),
-         // () => new ChernoffIntervalEstimationPolicy( 0.1),
-         // () => new ChernoffIntervalEstimationPolicy( 0.2),
-         //() => new ThresholdAscentPolicy(5, 0.01), 
-         //() => new ThresholdAscentPolicy(5, 0.05),
-         //() => new ThresholdAscentPolicy(5, 0.1),
-         //() => new ThresholdAscentPolicy(5, 0.2),
-         //() => new ThresholdAscentPolicy(10, 0.01), 
-         //() => new ThresholdAscentPolicy(10, 0.05),
-         //() => new ThresholdAscentPolicy(10, 0.1),
-         //() => new ThresholdAscentPolicy(10, 0.2),
-         //() => new ThresholdAscentPolicy(50, 0.01), 
-         //() => new ThresholdAscentPolicy(50, 0.05),
-         //() => new ThresholdAscentPolicy(50, 0.1),
-         //() => new ThresholdAscentPolicy(50, 0.2),
-         //() => new ThresholdAscentPolicy(100, 0.01), 
-         () => new ThresholdAscentPolicy(100, 0.05),
-         //() => new ThresholdAscentPolicy(100, 0.1),
-         //() => new ThresholdAscentPolicy(100, 0.2),
-         //() => new ThresholdAscentPolicy(500, 0.01), 
-         //() => new ThresholdAscentPolicy(500, 0.05),
-         //() => new ThresholdAscentPolicy(500, 0.1),
-         //() => new ThresholdAscentPolicy(500, 0.2),
-         //() => new ThresholdAscentPolicy(5000, 0.01), 
-         //() => new ThresholdAscentPolicy(10000, 0.01), 
-        };
-
-      var instanceFactories = new Func<Random, Tuple<IProblem, int>>[]
-      {
-        //(rand) => Tuple.Create((IProblem)new SantaFeAntProblem(), 17),
-        //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:0, correctReward:1, decoyReward:0, phrasesAsSets:false ), 15),
-        //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:0, correctReward:1, decoyReward:0, phrasesAsSets:true ), 15),
-        //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:200, correctReward:1, decoyReward:0.5, phrasesAsSets:false), 15),
-        //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:200, correctReward:1, decoyReward:0.5, phrasesAsSets:true), 15),
-        (rand) => Tuple.Create((IProblem)new SymbolicRegressionPoly10Problem(), 23)
-      };
-
-      foreach (var instanceFactory in instanceFactories) {
-        foreach (var useCanonical in new bool[] { true /*, false */ }) {
-          foreach (var randomTries in new int[] { 1 /*, 1, 10 /*, /* 5, 100 /*, 500, 1000 */}) {
-            foreach (var policyFactory in policyFactories) {
-              var myRandomTries = randomTries;
-              var localRand = new Random(localRandSeed);
-              var options = new ParallelOptions();
-              options.MaxDegreeOfParallelism = 1;
-              Parallel.For(0, reps, options, (i) => {
-                Random myLocalRand;
-                lock (localRand)
-                  myLocalRand = new Random(localRand.Next());
-
-                int iterations = 0;
-                var globalStatistics = new SentenceSetStatistics();
-
-                // var problem = new SymbolicRegressionPoly10Problem();
-                // var problem = new SantaFeAntProblem();
-                //var problem = new PalindromeProblem();
-                //var problem = new HardPalindromeProblem();
-                //var problem = new RoyalPairProblem();
-                //var problem = new EvenParityProblem();
-                // var alg = new MctsSampler(problem.Item1, problem.Item2, myLocalRand, myRandomTries, policy()); 
-                var instance = instanceFactory(myLocalRand);
-                var problem = instance.Item1;
-                var maxLen = instance.Item2;
-                var alg = new SequentialSearch(problem, maxLen, myLocalRand, myRandomTries,
-                  new GenericGrammarPolicy(problem, policyFactory(), useCanonical));
-                // var alg = new SequentialSearch(problem, maxLen, myLocalRand,
-                //   myRandomTries,
-                //   new GenericFunctionApproximationGrammarPolicy(problem,
-                //     useCanonical));
-                //var alg = new ExhaustiveBreadthFirstSearch(problem, 25);
-                //var alg = new AlternativesContextSampler(problem, 25);
-
-                alg.SolutionEvaluated += (sentence, quality) => {
-                  iterations++;
-                  globalStatistics.AddSentence(sentence, quality);
-                  if (iterations % 1000 == 0) {
-                    Console.WriteLine("{0,3} {1,5} \"{2,25}\" {3} {4} {5}", i, myRandomTries, policyFactory(), useCanonical, problem.ToString(), globalStatistics);
-                  }
-                };
-                alg.FoundNewBestSolution += (sentence, quality) => {
-                  //Console.WriteLine("{0,5} {1,25} {2} {3}",
-                  //  myRandomTries, policyFactory(), useCanonical,
-                  //  globalStatistics);
-                };
-
-                alg.Run(maxIterations);
-              });
-            }
-          }
-        }
-      }
-    }
 
     private static void RunDemo() {
-      // TODO: cleanup nach EuroCAST
-      // TODO: why does GaussianThompsonSampling work so well with MCTS for the artificial ant problem?
-      // TODO: research thompson sampling for max bandit?
-      // TODO: verify TA implementation using example from the original paper      
-      // TODO: implement thompson sampling for gaussian mixture models
-      // TODO: gleichzeitige modellierung von transformierter zielvariable (y, 1/y, log(y), exp(y), sqrt(y), ...)
-      // TODO: vergleich bei complete-randomly mÃ¶glichst kurze sÃ€tze generieren vs. einfach zufÃ€llig alternativen wÃ€hlen
-      // TODO: reward discounting (fÃŒr verÃ€nderliche reward distributions ÃŒber zeit). speziellen unit-test dafÃŒr erstellen
-      // TODO: constant optimization 
 
 
-      int maxIterations = 1000000;
+      int maxIterations = 100000;
       int iterations = 0;
-      var sw = new Stopwatch();
 
       var globalStatistics = new SentenceSetStatistics();
       var random = new Random();
 
-
-      //var problem = new RoyalSequenceProblem(random, 10, 30, 2, 1, 0);
-      // var phraseLen = 3;
-      // var numPhrases = 5;
-      // var problem = new RoyalPhraseSequenceProblem(random, 10, numPhrases, phraseLen: phraseLen, numCorrectPhrases: 1, correctReward: 1, incorrectReward: 0.0, phrasesAsSets: false);
-
-      //var phraseLen = 3;
-      //var numPhrases = 5;
-      //var problem = new FindPhrasesProblem(random, 10, numPhrases, phraseLen, numOptimalPhrases: numPhrases, numDecoyPhrases: 0, correctReward: 1.0, decoyReward: 0, phrasesAsSets: false);
-
-      // good results for symb-reg
-      // prev results: e.g. 10 randomtries and EpsGreedyPolicy(0.2, (aInfo)=>aInfo.MaxReward)
-      // 2015 01 19: grid test with canonical states: 
-      // - EpsGreedyPolicy(0.20,max)
-      // - GenericThompsonSamplingPolicy("")
-      // - UCTPolicy(0.10) (5 of 5 runs, 35000 iters avg.), 10 successful runs of 10 with rand-tries 0, bei 40000 iters 9 / 10, bei 30000 1 / 10
-      // 2015 01 22: symb-reg: grid test on find-phrases problem showed good results for UCB1TunedPolicy and SequentialSearch with canonical states
-      // - symb-reg: consistent results with UCB1Tuned. finds optimal solution in ~50k iters (new GenericGrammarPolicy(problem, new UCB1TunedPolicy(), true));
-      // 2015 01 23: grid test with canonical states:
-      // - UCTPolicy(0.10) und UCBNormalPolicy 10/10 optimale LÃ¶sungen bei max. 50k iters, etwas schlechter: generic-thompson with variable sigma und bolzmannexploration (100)
-
-
-      // good results for artificial ant:
-      // prev results: 
-      // - var alg = new MctsSampler(problem, 17, random, 1, (rand, numActions) => new ThresholdAscentPolicy(numActions, 500, 0.01));
-      // - GaussianModelWithUnknownVariance (and Q= 0.99-quantil) also works well for Ant
-      // 2015 01 19: grid test with canonical states (non-canonical slightly worse)
-      // - ant: Threshold Ascent (best 100, 0.01; all variants relatively good)
-      // - ant: Policies where the variance has a large weight compared to the mean? (Gaussian(compatible), Gaussian with fixed variance, UCT with large c, alle TA)
-      // - ant: UCB1Tuned with canonical states also works very well for the artificial ant! constistent solutions in less than 10k iters      
-
-      //var problem = new SymbolicRegressionPoly10Problem();
-      //var problem = new SantaFeAntProblem();
-      var problem = new SymbolicRegressionProblem(random, "Breiman");
-      //var problem = new PalindromeProblem();
-      //var problem = new HardPalindromeProblem();
+      var problem = new SymbolicRegressionPoly10Problem();
+      //var problem = new SantaFeAntProblem();              
       //var problem = new RoyalPairProblem();
       //var problem = new EvenParityProblem();
-      // symbreg length = 11 q = 0.824522210419616
-      //var alg = new MctsSampler(problem, 23, random, 0, new BoltzmannExplorationPolicy(100));
-      //var alg = new MctsSampler(problem, 23, random, 0, new EpsGreedyPolicy(0.1));
-      //var alg = new SequentialSearch(problem, 23, random, 0,
-      //  new HeuristicLab.Algorithms.Bandits.GrammarPolicies.QLearningGrammarPolicy(problem, new BoltzmannExplorationPolicy(10),
-      //    1, 1, true));
-      //var alg = new SequentialSearch(problem, 23, random, 0,
-      //  new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericContextualGrammarPolicy(problem, new GenericThompsonSamplingPolicy(new GaussianModel(0.5, 10, 1, 1)), true));
-      var alg = new SequentialSearch(problem, 30, random, 0,
-        new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericFunctionApproximationGrammarPolicy(problem, true));
-      //var alg = new MctsQLearningSampler(problem, sentenceLen, random, 0, null);
-      //var alg = new MctsQLearningSampler(problem, 30, random, 0, new EpsGreedyPolicy(0.2));
-      //var alg = new MctsContextualSampler(problem, 23, random, 0); // must visit each canonical solution only once
-      //var alg = new TemporalDifferenceTreeSearchSampler(problem, 30, random, 1);
-      //var alg = new ExhaustiveBreadthFirstSearch(problem, 7);
-      //var alg = new AlternativesContextSampler(problem, random, 17, 4, (rand, numActions) => new RandomPolicy(rand, numActions));
-      //var alg = new ExhaustiveDepthFirstSearch(problem, 17);
-      // var alg = new AlternativesSampler(problem, 17);
-      // var alg = new RandomSearch(problem, random, 17);
-      //var alg = new ExhaustiveRandomFirstSearch(problem, random, 17);
+      var alg = new SequentialSearch(problem, 23, random, 0,
+       new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericGrammarPolicy(problem, new UCB1TunedPolicy()));
+
 
       alg.FoundNewBestSolution += (sentence, quality) => {
         //Console.WriteLine("{0}", globalStatistics);
-        //Console.ReadLine();
       };
+
       alg.SolutionEvaluated += (sentence, quality) => {
         iterations++;
         globalStatistics.AddSentence(sentence, quality);
 
-        //if (iterations % 100 == 0) {
-        //  if (iterations % 10000 == 0) Console.Clear();
-        //  Console.SetCursorPosition(0, 0);
-        //  alg.PrintStats();
-        //}
+        // comment this if you don't want to see solver statistics
+        if (iterations % 100 == 0) {
+          if (iterations % 10000 == 0) Console.Clear();
+          Console.SetCursorPosition(0, 0);
+          alg.PrintStats();
+        }
 
-        //Console.WriteLine(sentence);
-
-        if (iterations % 100 == 0) {
-          Console.WriteLine("{0}", globalStatistics);
-        }
+        // uncomment this if you want to collect statistics of the generated sentences
+        // if (iterations % 1000 == 0) {
+        //   Console.WriteLine("{0}", globalStatistics);
+        // }
       };
 
-
+      var sw = new Stopwatch();
       sw.Start();
-
       alg.Run(maxIterations);
-
       sw.Stop();
 
@@ -292,162 +78,4 @@
         (double)sw.ElapsedMilliseconds * 1000 / maxIterations);
     }
-
-    public static void RunGpDemo() {
-      int iterations = 0;
-      const int seed = 31415;
-      const int maxIterations = 100000;
-
-      //var prob = new SymbolicRegressionProblem(new Random(31415), "Tower");
-      var prob = new SymbolicRegressionPoly10Problem();
-      var sgp = new OffspringSelectionGP(prob, new Random(seed), true);
-      RunGP(sgp, prob, 200000, 500, 0.15, 50);
-    }
-
-
-    private static void RunFunApproxTest() {
-      const int nReps = 30;
-      const int seed = 31415;
-      //const int maxIters = 50000;
-      var rand = new Random();
-      var problemFactories = new Func<Tuple<int, int, ISymbolicExpressionTreeProblem>>[]
-      {
-        () => Tuple.Create(100000, 23,  (ISymbolicExpressionTreeProblem)new SymbolicRegressionPoly10Problem()), 
-        //() => Tuple.Create(100000, 17, (ISymbolicExpressionTreeProblem)new SantaFeAntProblem()), 
-        //() => Tuple.Create(50000, 32,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 
-        //() => Tuple.Create(50000, 64, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 
-        //() => Tuple.Create(50000, 64,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 
-        //() => Tuple.Create(50000, 128, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 
-        //() => Tuple.Create(50000, 128,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 
-        //() => Tuple.Create(50000, 256, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 
-        //() => Tuple.Create(50000, 256,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 
-        //() => new RoyalPairProblem(), 
-        //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, true), 
-        //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, false), 
-        //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 50, 1, 0.8, false), 
-      };
-
-      // skip experiments that are already done
-      for (int i = 0; i < nReps; i++) {
-        foreach (var problemFactory in problemFactories) {
-          {
-            var solverSeed = rand.Next();
-            var tupel = problemFactory();
-            var maxIters = tupel.Item1;
-            var maxSize = tupel.Item2;
-            var prob = tupel.Item3;
-
-            var alg = new SequentialSearch(prob, maxSize, new Random(solverSeed), 0,
-          new HeuristicLab.Algorithms.Bandits.GrammarPolicies.GenericFunctionApproximationGrammarPolicy(prob, true));
-
-            int iterations = 0;
-            double bestQuality = double.NegativeInfinity;
-            var globalStatistics = new SentenceSetStatistics();
-            var algName = alg.GetType().Name;
-            var probName = prob.GetType().Name;
-            alg.SolutionEvaluated += (sentence, quality) => {
-              bestQuality = Math.Max(bestQuality, quality);
-              iterations++;
-              globalStatistics.AddSentence(sentence, quality);
-              //if (iterations % 100 == 0) {
-              //  Console.Clear();
-              //  Console.SetCursorPosition(0, 0);
-              //  alg.PrintStats();
-              //}
-              //Console.WriteLine("{0:N5} {1}", quality, sentence);
-              if (iterations % 1000 == 0) {
-                Console.WriteLine("\"{0,25}\" {1} \"{2,25}\" {3}", algName, maxSize, probName, globalStatistics);
-                if (bestQuality.IsAlmost(1.0)) {
-                  alg.StopRequested = true;
-                }
-              }
-            };
-
-            alg.Run(maxIters);
-
-
-            while (iterations < maxIters) {
-              iterations++;
-              globalStatistics.AddSentence("BEST", bestQuality);
-              if (iterations % 1000 == 0) {
-                Console.WriteLine("\"{0,25}\" {1} \"{2,25}\" {3}", algName, maxSize, probName, globalStatistics);
-                if (bestQuality.IsAlmost(1.0)) {
-                  alg.StopRequested = true;
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-
-    private static void RunGpGridTest() {
-      const int nReps = 20;
-      const int seed = 31415;
-      //const int maxIters = 50000;
-      var rand = new Random(seed);
-      var problemFactories = new Func<Tuple<int, int, ISymbolicExpressionTreeProblem>>[]
-      {
-        () => Tuple.Create(50000, 32, (ISymbolicExpressionTreeProblem)new PermutationProblem()), 
-        () => Tuple.Create(50000, 32, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 
-        () => Tuple.Create(50000, 32,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 
-        () => Tuple.Create(50000, 64, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 
-        () => Tuple.Create(50000, 64,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 
-        () => Tuple.Create(50000, 128, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 
-        () => Tuple.Create(50000, 128,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 
-        () => Tuple.Create(50000, 256, (ISymbolicExpressionTreeProblem)new RoyalPairProblem()), 
-        () => Tuple.Create(50000, 256,(ISymbolicExpressionTreeProblem)new RoyalSymbolProblem()), 
-        //() => new RoyalPairProblem(), 
-        //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, true), 
-        //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 0, 1, 0, false), 
-        //() => new FindPhrasesProblem(rand, 20, 5, 3, 5, 50, 1, 0.8, false), 
-      };
-
-      foreach (var popSize in new int[] { 100 /*, 250, 500, 1000, 2500, 5000, 10000 */ }) {
-        foreach (var mutationRate in new double[] { /* 0.05, /* 0.10, */ 0.15, /* 0.25, 0.3 */}) {
-          // skip experiments that are already done
-          foreach (var problemFactory in problemFactories) {
-            for (int i = 0; i < nReps; i++) {
-              {
-                var solverSeed = rand.Next();
-                var tupel = problemFactory();
-                var maxIters = tupel.Item1;
-                var maxSize = tupel.Item2;
-                var prob = tupel.Item3;
-                var sgp = new StandardGP(prob, new Random(solverSeed));
-                RunGP(sgp, prob, maxIters, popSize, mutationRate, maxSize);
-              }
-              //{
-              //  var prob = problemFactory();
-              //  var osgp = new OffspringSelectionGP(prob, new Random(solverSeed));
-              //  RunGP(osgp, prob, maxIters, popSize, mutationRate, maxSize);
-              //}
-            }
-          }
-        }
-
-      }
-    }
-
-    private static void RunGP(IGPSolver gp, ISymbolicExpressionTreeProblem prob, int maxIters, int popSize, double mutationRate, int maxSize) {
-      int iterations = 0;
-      var globalStatistics = new SentenceSetStatistics(prob.BestKnownQuality(maxSize));
-      var gpName = gp.GetType().Name;
-      var probName = prob.GetType().Name;
-      gp.SolutionEvaluated += (sentence, quality) => {
-        iterations++;
-        globalStatistics.AddSentence(sentence, quality);
-
-        if (iterations % 100 == 0) {
-          Console.WriteLine("\"{0,25}\" {1} {2:N2} {3} \"{4,25}\" {5}", gpName, popSize, mutationRate, maxSize, probName, globalStatistics);
-        }
-      };
-
-      gp.PopulationSize = popSize;
-      gp.MutationRate = mutationRate;
-      gp.MaxSolutionSize = maxSize + 2;
-      gp.MaxSolutionDepth = maxSize + 2;
-
-      gp.Run(maxIters);
-    }
   }
 }
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunBaselineExperiments.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunBaselineExperiments.cs	(revision 11981)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunBaselineExperiments.cs	(revision 11981)
@@ -0,0 +1,312 @@
+﻿using System;
+using System.Collections;
+using System.Collections.Generic;
+using HeuristicLab.Algorithms.Bandits.BanditPolicies;
+using HeuristicLab.Algorithms.Bandits.GrammarPolicies;
+using HeuristicLab.Algorithms.GeneticProgramming;
+using HeuristicLab.Algorithms.GrammaticalOptimization;
+using HeuristicLab.Problems.GrammaticalOptimization;
+using HeuristicLab.Problems.GrammaticalOptimization.SymbReg;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using RandomPolicy = HeuristicLab.Algorithms.Bandits.BanditPolicies.RandomPolicy;
+
+namespace HeuristicLab.Problems.GrammaticalOptimization.Test {
+
+
+  [TestClass]
+  public class RunBaselineExperiments {
+    private readonly static int randSeed = 31415;
+
+    internal class Configuration {
+      public ISymbolicExpressionTreeProblem Problem;
+      public int MaxSize;
+      public int RandSeed;
+
+      public override string ToString() {
+        return string.Format("{0} {1} {2}", RandSeed, Problem, MaxSize);
+      }
+    }
+
+    #region permutation
+    [TestMethod]
+    public void RunPureRandomSearchPermutationProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new PermutationProblem(), 
+      };
+
+      var maxSizes = new int[] { 32 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunPureRandomSearchForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunRandomSearchNoResamplingPermutationProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new PermutationProblem(), 
+      };
+
+      var maxSizes = new int[] { 32 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunRandomSearchNoResamplingForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    #endregion
+
+    #region royalpair
+    [TestMethod]
+    public void RunPureRandomSearchRoyalPairProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new RoyalPairProblem(), 
+      };
+
+      var maxSizes = new int[] { 32, 64, 128, 256 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunPureRandomSearchForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunRandomSearchNoResamplingRoyalPairProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new RoyalPairProblem(), 
+      };
+
+      var maxSizes = new int[] { 32, 64, 128, 256 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunRandomSearchNoResamplingForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    #endregion
+
+    #region royalsymbol
+    [TestMethod]
+    public void RunPureRandomSearchRoyalSymbolProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new RoyalSymbolProblem(), 
+      };
+
+      var maxSizes = new int[] { 32, 64, 128, 256 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunPureRandomSearchForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunRandomSearchNoResamplingRoyalSymbolProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new RoyalSymbolProblem(), 
+      };
+
+      var maxSizes = new int[] { 32, 64, 128, 256 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunRandomSearchNoResamplingForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    #endregion
+
+    #region findphrases
+    [TestMethod]
+    public void RunPureRandomSearchFindPhrasesProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 0, 1, 0, true), 
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 0, 1, 0, false), 
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 50, 1, 0.8, false), 
+      };
+
+      var maxSizes = new int[] { 15 * 3 }; // * 3 for non-terminals
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunPureRandomSearchForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunRandomSearchNoResamplingFindPhrasesProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 0, 1, 0, true), 
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 0, 1, 0, false), 
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 50, 1, 0.8, false), 
+      };
+
+      var maxSizes = new int[] { 15 * 3 }; // * 3 for non-terminals
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunRandomSearchNoResamplingForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+
+    #endregion
+
+    #region artificial ant
+    [TestMethod]
+    public void RunPureRandomSearchArtificialAntProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SantaFeAntProblem(), 
+      };
+
+      var maxSizes = new int[] { 30, 50, 100 }; // size of sequential representation is 17
+      int nReps = 20;
+      int maxIterations = 100000; // randomsearch finds the optimum almost always for 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunPureRandomSearchForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunRandomSearchNoResamplingArtificialAntProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SantaFeAntProblem(), 
+      };
+
+      var maxSizes = new int[] { 30, 50, 100 }; // size of sequential representation is 17
+      int nReps = 20;
+      int maxIterations = 100000; // randomsearch finds the optimum almost always for 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunRandomSearchNoResamplingForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    #endregion
+
+    #region symb-reg-poly-10
+    [TestMethod]
+    public void RunPureRandomSearchPoly10Problem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SymbolicRegressionPoly10Problem(), 
+      };
+
+      var maxSizes = new int[] { 30, 50, 100 }; // size of sequential representation is 23
+      int nReps = 20;
+      int maxIterations = 100000; // sequentialsearch should find the optimum within 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunPureRandomSearchForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunRandomSearchNoResamplingPoly10Problem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SymbolicRegressionPoly10Problem(), 
+      };
+
+      var maxSizes = new int[] { 30, 50, 100 }; // size of sequential representation is 23
+      int nReps = 20;
+      int maxIterations = 100000; // sequentialsearch should find the optimum within 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunRandomSearchNoResamplingForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+    #endregion
+
+    #region helpers
+    private IEnumerable<Configuration> GenerateConfigurations(Func<int, ISymbolicExpressionTreeProblem> problemFactory,
+      int nReps,
+      IEnumerable<int> maxSizes
+      ) {
+      var seedRand = new Random(randSeed);
+      // the problem seed is the same for all configuratons 
+      // this guarantees that we solve the _same_ problem each time
+      // with different solvers and multiple repetitions
+      var problemSeed = randSeed;
+      for (int i = 0; i < nReps; i++) {
+        // in each repetition use the same random seed for all solver configuratons
+        // do nReps with different seeds for each configuration
+        var solverSeed = seedRand.Next();
+        foreach (var maxSize in maxSizes) {
+          yield return new Configuration {
+            MaxSize = maxSize,
+            Problem = problemFactory(problemSeed),
+            RandSeed = solverSeed
+          };
+        }
+      }
+    }
+
+    private static void RunPureRandomSearchForProblem(
+      int randSeed,
+      ISymbolicExpressionTreeProblem problem,
+      int maxIters,
+      int maxSize
+      ) {
+      var solver = new RandomSearch(problem, new Random(randSeed), maxSize);
+      var problemName = problem.GetType().Name;
+      var bestKnownQuality = problem.BestKnownQuality(maxSize);
+      RunSolver(solver, problemName, bestKnownQuality, maxIters, maxSize);
+    }
+
+    private static void RunRandomSearchNoResamplingForProblem(
+  int randSeed,
+  ISymbolicExpressionTreeProblem problem,
+  int maxIters,
+  int maxSize
+  ) {
+      var solver = new SequentialSearch(problem, maxSize, new Random(randSeed), 0,
+        new GenericGrammarPolicy(problem, new RandomPolicy(), false));
+
+      var problemName = problem.GetType().Name;
+      var bestKnownQuality = problem.BestKnownQuality(maxSize);
+      RunSolver(solver, problemName, bestKnownQuality, maxIters, maxSize);
+    }
+
+    private static void RunSolver(ISolver solver, string problemName, double bestKnownQuality, int maxIters, int maxSize) {
+      int iterations = 0;
+      var globalStatistics = new SentenceSetStatistics(bestKnownQuality);
+      var gpName = solver.GetType().Name;
+      solver.SolutionEvaluated += (sentence, quality) => {
+        iterations++;
+        globalStatistics.AddSentence(sentence, quality);
+
+        if (iterations % 1000 == 0) {
+          Console.WriteLine("\"{0,25}\" {1} \"{2,25}\" {3}", gpName, maxSize, problemName, globalStatistics);
+        }
+      };
+
+      solver.Run(maxIters);
+    }
+    #endregion
+  }
+}
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunDemo.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunDemo.cs	(revision 11981)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunDemo.cs	(revision 11981)
@@ -0,0 +1,157 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using HeuristicLab.Algorithms.Bandits;
+using HeuristicLab.Algorithms.Bandits.BanditPolicies;
+using HeuristicLab.Algorithms.Bandits.GrammarPolicies;
+using HeuristicLab.Algorithms.GrammaticalOptimization;
+
+namespace HeuristicLab.Problems.GrammaticalOptimization.Test {
+  class RunDemo {
+    private static void RunGridTest() {
+      int maxIterations = 200000; // for poly-10 with 50000 evaluations no successful try with hl yet
+      //var globalRandom = new Random(31415);
+      var localRandSeed = new Random().Next();
+      var reps = 20;
+
+      var policyFactories = new Func<IBanditPolicy>[]
+        {
+         //() => new RandomPolicy(), 
+         // () => new ActiveLearningPolicy(),  
+         //() => new EpsGreedyPolicy(0.01, (aInfo)=> aInfo.MaxReward, "max"), 
+         //() => new EpsGreedyPolicy(0.05, (aInfo)=> aInfo.MaxReward, "max"), 
+         //() => new EpsGreedyPolicy(0.1, (aInfo)=> aInfo.MaxReward, "max"), 
+         //() => new EpsGreedyPolicy(0.2, (aInfo)=> aInfo.MaxReward, "max"), 
+         ////() => new GaussianThompsonSamplingPolicy(), 
+         //() => new GaussianThompsonSamplingPolicy(true), 
+         //() => new GenericThompsonSamplingPolicy(new GaussianModel(0.5, 10, 1)), 
+         //() => new GenericThompsonSamplingPolicy(new GaussianModel(0.5, 10, 1, 1)), 
+         ////() => new BernoulliThompsonSamplingPolicy(),
+         //() => new GenericThompsonSamplingPolicy(new BernoulliModel(1, 1)), 
+         //() => new EpsGreedyPolicy(0.01), 
+         //() => new EpsGreedyPolicy(0.05), 
+         //() => new EpsGreedyPolicy(0.1), 
+         //() => new EpsGreedyPolicy(0.2), 
+         //() => new EpsGreedyPolicy(0.5), 
+         //() => new UCTPolicy(0.01),
+         //() => new UCTPolicy(0.05),
+         //() => new UCTPolicy(0.1),
+         //() => new UCTPolicy(0.5),
+         //() => new UCTPolicy(1),
+         //() => new UCTPolicy(2),
+         //() => new UCTPolicy( 5),
+         //() => new UCTPolicy( 10),
+         //() => new ModifiedUCTPolicy(0.01),
+         //() => new ModifiedUCTPolicy(0.05),
+         //() => new ModifiedUCTPolicy(0.1),
+         //() => new ModifiedUCTPolicy(0.5),
+         //() => new ModifiedUCTPolicy(1),
+         //() => new ModifiedUCTPolicy(2),
+         //() => new ModifiedUCTPolicy( 5),
+         //() => new ModifiedUCTPolicy( 10),
+         //() => new UCB1Policy(), 
+         //() => new UCB1TunedPolicy(), 
+         //() => new UCBNormalPolicy(), 
+         //() => new BoltzmannExplorationPolicy(1),
+         //() => new BoltzmannExplorationPolicy(10),
+         //() => new BoltzmannExplorationPolicy(20),
+         //() => new BoltzmannExplorationPolicy(100),
+         //() => new BoltzmannExplorationPolicy(200),
+         //() => new BoltzmannExplorationPolicy(500),
+         // () => new ChernoffIntervalEstimationPolicy( 0.01), 
+         // () => new ChernoffIntervalEstimationPolicy( 0.05),
+         // () => new ChernoffIntervalEstimationPolicy( 0.1),
+         // () => new ChernoffIntervalEstimationPolicy( 0.2),
+         //() => new ThresholdAscentPolicy(5, 0.01), 
+         //() => new ThresholdAscentPolicy(5, 0.05),
+         //() => new ThresholdAscentPolicy(5, 0.1),
+         //() => new ThresholdAscentPolicy(5, 0.2),
+         //() => new ThresholdAscentPolicy(10, 0.01), 
+         //() => new ThresholdAscentPolicy(10, 0.05),
+         //() => new ThresholdAscentPolicy(10, 0.1),
+         //() => new ThresholdAscentPolicy(10, 0.2),
+         //() => new ThresholdAscentPolicy(50, 0.01), 
+         //() => new ThresholdAscentPolicy(50, 0.05),
+         //() => new ThresholdAscentPolicy(50, 0.1),
+         //() => new ThresholdAscentPolicy(50, 0.2),
+         //() => new ThresholdAscentPolicy(100, 0.01), 
+         () => new ThresholdAscentPolicy(100, 0.05),
+         //() => new ThresholdAscentPolicy(100, 0.1),
+         //() => new ThresholdAscentPolicy(100, 0.2),
+         //() => new ThresholdAscentPolicy(500, 0.01), 
+         //() => new ThresholdAscentPolicy(500, 0.05),
+         //() => new ThresholdAscentPolicy(500, 0.1),
+         //() => new ThresholdAscentPolicy(500, 0.2),
+         //() => new ThresholdAscentPolicy(5000, 0.01), 
+         //() => new ThresholdAscentPolicy(10000, 0.01), 
+        };
+
+      var instanceFactories = new Func<Random, Tuple<IProblem, int>>[]
+      {
+        //(rand) => Tuple.Create((IProblem)new SantaFeAntProblem(), 17),
+        //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:0, correctReward:1, decoyReward:0, phrasesAsSets:false ), 15),
+        //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:0, correctReward:1, decoyReward:0, phrasesAsSets:true ), 15),
+        //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:200, correctReward:1, decoyReward:0.5, phrasesAsSets:false), 15),
+        //(rand) => Tuple.Create((IProblem)new FindPhrasesProblem(rand, 10, numPhrases:5, phraseLen:3, numOptimalPhrases:5, numDecoyPhrases:200, correctReward:1, decoyReward:0.5, phrasesAsSets:true), 15),
+        (rand) => Tuple.Create((IProblem)new SymbolicRegressionPoly10Problem(), 23)
+      };
+
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var useCanonical in new bool[] { true /*, false */ }) {
+          foreach (var randomTries in new int[] { 1 /*, 1, 10 /*, /* 5, 100 /*, 500, 1000 */}) {
+            foreach (var policyFactory in policyFactories) {
+              var myRandomTries = randomTries;
+              var localRand = new Random(localRandSeed);
+              var options = new ParallelOptions();
+              options.MaxDegreeOfParallelism = 1;
+              Parallel.For(0, reps, options, (i) => {
+                Random myLocalRand;
+                lock (localRand)
+                  myLocalRand = new Random(localRand.Next());
+
+                int iterations = 0;
+                var globalStatistics = new SentenceSetStatistics();
+
+                // var problem = new SymbolicRegressionPoly10Problem();
+                // var problem = new SantaFeAntProblem();
+                //var problem = new PalindromeProblem();
+                //var problem = new HardPalindromeProblem();
+                //var problem = new RoyalPairProblem();
+                //var problem = new EvenParityProblem();
+                // var alg = new MctsSampler(problem.Item1, problem.Item2, myLocalRand, myRandomTries, policy()); 
+                var instance = instanceFactory(myLocalRand);
+                var problem = instance.Item1;
+                var maxLen = instance.Item2;
+                var alg = new SequentialSearch(problem, maxLen, myLocalRand, myRandomTries,
+                  new GenericGrammarPolicy(problem, policyFactory(), useCanonical));
+                // var alg = new SequentialSearch(problem, maxLen, myLocalRand,
+                //   myRandomTries,
+                //   new GenericFunctionApproximationGrammarPolicy(problem,
+                //     useCanonical));
+                //var alg = new ExhaustiveBreadthFirstSearch(problem, 25);
+                //var alg = new AlternativesContextSampler(problem, 25);
+
+                alg.SolutionEvaluated += (sentence, quality) => {
+                  iterations++;
+                  globalStatistics.AddSentence(sentence, quality);
+                  if (iterations % 1000 == 0) {
+                    Console.WriteLine("{0,3} {1,5} \"{2,25}\" {3} {4} {5}", i, myRandomTries, policyFactory(), useCanonical, problem.ToString(), globalStatistics);
+                  }
+                };
+                alg.FoundNewBestSolution += (sentence, quality) => {
+                  //Console.WriteLine("{0,5} {1,25} {2} {3}",
+                  //  myRandomTries, policyFactory(), useCanonical,
+                  //  globalStatistics);
+                };
+
+                alg.Run(maxIterations);
+              });
+            }
+          }
+        }
+      }
+    }
+  }
+}
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunGpExperiments.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunGpExperiments.cs	(revision 11981)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunGpExperiments.cs	(revision 11981)
@@ -0,0 +1,328 @@
+﻿using System;
+using System.Collections;
+using System.Collections.Generic;
+using HeuristicLab.Algorithms.GeneticProgramming;
+using HeuristicLab.Algorithms.GrammaticalOptimization;
+using HeuristicLab.Problems.GrammaticalOptimization.SymbReg;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Problems.GrammaticalOptimization.Test {
+
+
+  [TestClass]
+  public class RunGpExperiments {
+    private readonly static int[] popSizes = new int[] { 100, 250, 500, 1000, 2500, 5000, 10000 };
+    private readonly static double[] mutationRates = new double[] { 0.15 };
+    private readonly static int randSeed = 31415;
+
+    internal class GPConfiguration {
+      public ISymbolicExpressionTreeProblem Problem;
+      public int PopSize;
+      public int MaxSize;
+      public int RandSeed;
+      public double MutationRate;
+
+      public override string ToString() {
+        return string.Format("{0} {1} {2} {3} {4}", RandSeed, Problem, PopSize, MaxSize, MutationRate);
+      }
+    }
+
+    #region permutation
+    [TestMethod]
+    public void RunStandardGPPermutationProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new PermutationProblem(), 
+      };
+
+      var maxSizes = new int[] { 32 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunStandardGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunOffspringSelectionGPPermutationProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new PermutationProblem(), 
+      };
+
+      var maxSizes = new int[] { 32 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunOffspringSelectionGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    #endregion
+
+    #region royalpair
+    [TestMethod]
+    public void RunStandardGPRoyalPairProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new RoyalPairProblem(), 
+      };
+
+      var maxSizes = new int[] { 32, 64, 128, 256 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunStandardGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunOffspringSelectionGPRoyalPairProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new RoyalPairProblem(), 
+      };
+
+      var maxSizes = new int[] { 32, 64, 128, 256 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunOffspringSelectionGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    #endregion
+
+    #region royalsymbol
+    [TestMethod]
+    public void RunStandardGPRoyalSymbolProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new RoyalSymbolProblem(), 
+      };
+
+      var maxSizes = new int[] { 32, 64, 128, 256 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunStandardGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunOffspringSelectionGPRoyalSymbolProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem)new RoyalSymbolProblem(), 
+      };
+
+      var maxSizes = new int[] { 32, 64, 128, 256 };
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunOffspringSelectionGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    #endregion
+
+    #region findphrases
+    [TestMethod]
+    public void RunStandardGPFindPhrasesProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 0, 1, 0, true), 
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 0, 1, 0, false), 
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 50, 1, 0.8, false), 
+      };
+
+      var maxSizes = new int[] { 15 * 3 }; // * 3 for non-terminals
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunStandardGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunOffspringSelectionGPFindPhrasesProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 0, 1, 0, true), 
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 0, 1, 0, false), 
+        (randSeed) => (ISymbolicExpressionTreeProblem) new FindPhrasesProblem(new Random(randSeed), 20, 5, 3, 5, 50, 1, 0.8, false), 
+      };
+
+      var maxSizes = new int[] { 15 * 3 }; // * 3 for non-terminals
+      int nReps = 20;
+      int maxIterations = 50000;
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunOffspringSelectionGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    #endregion
+
+    #region artificial ant
+    [TestMethod]
+    public void RunStandardGPArtificialAntProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SantaFeAntProblem(), 
+      };
+
+      var maxSizes = new int[] { 30, 50, 100 }; // size of sequential representation is 17
+      int nReps = 20;
+      int maxIterations = 100000; // randomsearch finds the optimum almost always for 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunStandardGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunOffspringSelectionGPArtificialAntProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SantaFeAntProblem(), 
+      };
+
+      var maxSizes = new int[] { 30, 50, 100 }; // size of sequential representation is 17
+      int nReps = 20;
+      int maxIterations = 100000; // randomsearch finds the optimum almost always for 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunOffspringSelectionGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    #endregion
+
+    #region symb-reg-poly-10
+    [TestMethod]
+    public void RunStandardGPPoly10Problem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SymbolicRegressionPoly10Problem(), 
+      };
+
+      var maxSizes = new int[] { 30, 50, 100 }; // size of sequential representation is 23
+      int nReps = 20;
+      int maxIterations = 100000; // sequentialsearch should find the optimum within 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunStandardGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    [TestMethod]
+    public void RunOffspringSelectionGPPoly10Problem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SymbolicRegressionPoly10Problem(), 
+      };
+
+      var maxSizes = new int[] { 30, 50, 100 }; // size of sequential representation is 23
+      int nReps = 20;
+      int maxIterations = 100000; // sequentialsearch should find the optimum within 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, popSizes, maxSizes, mutationRates)) {
+          RunOffspringSelectionGpForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.PopSize, conf.MaxSize, conf.MutationRate);
+        }
+      }
+    }
+    #endregion
+
+    #region helpers
+    private IEnumerable<GPConfiguration> GenerateConfigurations(Func<int, ISymbolicExpressionTreeProblem> problemFactory,
+      int nReps,
+      IEnumerable<int> popSizes,
+      IEnumerable<int> maxSizes,
+      IEnumerable<double> mutationRates) {
+      var seedRand = new Random(randSeed);
+      // the problem seed is the same for all configuratons 
+      // this guarantees that we solve the _same_ problem each time
+      // with different solvers and multiple repetitions
+      var problemSeed = randSeed;
+      for (int i = 0; i < nReps; i++) {
+        // in each repetition use the same random seed for all solver configuratons
+        // do nReps with different seeds for each configuration
+        var solverSeed = seedRand.Next();
+        foreach (var popSize in popSizes) {
+          foreach (var mutRate in mutationRates) {
+            foreach (var maxSize in maxSizes) {
+              yield return new GPConfiguration {
+                MaxSize = maxSize,
+                MutationRate = mutRate,
+                PopSize = popSize,
+                Problem = problemFactory(problemSeed),
+                RandSeed = solverSeed
+              };
+            }
+          }
+        }
+      }
+    }
+
+    private static void RunStandardGpForProblem(
+      int randSeed,
+      ISymbolicExpressionTreeProblem problem,
+      int maxIters,
+      int popSize,
+      int maxSize,
+      double mutationRate
+      ) {
+      var gp = new StandardGP(problem, new Random(randSeed), false);
+      var problemName = problem.GetType().Name;
+      var bestKnownQuality = problem.BestKnownQuality(maxSize);
+      RunGP(gp, problemName, bestKnownQuality, maxIters, popSize, mutationRate, maxSize);
+    }
+
+    private static void RunOffspringSelectionGpForProblem(
+  int randSeed,
+  ISymbolicExpressionTreeProblem problem,
+  int maxIters,
+  int popSize,
+  int maxSize,
+  double mutationRate
+  ) {
+      var gp = new OffspringSelectionGP(problem, new Random(randSeed), false);
+      var problemName = problem.GetType().Name;
+      var bestKnownQuality = problem.BestKnownQuality(maxSize);
+      RunGP(gp, problemName, bestKnownQuality, maxIters, popSize, mutationRate, maxSize);
+    }
+
+
+
+
+    private static void RunGP(IGPSolver gp, string problemName, double bestKnownQuality, int maxIters, int popSize, double mutationRate, int maxSize) {
+      int iterations = 0;
+      var globalStatistics = new SentenceSetStatistics(bestKnownQuality);
+      var gpName = gp.GetType().Name;
+      gp.SolutionEvaluated += (sentence, quality) => {
+        iterations++;
+        globalStatistics.AddSentence(sentence, quality);
+
+        if (iterations % 1000 == 0) {
+          Console.WriteLine("\"{0,25}\" {1} {2:N2} {3} \"{4,25}\" {5}", gpName, popSize, mutationRate, maxSize, problemName, globalStatistics);
+        }
+      };
+
+      gp.PopulationSize = popSize;
+      gp.MutationRate = mutationRate;
+      gp.MaxSolutionSize = maxSize + 2;
+      gp.MaxSolutionDepth = maxSize + 2;
+
+      gp.Run(maxIters);
+    }
+    #endregion
+  }
+}
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunSequentialSolverFuncApproxExperiments.cs
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunSequentialSolverFuncApproxExperiments.cs	(revision 11981)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/Test/RunSequentialSolverFuncApproxExperiments.cs	(revision 11981)
@@ -0,0 +1,123 @@
+﻿using System;
+using System.Collections;
+using System.Collections.Generic;
+using HeuristicLab.Algorithms.Bandits.GrammarPolicies;
+using HeuristicLab.Algorithms.GeneticProgramming;
+using HeuristicLab.Algorithms.GrammaticalOptimization;
+using HeuristicLab.Problems.GrammaticalOptimization;
+using HeuristicLab.Problems.GrammaticalOptimization.SymbReg;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Problems.GrammaticalOptimization.Test {
+  // only supported for Artificial Ant and Symbolic Regression up to now
+
+  [TestClass]
+  public class RunSequentialSolverFuncApproximationExperiments {
+    private readonly static int randSeed = 31415;
+
+    internal class Configuration {
+      public ISymbolicExpressionTreeProblem Problem;
+      public int MaxSize;
+      public int RandSeed;
+
+      public override string ToString() {
+        return string.Format("{0} {1} {2}", RandSeed, Problem, MaxSize);
+      }
+    }
+
+
+    #region artificial ant
+    [TestMethod]
+    public void RunSeqSolvFuncApproxArtificialAntProblem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SantaFeAntProblem(), 
+      };
+
+      var maxSizes = new int[] { 17 }; // size of sequential representation is 17
+      int nReps = 20;
+      int maxIterations = 100000; // randomsearch finds the optimum almost always for 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunSeqSolvFuncApproxForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+
+    #endregion
+
+    #region symb-reg-poly-10
+    [TestMethod]
+    public void RunSeqSolvFuncApproxPoly10Problem() {
+      var instanceFactories = new Func<int, ISymbolicExpressionTreeProblem>[]
+      {
+        (randSeed) => (ISymbolicExpressionTreeProblem) new SymbolicRegressionPoly10Problem(), 
+      };
+
+      var maxSizes = new int[] { 23 }; // size of sequential representation is 23
+      int nReps = 20;
+      int maxIterations = 100000; // sequentialsearch should find the optimum within 100000 evals
+      foreach (var instanceFactory in instanceFactories) {
+        foreach (var conf in GenerateConfigurations(instanceFactory, nReps, maxSizes)) {
+          RunSeqSolvFuncApproxForProblem(conf.RandSeed, conf.Problem, maxIterations, conf.MaxSize);
+        }
+      }
+    }
+
+    #endregion
+
+    #region helpers
+    private IEnumerable<Configuration> GenerateConfigurations(Func<int, ISymbolicExpressionTreeProblem> problemFactory,
+      int nReps,
+      IEnumerable<int> maxSizes
+      ) {
+      var seedRand = new Random(randSeed);
+      // the problem seed is the same for all configuratons 
+      // this guarantees that we solve the _same_ problem each time
+      // with different solvers and multiple repetitions
+      var problemSeed = randSeed;
+      for (int i = 0; i < nReps; i++) {
+        // in each repetition use the same random seed for all solver configuratons
+        // do nReps with different seeds for each configuration
+        var solverSeed = seedRand.Next();
+        foreach (var maxSize in maxSizes) {
+          yield return new Configuration {
+            MaxSize = maxSize,
+            Problem = problemFactory(problemSeed),
+            RandSeed = solverSeed
+          };
+        }
+      }
+    }
+
+    private static void RunSeqSolvFuncApproxForProblem(
+      int randSeed,
+      IProblem problem,
+      int maxIters,
+      int maxSize
+      ) {
+      var solver = new SequentialSearch(problem, maxSize, new Random(randSeed), 0,
+        new GenericFunctionApproximationGrammarPolicy(problem, true));
+      var problemName = problem.GetType().Name;
+      var bestKnownQuality = problem.BestKnownQuality(maxSize);
+      RunSolver(solver, problemName, bestKnownQuality, maxIters, maxSize);
+    }
+
+    private static void RunSolver(ISolver solver, string problemName, double bestKnownQuality, int maxIters, int maxSize) {
+      int iterations = 0;
+      var globalStatistics = new SentenceSetStatistics(bestKnownQuality);
+      var gpName = solver.GetType().Name;
+      solver.SolutionEvaluated += (sentence, quality) => {
+        iterations++;
+        globalStatistics.AddSentence(sentence, quality);
+
+        if (iterations % 1000 == 0) {
+          Console.WriteLine("\"{0,25}\" {1} \"{2,25}\" {3}", gpName, maxSize, problemName, globalStatistics);
+        }
+      };
+
+      solver.Run(maxIters);
+    }
+    #endregion
+  }
+}
Index: branches/HeuristicLab.Problems.GrammaticalOptimization/Test/Test.csproj
===================================================================
--- branches/HeuristicLab.Problems.GrammaticalOptimization/Test/Test.csproj	(revision 11980)
+++ branches/HeuristicLab.Problems.GrammaticalOptimization/Test/Test.csproj	(revision 11981)
@@ -39,16 +39,4 @@
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
-    </Reference>
-    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
-    </Reference>
-    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
-    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core">
@@ -69,4 +57,8 @@
   </Choose>
   <ItemGroup>
+    <Compile Include="RunDemo.cs" />
+    <Compile Include="RunSequentialSolverFuncApproxExperiments.cs" />
+    <Compile Include="RunBaselineExperiments.cs" />
+    <Compile Include="RunGpExperiments.cs" />
     <Compile Include="TestCanonicalExpressions.cs" />
     <Compile Include="TestSymbRegInstances.cs" />
