Index: /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator.sln
===================================================================
--- /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator.sln	(revision 14409)
+++ /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator.sln	(revision 14409)
@@ -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/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs
===================================================================
--- /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs	(revision 14409)
+++ /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs	(revision 14409)
@@ -0,0 +1,118 @@
+﻿#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 {
+    public string Label { get; set; }
+
+    public ExpressionType Type { get; }
+
+    private readonly List<Expression> arguments;
+    public IEnumerable<Expression> Arguments {
+      get { return arguments ?? Enumerable.Empty<Expression>(); }
+    }
+
+    public IRandom Distribution { get; }
+
+    public Func<IEnumerable<double>, double> Transform { get; }
+
+    public double Value { get; }
+
+    public Expression(string label, double value) {
+      Type = ExpressionType.Constant;
+      Value = value;
+      Label = label;
+    }
+
+    public Expression(string label, IRandom distribution) {
+      Type = ExpressionType.RandomVariable;
+      Distribution = distribution;
+      Label = label;
+    }
+
+    public Expression(string label, Func<IEnumerable<double>, double> transform, IEnumerable<Expression> arguments) {
+      Type = ExpressionType.Function;
+      Transform = transform;
+      this.arguments = this.arguments ?? new List<Expression>();
+      this.arguments.AddRange(arguments);
+      Label = label;
+    }
+
+    public static Expression Constant(string label, double value) {
+      return new Expression(label, value);
+    }
+
+    public static Expression RandomVariable(string label, IRandom distribution) {
+      return new Expression(label, distribution);
+    }
+
+    public static Expression Function(string label, Func<IEnumerable<double>, double> transform, IEnumerable<Expression> arguments) {
+      return new Expression(label, transform, arguments);
+    }
+
+    public override string ToString() {
+      var sb = new StringBuilder();
+
+      switch (Type) {
+        case ExpressionType.Constant:
+          sb.Append(Value.ToString("0.000", CultureInfo.CurrentCulture));
+          break;
+        case ExpressionType.RandomVariable:
+          sb.Append(string.Format("{0} ~ {1}", Label, GetStringDescription(Distribution)));
+          break;
+        case ExpressionType.Function:
+          sb.Append(string.Format("{0} (", Label));
+          if (arguments != null) {
+            for (int i = 0; i < arguments.Count - 1; ++i)
+              sb.Append(string.Format("{0}, ", arguments[i]));
+            sb.Append(string.Format("{0})", arguments.Last()));
+          }
+          break;
+      }
+
+      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/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionEvaluator.cs
===================================================================
--- /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionEvaluator.cs	(revision 14409)
+++ /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionEvaluator.cs	(revision 14409)
@@ -0,0 +1,73 @@
+﻿#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) {
+      var data = new Dictionary<Expression, List<double>>();
+      for (int i = 0; i < rows; ++i) {
+        evaluationCache.Clear();
+        Evaluate(expression);
+        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/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs
===================================================================
--- /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs	(revision 14409)
+++ /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs	(revision 14409)
@@ -0,0 +1,82 @@
+﻿#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.Random;
+
+namespace HeuristicLab.ExpressionGenerator {
+  public abstract class ExpressionTemplate {
+    protected List<Tuple<Expression, double>> arguments;
+    protected readonly Func<IEnumerable<double>, double> transform;
+    protected readonly string label;
+
+    public abstract Expression Instantiate(IRandom random);
+
+    protected ExpressionTemplate(string label, Func<IEnumerable<double>, double> transform) {
+      this.transform = transform;
+      this.label = label;
+    }
+
+    public void AddArgument(Expression expression, double priority = 1d) {
+      arguments = arguments ?? new List<Tuple<Expression, double>>();
+      arguments.Add(Tuple.Create(expression, priority));
+    }
+
+    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> priorities) {
+      arguments = arguments ?? new List<Tuple<Expression, double>>();
+      arguments.AddRange(expressions.Zip(priorities, Tuple.Create));
+    }
+  }
+
+  public class RandomArityTemplate : ExpressionTemplate {
+    private readonly IRandom arityDistribution;
+
+    public RandomArityTemplate(string label, Func<IEnumerable<double>, double> transform, IRandom arityDistribution) : base(label, transform) {
+      this.arityDistribution = arityDistribution;
+    }
+
+    public override Expression Instantiate(IRandom random) {
+      var arity = (int)Math.Round(arityDistribution.NextDouble());
+      var args = arguments.SampleProportional(random, arity, arguments.Select(x => x.Item2)).Select(x => x.Item1);
+      return Expression.Function(label, transform, args);
+    }
+  }
+
+  public class FixedArityTemplate : ExpressionTemplate {
+    private readonly int arity;
+    public FixedArityTemplate(string label, Func<IEnumerable<double>, double> transform, int arity) : base(label, transform) {
+      this.arity = arity;
+    }
+
+    public override Expression Instantiate(IRandom random) {
+      var args = arguments.SampleProportional(random, arity, arguments.Select(x => x.Item2)).Select(x => x.Item1);
+      return Expression.Function(label, transform, args);
+    }
+  }
+}
Index: /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/HeuristicLab.ExpressionGenerator.csproj
===================================================================
--- /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/HeuristicLab.ExpressionGenerator.csproj	(revision 14409)
+++ /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/HeuristicLab.ExpressionGenerator.csproj	(revision 14409)
@@ -0,0 +1,94 @@
+﻿<?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>
+  </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="Expression.cs" />
+    <Compile Include="ExpressionEvaluator.cs" />
+    <Compile Include="ExpressionTemplate.cs" />
+    <Compile Include="Interfaces\IExpression.cs" />
+    <Compile Include="Plugin.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+set ProjectDir=$(ProjectDir)
+set SolutionDir=$(SolutionDir)
+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/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Interfaces/IExpression.cs
===================================================================
--- /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Interfaces/IExpression.cs	(revision 14409)
+++ /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Interfaces/IExpression.cs	(revision 14409)
@@ -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; }
+    IEnumerable<Expression> Arguments { get; }
+    double Value { get; }
+    IRandom Distribution { get; }
+    Func<IEnumerable<double>, double> Transform { get; }
+  }
+}
Index: /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Plugin.cs.frame
===================================================================
--- /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Plugin.cs.frame	(revision 14409)
+++ /branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Plugin.cs.frame	(revision 14409)
@@ -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/HeuristicLab.ExpressionGenerator/PreBuildEvent.cmd
===================================================================
--- /branches/HeuristicLab.ExpressionGenerator/PreBuildEvent.cmd	(revision 14409)
+++ /branches/HeuristicLab.ExpressionGenerator/PreBuildEvent.cmd	(revision 14409)
@@ -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
