Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator.sln
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator.sln	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator.sln	(revision 16136)
@@ -0,0 +1,22 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.ExpressionGenerator", "HeuristicLab.ExpressionGenerator\3.4\HeuristicLab.ExpressionGenerator.csproj", "{78E3A433-C8CD-47CF-A5E4-33B568AF23BF}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{78E3A433-C8CD-47CF-A5E4-33B568AF23BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{78E3A433-C8CD-47CF-A5E4-33B568AF23BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{78E3A433-C8CD-47CF-A5E4-33B568AF23BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{78E3A433-C8CD-47CF-A5E4-33B568AF23BF}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Distributions.cs
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Distributions.cs	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Distributions.cs	(revision 16136)
@@ -0,0 +1,78 @@
+﻿
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Core;
+using HeuristicLab.ExpressionGenerator.Interfaces;
+
+namespace HeuristicLab.ExpressionGenerator {
+  // wrapper which calls NextDouble() of a PRNG to sample from a distribution
+  public class DoublePrngDistribution : IDistribution<double> {
+    private readonly IRandom prng;
+
+    public DoublePrngDistribution(IRandom random) {
+      this.prng = random;
+    }
+
+    public double Sample() {
+      return prng.NextDouble();
+    }
+
+    public IEnumerable<double> SampleN(int n) {
+      return Enumerable.Range(0, n).Select(_ => prng.NextDouble());
+    }
+  }
+  // wrapper which calls Next() of a PRNG to sample from a distribution
+  public class IntPrngDistribution : IDistribution<int> {
+    private readonly IRandom prng;
+
+    public IntPrngDistribution(IRandom random) {
+      this.prng = random;
+    }
+
+    public int Sample() {
+      return prng.Next();
+    }
+
+    public IEnumerable<int> SampleN(int n) {
+      return Enumerable.Range(0, n).Select(_ => prng.Next());
+    }
+  }
+
+  // p(x): x == value ? 1 : 0
+  public class PointDistribution<T> : IDistribution<T> where T : struct {
+    public readonly T value;
+
+    public PointDistribution(T value) {
+      this.value = value;
+    }
+
+    public T Sample() {
+      return value;
+    }
+
+    public IEnumerable<T> SampleN(int n) {
+      return Enumerable.Repeat(value, n);
+    }
+  }
+
+  public class DiscreteUniformDistribution : IDistribution<int> {
+    public readonly int minValue; // inclusive
+    public readonly int maxValue; // exclusive
+    public readonly IRandom random;
+
+    public DiscreteUniformDistribution(IRandom random, int minValue, int maxValue) {
+      this.minValue = minValue;
+      this.maxValue = maxValue;
+      this.random = random;
+    }
+
+    public int Sample() {
+      return random.Next(minValue, maxValue);
+    }
+
+    public IEnumerable<int> SampleN(int n) {
+      return Enumerable.Range(0, n).Select(_ => Sample());
+    }
+  }
+}
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs	(revision 16136)
@@ -0,0 +1,204 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Random;
+
+namespace HeuristicLab.ExpressionGenerator {
+  public class Expression : IExpression {
+    // unique name for each expression 
+    public string Name { get; set; }
+    // optional label (non-unique) - useful for string (infix) representations
+    public string Label { get; set; }
+
+    public ExpressionType Type { get; private set; }
+
+    private readonly List<Expression> arguments; // only for functions
+    public IEnumerable<Expression> Arguments {
+      get { return arguments ?? Enumerable.Empty<Expression>(); }
+    }
+
+    public IRandom Distribution { get; private set; }  // only for random variables
+
+    public Func<IEnumerable<double>, double> Transform { get; private set; } // only for functions
+
+    public double Value { get; private set; } // only for constants
+
+    public Expression(string name, double value) {
+      Type = ExpressionType.Constant;
+      Value = value;
+      Name = name;
+    }
+
+    public Expression(string name, IRandom distribution) {
+      Type = ExpressionType.RandomVariable;
+      Distribution = distribution;
+      Name = name;
+    }
+
+    public Expression(string name, Func<IEnumerable<double>, double> transform, IEnumerable<Expression> arguments) {
+      Type = ExpressionType.Function;
+      Transform = transform;
+      this.arguments = this.arguments ?? new List<Expression>();
+      this.arguments.AddRange(arguments);
+      Name = name;
+    }
+
+    public static Expression Constant(string name, double value) {
+      return new Expression(name, value);
+    }
+
+    public static Expression RandomVariable(string name, IRandom distribution) {
+      return new Expression(name, distribution);
+    }
+
+    public static Expression Function(string name, Func<IEnumerable<double>, double> transform, IEnumerable<Expression> arguments) {
+      return new Expression(name, transform, arguments);
+    }
+
+    public override string ToString() {
+      var sb = new StringBuilder();
+
+      switch (Type) {
+        case ExpressionType.Constant:
+          sb.Append(Value.ToString("E4", CultureInfo.InvariantCulture));
+          break;
+        case ExpressionType.RandomVariable:
+          sb.Append(string.Format("{0} ~ {1}", Name, GetStringDescription(Distribution)));
+          break;
+        case ExpressionType.Function:
+          sb.Append(string.Format("{0} = f(", Name));
+          if (Arguments.Any()) {
+            for (int i = 0; i < arguments.Count - 1; ++i)
+              sb.Append(string.Format("{0}, ", arguments[i].Name));
+            sb.Append(string.Format("{0})", arguments.Last().Name));
+          }
+          break;
+      }
+
+      return sb.ToString();
+    }
+
+    public string PrintInfix() {
+      var sb = new StringBuilder();
+      switch (Type) {
+        case ExpressionType.Constant:
+          sb.Append(Value < 0
+              ? string.Format("(- {0})", Math.Abs(Value).ToString("E4", CultureInfo.InvariantCulture))
+              : Value.ToString("E4", CultureInfo.InvariantCulture));
+          break;
+        case ExpressionType.RandomVariable:
+          sb.Append(Name);
+          break;
+        case ExpressionType.Function:
+          if (!Arguments.Any())
+            break;
+          var args = Arguments.ToList();
+          // the Label should be known to the infix parser
+          if (Label == "+" || Label == "-" || Label == "*" || Label == "/") {
+            if (args.Count == 1) {
+              sb.Append(string.Format(Label == "/" ? "1 / {0}" : "{0}", args[0].PrintInfix()));
+            } else {
+              if (Label == "/") {
+                sb.Append(string.Format("{0} / ", args[0].PrintInfix()));
+                var remaining = args.Count - 1;
+                if (remaining == 1)
+                  sb.Append(args[1].PrintInfix());
+                else {
+                  sb.Append("(");
+                  var last = args.Last();
+                  for (int i = 1; i < args.Count - 1; ++i) {
+                    var arg = args[i];
+                    sb.Append(string.Format("{0} {1} ", arg.PrintInfix(), "*"));
+                  }
+                  sb.Append(string.Format("{0})", last.PrintInfix()));
+                }
+              } else {
+                sb.Append("(");
+                var last = args.Last();
+                for (int i = 0; i < args.Count - 1; ++i) {
+                  var arg = args[i];
+                  sb.Append(string.Format("{0} {1} ", arg.PrintInfix(), Label));
+                }
+                sb.Append(string.Format("{0})", last.PrintInfix()));
+              }
+            }
+          } else {
+            sb.Append(string.Format("{0}(", Label));
+            var last = args.Last();
+            for (int i = 0; i < args.Count - 1; ++i) {
+              var arg = args[i];
+              sb.Append(string.Format("{0}, ", arg.PrintInfix()));
+            }
+            sb.Append(string.Format("{0})", last.PrintInfix()));
+          }
+          break;
+      }
+      return sb.ToString();
+    }
+
+    public string PrintDot() {
+      var stack = new Stack<Expression>();
+      stack.Push(this);
+
+      var sb = new StringBuilder();
+      sb.AppendLine("digraph g {");
+
+      while (stack.Count > 0) {
+        var top = stack.Pop();
+
+        if (!top.Arguments.Any())
+          continue;
+
+        foreach (var arg in top.Arguments) {
+          var from = top.Arguments.Any() ? top.Name : top.ToString();
+          var to = arg.Arguments.Any() ? arg.Name : arg.ToString();
+          sb.AppendLine(string.Format("\"{0}\" -> \"{1}\";", from, to));
+          stack.Push(arg);
+        }
+      }
+
+      sb.AppendLine("}");
+      return sb.ToString();
+    }
+
+    private static string GetStringDescription(IRandom random) {
+      var normal = random as NormalDistributedRandom;
+      if (normal != null)
+        return string.Format("N({0}, {1})", normal.Mu, normal.Sigma);
+
+      var uniform = random as UniformDistributedRandom;
+      if (uniform != null)
+        return string.Format("U({0}, {1})", uniform.Min, uniform.Max);
+
+      var gamma = random as GammaDistributedRandom;
+      if (gamma != null)
+        return string.Format("G({0}, {1})", gamma.Shape, gamma.Rate);
+
+      return random.ToString();
+    }
+  }
+}
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionEvaluator.cs
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionEvaluator.cs	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionEvaluator.cs	(revision 16136)
@@ -0,0 +1,76 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace HeuristicLab.ExpressionGenerator {
+  public class ExpressionEvaluator {
+    private readonly Dictionary<Expression, double> evaluationCache;
+
+    public ExpressionEvaluator() {
+      evaluationCache = new Dictionary<Expression, double>();
+    }
+
+    public double Evaluate(Expression expression) {
+      double evaluation;
+      if (evaluationCache.TryGetValue(expression, out evaluation))
+        return evaluation;
+
+      switch (expression.Type) {
+        case ExpressionType.Constant:
+          evaluation = expression.Value;
+          break;
+        case ExpressionType.RandomVariable:
+          evaluation = expression.Distribution.NextDouble();
+          break;
+        case ExpressionType.Function:
+          var args = expression.Arguments.Select(Evaluate);
+          evaluation = expression.Transform(args);
+          break;
+        default:
+          throw new ArgumentException("Unknown expression type.");
+      }
+
+      evaluationCache[expression] = evaluation;
+      return evaluation;
+    }
+
+    public Dictionary<Expression, List<double>> GenerateData(Expression expression, int rows) {
+      return GenerateData(new [] {expression}, rows);
+    }
+    public Dictionary<Expression, List<double>> GenerateData(IEnumerable<Expression> expressions, int rows) {
+      var data = new Dictionary<Expression, List<double>>();
+      for (int i = 0; i < rows; ++i) {
+        evaluationCache.Clear();
+        foreach(var expr in expressions) Evaluate(expr);
+        foreach (var pair in evaluationCache) {
+          if (!data.ContainsKey(pair.Key))
+            data[pair.Key] = new List<double>();
+
+          data[pair.Key].Add(pair.Value);
+        }
+      }
+      return data;
+    }
+  }
+}
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionGenerator.cs
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionGenerator.cs	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionGenerator.cs	(revision 16136)
@@ -0,0 +1,292 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Core;
+using HeuristicLab.ExpressionGenerator.Interfaces;
+using HeuristicLab.Random;
+
+namespace HeuristicLab.ExpressionGenerator {
+  public static class ExpressionGenerator {
+    public static IEnumerable<Expression> GenerateRandomDistributedVariables(int numberOfVariables, string variablePrefix, IRandom randomDistribution) {
+      return Enumerable.Range(1, numberOfVariables).Select(x => Expression.RandomVariable(string.Format("{0}{1}", variablePrefix, x), randomDistribution));
+    }
+
+    public static Expression RationalExpression(IRandom uniformRandom, Expression[] variables, bool useLog, bool useExp) {
+      var numerators =
+        Enumerable.Range(0, 20)
+          .Select(
+            i =>
+              NonlinearExpressionTemplate(uniformRandom, variables, useLog, useExp, false)
+                .Instantiate("numerator" + i, uniformRandom, sampleWithRepetition: false))
+          .ToArray();
+      var denominators =
+        Enumerable.Range(0, 20)
+          .Select(
+            i =>
+              NonlinearExpressionTemplate(uniformRandom, variables, useLog, useExp, false)
+                .Instantiate("denominator" + i, uniformRandom, sampleWithRepetition: false))
+          .ToArray();
+
+
+      var scaledNumeratorTemplate = new ScalingTemplate(new PointDistribution<double>(1.0));
+      scaledNumeratorTemplate.AddArguments(numerators);
+
+      var scaledDenominatorTemplate = new RangeTemplate(
+        minValue: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 0.01, 1)),
+        valueRange: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 2, 10)));
+      scaledDenominatorTemplate.AddArguments(denominators);
+
+
+      var scaledNumerators =
+        Enumerable.Range(0, 20)
+          .Select(i => scaledNumeratorTemplate.Instantiate("scaledNumerator" + i, uniformRandom, false));
+
+      var scaledDenominators =
+        Enumerable.Range(0, 20)
+          .Select(i => scaledDenominatorTemplate.Instantiate("scaledDenom" + i, uniformRandom, false));
+
+      var template = new BinaryOperatorTemplate(Division) { Label = "/" };
+      template.AddLeftArguments(scaledNumerators);
+      template.AddRightArguments(scaledDenominators);
+
+      return template.Instantiate("rational", uniformRandom, false);
+    }
+
+    public static Expression SumOfCompactNonlinearTerms(IRandom uniformRandom, Expression[] variables, bool useLog,
+      bool useExp, bool useFrac) {
+      var numInstances = 2 * variables.Length;
+
+      var scalingVarsTemplate = new ScalingTemplate(new DoublePrngDistribution(new GammaDistributedRandom(uniformRandom, 2, 2))); // exp(x) = 1, var(x) = 8
+      scalingVarsTemplate.AddArguments(variables);
+      var scaledVars = Instantiate(scalingVarsTemplate, uniformRandom, numInstances, "scaledVar");
+
+      var sumOfScaledVarsTemplate = new RandomArityTemplate(Sum, new DiscreteUniformDistribution(uniformRandom, 1, 3)) { Label = "+" };
+      sumOfScaledVarsTemplate.AddArguments(scaledVars);
+      var sumOfScaledVars = Instantiate(sumOfScaledVarsTemplate, uniformRandom, numInstances, "sumOfScaledVars");
+
+      var prodTemplate = new RandomArityTemplate(Product, new DiscreteUniformDistribution(uniformRandom, 1, 3)) { Label = "*" };
+      prodTemplate.AddArguments(variables);
+
+      var logTermsTemplate = LogOfScaledExpression(uniformRandom, sumOfScaledVars,
+      minValue: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 0.1, 2)),
+      valueRange: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 1, 10)));
+      var logTerms = Instantiate(logTermsTemplate, uniformRandom, numInstances, "log");
+
+      var expTemplate = ExpOfScaledExpression(uniformRandom, Instantiate(prodTemplate, uniformRandom, numInstances, "prodOfVars"),
+                           minValue: new PointDistribution<double>(-2.0),
+                           valueRange: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 4, 6)));
+      var expTerms = Instantiate(expTemplate, uniformRandom, numInstances, "exp");
+
+      var fracTemplate = new BinaryOperatorTemplate(Division) { Label = "/" };
+      fracTemplate.AddLeftArgument(Expression.Constant("const", 1.0), variables.Length);
+      fracTemplate.AddLeftArguments(variables);
+      fracTemplate.AddRightArguments(sumOfScaledVars);
+      var fracTerms = Enumerable.Range(1, numInstances).Select(i => fracTemplate.Instantiate("frac" + i, uniformRandom, false));
+
+      var prodOfFactorsTemplate = new RandomArityTemplate(Product, new DiscreteUniformDistribution(uniformRandom, 1, 4)) { Label = "*" };
+      prodOfFactorsTemplate.AddArguments(variables, variables.Select(_ => 1.0));
+      if (useLog) prodOfFactorsTemplate.AddArguments(logTerms, logTerms.Select(_ => .3));
+      if (useExp) prodOfFactorsTemplate.AddArguments(expTerms, expTerms.Select(_ => .3));
+      if (useFrac) prodOfFactorsTemplate.AddArguments(fracTerms, fracTerms.Select(_ => .3));
+      var prodFactors = Instantiate(prodOfFactorsTemplate, uniformRandom, numInstances, "prod");
+
+      var scaledTermsTemplate =
+        new ScalingTemplate(new DoublePrngDistribution(new GammaDistributedRandom(uniformRandom, 2, 2))); // exp(x) = 1, var(x) = 8
+      scaledTermsTemplate.AddArguments(variables, variables.Select(_ => 1.0));
+      if (useLog) scaledTermsTemplate.AddArguments(logTerms, logTerms.Select(_ => 1.0));
+      if (useExp) scaledTermsTemplate.AddArguments(expTerms, expTerms.Select(_ => 1.0));
+      if (useFrac) scaledTermsTemplate.AddArguments(fracTerms, fracTerms.Select(_ => 1.0));
+      scaledTermsTemplate.AddArguments(prodFactors, prodFactors.Select(_ => 4.0));
+
+      var scaledTerms = Instantiate(scaledTermsTemplate, uniformRandom, 100, "scaledTerm");
+
+      var sumTemplate = new RandomArityTemplate(Sum, arityDistribution: new DiscreteUniformDistribution(uniformRandom, 5, 25)) { Label = "+" };
+      sumTemplate.AddArguments(scaledTerms);
+
+      return sumTemplate.Instantiate("sum", uniformRandom, false);
+    }
+
+    public static Expression NonlinearExpression(IRandom uniformRandom, Expression[] variables, bool useLog, bool useExp, bool useFrac) {
+      return NonlinearExpressionTemplate(uniformRandom, variables, useLog, useExp, useFrac)
+        .Instantiate("nonlinearexpr", uniformRandom, sampleWithRepetition: false);
+    }
+
+    public static ExpressionTemplate NonlinearExpressionTemplate(IRandom uniformRandom, Expression[] variables, bool useLog, bool useExp, bool useFrac) {
+      var scalingTemplate = ScaledExpression(uniformRandom, variables, varianceDistribution: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 1, 10)));
+      var scaledVars = Instantiate(scalingTemplate, uniformRandom, variables.Length, "scaledVar");
+
+      var sumTemplate = new RandomArityTemplate(Sum, new DiscreteUniformDistribution(uniformRandom, 1, 3)) { Label = "+" };
+      sumTemplate.AddArguments(scaledVars);
+      var prodTemplate = new RandomArityTemplate(Product, new DiscreteUniformDistribution(uniformRandom, 1, 3)) { Label = "*" };
+      prodTemplate.AddArguments(variables);
+
+      var logTemplate = LogOfScaledExpression(uniformRandom, Instantiate(sumTemplate, uniformRandom, scaledVars.Count(), "sumOfScaledVars"),
+        minValue: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 0.1, 2)),
+        valueRange: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 1, 10)));
+
+      var expTemplate = ExpOfScaledExpression(uniformRandom, Instantiate(prodTemplate, uniformRandom, variables.Length, "prodOfVars"),
+        minValue: new PointDistribution<double>(-3.0),
+        valueRange: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 4, 6)));
+
+      var variableSumTemplate = new RandomArityTemplate(Sum, new DiscreteUniformDistribution(uniformRandom, 1, 4)) { Label = "+" };
+      variableSumTemplate.AddArguments(variables);
+      var variableSums = Instantiate(variableSumTemplate, uniformRandom, variables.Length * 2, "varsum");
+
+      var scaledVariableSumTemplate =
+        new RangeTemplate(minValue: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 0.1, 1)),
+          valueRange: new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 1, 5))) { Label = "*" };
+      scaledVariableSumTemplate.AddArguments(variableSums);
+      var scaledVariableSums = Instantiate(scaledVariableSumTemplate, uniformRandom, variables.Length * 2,
+        "scaledvarsum");
+
+      var fracTemplate = new BinaryOperatorTemplate(Division) { Label = "/" };
+      fracTemplate.AddLeftArguments(variables);
+      fracTemplate.AddRightArguments(scaledVariableSums);
+
+      var scaledExprTemplate = new ScalingTemplate(new DoublePrngDistribution(new UniformDistributedRandom(uniformRandom, 1, 10))) { Label = "*" };
+      if (useLog) scaledExprTemplate.AddArguments(Instantiate(logTemplate, uniformRandom, scaledVars.Count(), "log"));
+      if (useExp) scaledExprTemplate.AddArguments(Instantiate(expTemplate, uniformRandom, variables.Length, "exp"));
+      if (useFrac) scaledExprTemplate.AddArguments(Enumerable.Range(0, 20).Select(i => fracTemplate.Instantiate("frac" + i, uniformRandom, false)));
+
+      var mainTemplate = new RandomArityTemplate(Sum, arityDistribution: new DiscreteUniformDistribution(uniformRandom, 3, 5));
+      mainTemplate.AddArguments(scaledVars);
+      if (useLog || useExp) {
+        mainTemplate.AddArguments(Instantiate(scaledExprTemplate, uniformRandom, 20, "scaledExpr"));
+      }
+      mainTemplate.Label = "+";
+
+      return mainTemplate;
+    }
+
+    public static Expression Polynomial(IRandom uniformRandom, Expression[] variables, bool useLog, bool useExp) {
+      const int count = 10; // how many instances of each template should be produce?
+      int i = 1;
+      // the main template
+      var template = new RandomArityTemplate(Sum, arityDistribution: new DiscreteUniformDistribution(uniformRandom, 2, count)) { Label = "+" };
+      template.AddArguments(variables);
+
+      var sumTemplate = new RandomArityTemplate(Sum, arityDistribution: new DiscreteUniformDistribution(uniformRandom, 1, variables.Length)) { Label = "+" };
+      sumTemplate.AddArguments(variables);
+
+      var productTemplate = new RandomArityTemplate(Product, arityDistribution: new DiscreteUniformDistribution(uniformRandom, 1, variables.Length)) { Label = "*" };
+      productTemplate.AddArguments(variables);
+
+      var inverseTemplate = new FixedArityTemplate(Division, 1) { Label = "/" };
+      inverseTemplate.AddArguments(variables);
+      inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => sumTemplate.Instantiate(string.Format("sum{0}", i++), uniformRandom)));
+      inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => productTemplate.Instantiate(string.Format("prod{0}", i++), uniformRandom)));
+
+      if (useLog) {
+        var logTemplate = new FixedArityTemplate(Log, 1) { Label = "log" };
+        logTemplate.AddArguments(variables);
+        logTemplate.AddArguments(Enumerable.Range(1, count).Select(x => sumTemplate.Instantiate(string.Format("sum{0}", i++), uniformRandom)));
+        template.AddArguments(Enumerable.Range(1, count).Select(x => logTemplate.Instantiate(string.Format("log{0}", i++), uniformRandom)));
+        inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => logTemplate.Instantiate(string.Format("log{0}", i++), uniformRandom)));
+      }
+
+      if (useExp) {
+        var expTemplate = new FixedArityTemplate(Exp, 1) { Label = "exp" };
+        expTemplate.AddArguments(variables);
+        expTemplate.AddArguments(Enumerable.Range(1, count).Select(x => productTemplate.Instantiate(string.Format("prod{0}", i++), uniformRandom)));
+        template.AddArguments(Enumerable.Range(1, count).Select(x => expTemplate.Instantiate(string.Format("exp{0}", i++), uniformRandom)));
+        inverseTemplate.AddArguments(Enumerable.Range(1, count).Select(x => expTemplate.Instantiate(string.Format("exp{0}", i++), uniformRandom)));
+      }
+
+      template.AddArguments(Enumerable.Range(1, count).Select(x => inverseTemplate.Instantiate(string.Format("inv{0}", i++), uniformRandom)));
+      return template.Instantiate("polynomial", uniformRandom);
+    }
+
+    // variance random must have support only positive numbers
+    private static ExpressionTemplate ScaledExpression(IRandom uniformRandom, IEnumerable<Expression> arguments, IDistribution<double> varianceDistribution) {
+      var scalingTemplate = new ScalingTemplate(scaledVariance: varianceDistribution);
+      scalingTemplate.AddArguments(arguments);
+      scalingTemplate.Label = "*";
+      return scalingTemplate;
+    }
+
+    /// template scales and translates the argument expression first to guarantee positive values
+    private static ExpressionTemplate LogOfScaledExpression(IRandom uniformRandom, IEnumerable<Expression> arguments,
+      IDistribution<double> minValue = null, IDistribution<double> valueRange = null) {
+      var limitToRangeTemplate = new RangeTemplate(minValue, valueRange);
+      limitToRangeTemplate.AddArguments(arguments);
+
+      var logTemplate = new FixedArityTemplate(Log, 1) { Label = "log" };
+      logTemplate.AddArguments(Enumerable.Range(1, arguments.Count()).Select(i => limitToRangeTemplate.Instantiate(string.Format("log{0}", i), uniformRandom, false)));
+      return logTemplate;
+    }
+
+    /// template scales the argument expression first to guarantee reasonable values
+    private static ExpressionTemplate ExpOfScaledExpression(IRandom uniformRandom, IEnumerable<Expression> arguments,
+      IDistribution<double> minValue = null,
+      IDistribution<double> valueRange = null) {
+      var limitToRangeTemplate = new RangeTemplate(minValue, valueRange);
+      limitToRangeTemplate.AddArguments(arguments);
+
+      var expTemplate = new FixedArityTemplate(Exp, 1) { Label = "exp" };
+      expTemplate.AddArguments(Enumerable.Range(1, arguments.Count()).Select(i => limitToRangeTemplate.Instantiate(string.Format("exp{0}", i), uniformRandom, false)));
+      return expTemplate;
+    }
+
+    public static IEnumerable<Expression> Instantiate(ExpressionTemplate template, IRandom random, int count, string name) {
+      return Enumerable.Range(1, count).Select(i => template.Instantiate(name + i, random, false));
+    }
+
+    #region static functions
+    public static double Sum(IEnumerable<double> args) {
+      return args.Sum();
+    }
+
+    public static double Product(IEnumerable<double> args) {
+      return args.Aggregate((x, y) => x * y);
+    }
+
+    public static double Division(IEnumerable<double> args) {
+      if (args.Count() == 1)
+        return 1 / args.First();
+
+      return args.Aggregate((x, y) => x / y);
+    }
+
+    public static double Subtraction(IEnumerable<double> args) {
+      if (args.Count() == 1)
+        return -args.First();
+
+      return args.Aggregate((x, y) => x - y);
+    }
+
+    public static double Exp(IEnumerable<double> args) {
+      return Math.Exp(args.Single());
+    }
+
+    public static double Log(IEnumerable<double> args) {
+      return Math.Log(args.Single());
+    }
+
+    public static double Square(IEnumerable<double> args) {
+      var v = args.Single();
+      return v * v;
+    }
+    #endregion
+  }
+}
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs	(revision 16136)
@@ -0,0 +1,255 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.ExpressionGenerator.Interfaces;
+using HeuristicLab.Random;
+
+namespace HeuristicLab.ExpressionGenerator {
+  public interface IExpressionTemplate {
+    string Label { get; set; }
+  }
+  public abstract class ExpressionTemplate : IExpressionTemplate {
+    protected List<Tuple<Expression, double>> arguments;
+    protected readonly Func<IEnumerable<double>, double> transform;
+    public string Label { get; set; }
+
+    protected Expression Instantiate(string name, IRandom random, int n, bool sampleWithRepetition = false) {
+      var func = Expression.Function(name, transform, SampleArguments(random, n, sampleWithRepetition));
+      func.Label = Label;
+      return func;
+    }
+
+    protected IEnumerable<Expression> SampleArguments(IRandom random, int n, bool sampleWithRepetition = false) {
+      var weights = arguments.Select(x => x.Item2);
+      var args = sampleWithRepetition
+       ? arguments.SampleProportional(random, n, weights, windowing: false).Select(x => x.Item1)
+       : arguments.SampleProportionalWithoutRepetition(random, n, weights, windowing: false).Select(x => x.Item1);
+      return args;
+    }
+
+    public abstract Expression Instantiate(string name, IRandom random, bool sampleWithRepetition = false);
+
+    protected ExpressionTemplate(Func<IEnumerable<double>, double> transform) {
+      this.transform = transform;
+    }
+
+    public void AddArgument(Expression expression, double weight = 1d) {
+      arguments = arguments ?? new List<Tuple<Expression, double>>();
+      arguments.Add(Tuple.Create(expression, weight));
+    }
+
+    public void AddArguments(IEnumerable<Expression> expressions) {
+      arguments = arguments ?? new List<Tuple<Expression, double>>();
+      arguments.AddRange(expressions.Select(x => Tuple.Create(x, 1d)));
+    }
+
+    public void AddArguments(IEnumerable<Expression> expressions, IEnumerable<double> weights) {
+      arguments = arguments ?? new List<Tuple<Expression, double>>();
+      arguments.AddRange(expressions.Zip(weights, Tuple.Create));
+    }
+  }
+
+  public class RandomArityTemplate : ExpressionTemplate {
+    private readonly IDistribution<int> arityDistribution;
+
+    public RandomArityTemplate(Func<IEnumerable<double>, double> transform, IDistribution<int> arityDistribution) : base(transform) {
+      this.arityDistribution = arityDistribution;
+    }
+
+    public override Expression Instantiate(string name, IRandom random, bool sampleWithRepetition = false) {
+      var arity = arityDistribution.Sample();
+      return Instantiate(name, random, arity, sampleWithRepetition);
+    }
+  }
+
+  public class FixedArityTemplate : ExpressionTemplate {
+    private readonly int arity;
+    public FixedArityTemplate(Func<IEnumerable<double>, double> transform, int arity) : base(transform) {
+      this.arity = arity;
+    }
+
+    public override Expression Instantiate(string name, IRandom random, bool sampleWithRepetition = false) {
+      return Instantiate(name, random, arity, sampleWithRepetition);
+    }
+  }
+
+
+  public class BinaryOperatorTemplate : IExpressionTemplate {
+    public string Label { get; set; }
+    private readonly Func<IEnumerable<double>, double> transform;
+    private List<Tuple<Expression, double>> leftArguments;
+    private List<Tuple<Expression, double>> rightArguments;
+
+    public BinaryOperatorTemplate(Func<IEnumerable<double>, double> transform) {
+      this.transform = transform;
+    }
+
+    public void AddLeftArgument(Expression expression, double weight = 1d) {
+      leftArguments = leftArguments ?? new List<Tuple<Expression, double>>();
+      leftArguments.Add(Tuple.Create(expression, weight));
+    }
+
+    public void AddLeftArguments(IEnumerable<Expression> expressions) {
+      leftArguments = leftArguments ?? new List<Tuple<Expression, double>>();
+      leftArguments.AddRange(expressions.Select(x => Tuple.Create(x, 1d)));
+    }
+
+    public void AddLeftArguments(IEnumerable<Expression> expressions, IEnumerable<double> weights) {
+      leftArguments = leftArguments ?? new List<Tuple<Expression, double>>();
+      leftArguments.AddRange(expressions.Zip(weights, Tuple.Create));
+    }
+
+
+    public void AddRightArgument(Expression expression, double weight = 1d) {
+      rightArguments = rightArguments ?? new List<Tuple<Expression, double>>();
+      rightArguments.Add(Tuple.Create(expression, weight));
+    }
+
+    public void AddRightArguments(IEnumerable<Expression> expressions) {
+      rightArguments = rightArguments ?? new List<Tuple<Expression, double>>();
+      rightArguments.AddRange(expressions.Select(x => Tuple.Create(x, 1d)));
+    }
+
+    public void AddRightArguments(IEnumerable<Expression> expressions, IEnumerable<double> weights) {
+      rightArguments = rightArguments ?? new List<Tuple<Expression, double>>();
+      rightArguments.AddRange(expressions.Zip(weights, Tuple.Create));
+    }
+
+    public Expression Instantiate(string name, IRandom random, bool sampleWithRepetition = false) {
+      Expression leftArgument = null;
+      Expression rightArgument = null;
+      {
+        var weights = leftArguments.Select(x => x.Item2);
+        leftArgument = sampleWithRepetition
+          ? leftArguments.SampleProportional(random, 1, weights, windowing: false).Select(x => x.Item1).First() :
+          leftArguments.SampleProportionalWithoutRepetition(random, 1, weights, windowing: false).Select(x => x.Item1).First();
+      }
+      {
+        var weights = rightArguments.Select(x => x.Item2);
+        rightArgument = sampleWithRepetition
+          ? rightArguments.SampleProportional(random, 1, weights).Select(x => x.Item1).First() :
+          rightArguments.SampleProportionalWithoutRepetition(random, 1, weights).Select(x => x.Item1).First();
+      }
+
+      var func = Expression.Function(name, transform, new Expression[] { leftArgument, rightArgument });
+      func.Label = Label;
+      return func;
+    }
+  }
+
+  public class ScalingTemplate : ExpressionTemplate {
+    private readonly IDistribution<double> scaledVariance;
+    // w * expr
+    public ScalingTemplate(IDistribution<double> scaledVariance = null) : base(ExpressionGenerator.Product) {
+      this.scaledVariance = scaledVariance;
+    }
+
+    public override Expression Instantiate(string name, IRandom random, bool sampleWithRepetition = false) {
+      var expr = SampleArguments(random, 1, sampleWithRepetition).First();
+
+      // use the evaluator to determine variance of the sampled expression and initialize the constant accordingly to reach the target variance
+      var @const = 1.0;
+      if (scaledVariance != null) {
+        var evaluator = new ExpressionEvaluator();
+        var data = evaluator.GenerateData(expr, 10000);
+        var variance = data[expr].VariancePop();
+        @const = scaledVariance.Sample() / variance;
+      }
+
+      var func = Expression.Function(name, transform, new Expression[] { Expression.Constant(name, @const), expr });
+      func.Label = "*";
+      return func;
+    }
+  }
+
+  public class OffsetTemplate : ExpressionTemplate {
+    private readonly IDistribution<double> offset;
+    // expr + offset
+    public OffsetTemplate(IDistribution<double> offset = null) : base(ExpressionGenerator.Sum) {
+      this.offset = offset;
+    }
+
+    public override Expression Instantiate(string name, IRandom random, bool sampleWithRepetition = false) {
+      var expr = SampleArguments(random, 1, sampleWithRepetition).First();
+
+      // use the evaluator to determine variance of the sampled expression and initialize the constant accordingly to reach the target offset
+      var @const = 0.0;
+      if (offset != null) {
+        var evaluator = new ExpressionEvaluator();
+        var data = evaluator.GenerateData(expr, 10000);
+        var average = data[expr].Average();
+        @const = offset.Sample() - average;
+      }
+
+      var func = Expression.Function(name, transform, new Expression[] { Expression.Constant(name, @const), expr });
+      func.Label = "+";
+      return func;
+    }
+  }
+
+  public class RangeTemplate : ExpressionTemplate {
+    private readonly IDistribution<double> minValue;
+    private readonly IDistribution<double> valueRange;
+    // expr + offset
+    public RangeTemplate(IDistribution<double> minValue = null, IDistribution<double> valueRange = null) : base(null) {
+      this.minValue = minValue;
+      this.valueRange = valueRange;
+    }
+
+    public override Expression Instantiate(string name, IRandom random, bool sampleWithRepetition = false) {
+      var expr = SampleArguments(random, 1, sampleWithRepetition).First();
+
+      // use the evaluator to determine variance of the sampled expression and initialize the constant accordingly to reach the target offset
+      var mult = 1.0;
+      var add = 0.0;
+
+      if (minValue != null || valueRange != null) {
+        var evaluator = new ExpressionEvaluator();
+        var data = evaluator.GenerateData(expr, 10000);
+        if (valueRange != null) {
+          var targetRange = valueRange.Sample();
+          var min = data[expr].Min();
+          var max = data[expr].Max();
+          var range = max - min;
+          mult = targetRange / range;
+          add = -min + min / mult;
+        }
+        if (minValue != null) {
+          var targetMin = minValue.Sample();
+          var min = data[expr].Min();
+          add += (targetMin - min) / mult;
+        }
+
+        expr = Expression.Function(name + "-toZero", ExpressionGenerator.Sum, new Expression[] { Expression.Constant("name-add0", add), expr });
+        expr.Label = "+";
+        expr = Expression.Function(name + "-mult", ExpressionGenerator.Product, new Expression[] { Expression.Constant("name-mult", mult), expr });
+        expr.Label = "*";
+      }
+
+      return expr;
+    }
+  }
+}
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/HeuristicLab.ExpressionGenerator.csproj
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/HeuristicLab.ExpressionGenerator.csproj	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/HeuristicLab.ExpressionGenerator.csproj	(revision 16136)
@@ -0,0 +1,102 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{78E3A433-C8CD-47CF-A5E4-33B568AF23BF}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>HeuristicLab.ExpressionGenerator</RootNamespace>
+    <AssemblyName>HeuristicLab.ExpressionGenerator-3.4</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <LangVersion>4</LangVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="HeuristicLab.Common-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="HeuristicLab.Core-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="HeuristicLab.Data-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="HeuristicLab.Persistence-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
+      <Private>False</Private>
+    </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>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="HeuristicLab.Random-3.3">
+      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Distributions.cs" />
+    <Compile Include="Expression.cs" />
+    <Compile Include="ExpressionEvaluator.cs" />
+    <Compile Include="ExpressionGenerator.cs" />
+    <Compile Include="ExpressionTemplate.cs" />
+    <Compile Include="Interfaces\IDistribution.cs" />
+    <Compile Include="Interfaces\IExpression.cs" />
+    <Compile Include="Plugin.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Properties\AssemblyInfo.cs.frame" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+set ProjectDir=$(ProjectDir)
+set SolutionDir=$(SolutionDir)
+set Outdir=$(Outdir)
+
+call PreBuildEvent.cmd</PreBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Interfaces/IDistribution.cs
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Interfaces/IDistribution.cs	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Interfaces/IDistribution.cs	(revision 16136)
@@ -0,0 +1,8 @@
+﻿using System.Collections.Generic;
+
+namespace HeuristicLab.ExpressionGenerator.Interfaces {
+  public interface IDistribution<T> {
+    T Sample();
+    IEnumerable<T> SampleN(int n);
+  }
+}
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Interfaces/IExpression.cs
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Interfaces/IExpression.cs	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Interfaces/IExpression.cs	(revision 16136)
@@ -0,0 +1,36 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.ExpressionGenerator {
+  public enum ExpressionType { Constant, RandomVariable, Function }
+
+  public interface IExpression {
+    ExpressionType Type { get; }
+    Func<IEnumerable<double>, double> Transform { get; } // gkronber: better name?
+    IEnumerable<Expression> Arguments { get; }
+    IRandom Distribution { get; }  
+    double Value { get; } 
+  }
+}
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Plugin.cs.frame
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Plugin.cs.frame	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Plugin.cs.frame	(revision 16136)
@@ -0,0 +1,35 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-$year$ Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.ExpressionGenerator {
+  [Plugin("HeuristicLab.ExpressionGenerator", "3.4.0.$WCREV$")]
+  [PluginFile("HeuristicLab.ExpressionGenerator-3.4.dll", PluginFileType.Assembly)]
+  [PluginDependency("HeuristicLab.Common", "3.3")]
+  [PluginDependency("HeuristicLab.Core", "3.3")]
+  [PluginDependency("HeuristicLab.Data", "3.3")]
+  [PluginDependency("HeuristicLab.Persistence", "3.3")]
+  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
+  [PluginDependency("HeuristicLab.Random", "3.3")]
+  public class HeuristicLabExpressionGeneratorPlugin : PluginBase {
+  }
+}
Index: /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Properties/AssemblyInfo.cs.frame
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Properties/AssemblyInfo.cs.frame	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Properties/AssemblyInfo.cs.frame	(revision 16136)
@@ -0,0 +1,55 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristicLab.ExpressionGenerator")]
+[assembly: AssemblyDescription("Provides methods to automatically generate mathematical expressions")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2016 HEAL")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("13c7216b-bd02-4f3f-9ebc-2aa8a14ae12c")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers 
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("3.4.0.0")]
+[assembly: AssemblyFileVersion("3.4.10.$WCREV$")]
Index: /branches/2704_HeuristicLab.ExpressionGenerator/PreBuildEvent.cmd
===================================================================
--- /branches/2704_HeuristicLab.ExpressionGenerator/PreBuildEvent.cmd	(revision 16136)
+++ /branches/2704_HeuristicLab.ExpressionGenerator/PreBuildEvent.cmd	(revision 16136)
@@ -0,0 +1,11 @@
+IF EXIST "%ProjectDir%\Properties\AssemblyInfo.cs.frame" SubWCRev "%ProjectDir%\" "%ProjectDir%\Properties\AssemblyInfo.cs.frame" "%ProjectDir%\Properties\AssemblyInfo.cs"
+IF %ERRORLEVEL% NEQ 0 GOTO Error_Handling
+IF EXIST "%ProjectDir%\Plugin.cs.frame" SubWCRev "%ProjectDir%\" "%ProjectDir%\Plugin.cs.frame" "%ProjectDir%\Plugin.cs"
+IF %ERRORLEVEL% NEQ 0 GOTO Error_Handling
+GOTO Done
+
+:Error_Handling
+ECHO There was an error while running subwcrev. Please verify that the *.cs.frame files have been correctly converted to *.cs files, otherwise HeuristicLab won't build. 
+exit 0
+
+:Done
