Index: branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs
===================================================================
--- branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs	(revision 14872)
+++ branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs	(revision 14873)
@@ -42,9 +42,9 @@
     }
 
-    public IRandom Distribution { get; private set; }
-
-    public Func<IEnumerable<double>, double> Transform { get; private set; }
-
-    public double Value { get; private set; }
+    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) {
@@ -85,5 +85,5 @@
       switch (Type) {
         case ExpressionType.Constant:
-          sb.Append(Value.ToString("0.000", CultureInfo.CurrentCulture));
+          sb.Append(Value.ToString("0.000", CultureInfo.InvariantCulture));
           break;
         case ExpressionType.RandomVariable:
@@ -108,6 +108,6 @@
         case ExpressionType.Constant:
           sb.Append(Value < 0
-              ? string.Format("(- {0})", Math.Abs(Value).ToString("0.000", CultureInfo.CurrentCulture))
-              : Value.ToString("0.000", CultureInfo.CurrentCulture));
+              ? string.Format("(- {0})", Math.Abs(Value).ToString("0.000", CultureInfo.InvariantCulture))
+              : Value.ToString("0.000", CultureInfo.InvariantCulture));
           break;
         case ExpressionType.RandomVariable:
Index: branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionEvaluator.cs
===================================================================
--- branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionEvaluator.cs	(revision 14872)
+++ branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionEvaluator.cs	(revision 14873)
@@ -57,8 +57,11 @@
 
     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();
-        Evaluate(expression);
+        foreach(var expr in expressions) Evaluate(expr);
         foreach (var pair in evaluationCache) {
           if (!data.ContainsKey(pair.Key))
Index: branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionGenerator.cs
===================================================================
--- branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionGenerator.cs	(revision 14872)
+++ branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionGenerator.cs	(revision 14873)
@@ -23,4 +23,6 @@
 using System.Collections.Generic;
 using System.Linq;
+using System.Runtime.InteropServices;
+using HeuristicLab.Common;
 using HeuristicLab.Core;
 using HeuristicLab.Random;
@@ -30,4 +32,34 @@
     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 NonlinearExpression(IRandom uniformRandom, Expression[] variables, bool useLog, bool useExp) {
+      var scalingTemplate = ScaledExpression(uniformRandom, variables, varianceRandom: new UniformDistributedRandom(uniformRandom, 1, 10));
+      var scaledVars = Instantiate(scalingTemplate, uniformRandom, 100, "scaledVar");
+
+      var sumTemplate = new RandomArityTemplate(Sum, new UniformDistributedRandom(uniformRandom, 1, 3)) { Label = "+" };
+      sumTemplate.AddArguments(scaledVars);
+      var prodTemplate = new RandomArityTemplate(Product, new UniformDistributedRandom(uniformRandom, 1, 3)) { Label = "*" };
+      prodTemplate.AddArguments(variables);
+
+      var logTemplate = LogOfScaledExpression(uniformRandom, Instantiate(sumTemplate, uniformRandom, 100, "sumOfScaledVars"),
+        minValue: new UniformDistributedRandom(uniformRandom, 0.1, 2),
+        valueRange: new UniformDistributedRandom(uniformRandom, 1, 10));
+
+      var expTemplate = ExpOfScaledExpression(uniformRandom, Instantiate(prodTemplate, uniformRandom, 100, "prodOfVars"),
+        valueRange: new UniformDistributedRandom(uniformRandom, 1, 4)); // TODO should also specify an offset
+
+      var scaledExprTemplate = new ScalingTemplate(new UniformDistributedRandom(uniformRandom, 1, 10)) { Label = "*" };
+      if (useLog) scaledExprTemplate.AddArguments(Instantiate(logTemplate, uniformRandom, 100, "log"));
+      if (useExp) scaledExprTemplate.AddArguments(Instantiate(expTemplate, uniformRandom, 100, "exp"));
+
+      var mainTemplate = new RandomArityTemplate(Sum, new UniformDistributedRandom(uniformRandom, 3, 5));
+      mainTemplate.AddArguments(scaledVars);
+      if (useLog || useExp) {
+        mainTemplate.AddArguments(Instantiate(scaledExprTemplate, uniformRandom, 100, "scaledExpr"));
+      }
+      mainTemplate.Label = "+";
+
+      return mainTemplate.Instantiate("main", uniformRandom, false);
     }
 
@@ -70,14 +102,48 @@
     }
 
+    // variance random must have support only positive numbers
+    private static ExpressionTemplate ScaledExpression(IRandom uniformRandom, IEnumerable<Expression> arguments, IRandom varianceRandom) {
+      var scalingTemplate = new ScalingTemplate(scaledVariance: varianceRandom);
+      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,
+      IRandom minValue = null, IRandom valueRange = null) {
+      var limitToRangeTemplate = new RangeTemplate(minValue, valueRange);
+      limitToRangeTemplate.AddArguments(arguments);
+
+      var logTemplate = new FixedArityTemplate(Log, 1) { Label = "log" };
+      logTemplate.AddArguments(Enumerable.Range(1, 100).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,
+      IRandom valueRange = null) {
+      var limitToRangeTemplate = new RangeTemplate(null, valueRange);
+      limitToRangeTemplate.AddArguments(arguments);
+
+      var expTemplate = new FixedArityTemplate(Exp, 1) { Label = "exp" };
+      expTemplate.AddArguments(Enumerable.Range(1, 100).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
-    private static double Sum(IEnumerable<double> args) {
+    public static double Sum(IEnumerable<double> args) {
       return args.Sum();
     }
 
-    private static double Product(IEnumerable<double> args) {
+    public static double Product(IEnumerable<double> args) {
       return args.Aggregate((x, y) => x * y);
     }
 
-    private static double Division(IEnumerable<double> args) {
+    public static double Division(IEnumerable<double> args) {
       if (args.Count() == 1)
         return 1 / args.First();
@@ -86,5 +152,5 @@
     }
 
-    private static double Subtraction(IEnumerable<double> args) {
+    public static double Subtraction(IEnumerable<double> args) {
       if (args.Count() == 1)
         return -args.First();
@@ -93,13 +159,13 @@
     }
 
-    private static double Exp(IEnumerable<double> args) {
+    public static double Exp(IEnumerable<double> args) {
       return Math.Exp(args.Single());
     }
 
-    private static double Log(IEnumerable<double> args) {
+    public static double Log(IEnumerable<double> args) {
       return Math.Log(args.Single());
     }
 
-    private static double Square(IEnumerable<double> args) {
+    public static double Square(IEnumerable<double> args) {
       var v = args.Single();
       return v * v;
Index: branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs
===================================================================
--- branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs	(revision 14872)
+++ branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs	(revision 14873)
@@ -23,4 +23,5 @@
 using System.Collections.Generic;
 using System.Linq;
+using HeuristicLab.Common;
 using HeuristicLab.Core;
 using HeuristicLab.Random;
@@ -28,16 +29,20 @@
 namespace HeuristicLab.ExpressionGenerator {
   public abstract class ExpressionTemplate {
-    private List<Tuple<Expression, double>> arguments;
-    private readonly Func<IEnumerable<double>, double> transform;
+    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).Select(x => x.Item1)
        : arguments.SampleProportionalWithoutRepetition(random, n, weights).Select(x => x.Item1);
-      var func = Expression.Function(name, transform, args);
-      func.Label = Label;
-      return func;
+      return args;
     }
 
@@ -58,5 +63,5 @@
     }
 
-    public void AddArguments(IEnumerable<Expression> expressions, IEnumerable<double> weights) { 
+    public void AddArguments(IEnumerable<Expression> expressions, IEnumerable<double> weights) {
       arguments = arguments ?? new List<Tuple<Expression, double>>();
       arguments.AddRange(expressions.Zip(weights, Tuple.Create));
@@ -87,3 +92,96 @@
     }
   }
+
+  public class ScalingTemplate : ExpressionTemplate {
+    private readonly IRandom scaledVariance;
+    // w * expr
+    public ScalingTemplate(IRandom 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.NextDouble() / variance;
+      }
+
+      var func = Expression.Function(name, transform, new Expression[] { Expression.Constant(name, @const), expr });
+      func.Label = "*";
+      return func;
+    }
+  }
+
+  public class OffsetTemplate : ExpressionTemplate {
+    private readonly IRandom offset;
+    // expr + offset
+    public OffsetTemplate(IRandom 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.NextDouble() - average;
+      }
+
+      var func = Expression.Function(name, transform, new Expression[] { Expression.Constant(name, @const), expr });
+      func.Label = "+";
+      return func;
+    }
+  }
+
+  public class RangeTemplate : ExpressionTemplate {
+    private readonly IRandom minValue;
+    private readonly IRandom valueRange;
+    // expr + offset
+    public RangeTemplate(IRandom minValue = null, IRandom 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.NextDouble();
+          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.NextDouble();
+          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/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/HeuristicLab.ExpressionGenerator.csproj
===================================================================
--- branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/HeuristicLab.ExpressionGenerator.csproj	(revision 14872)
+++ branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/HeuristicLab.ExpressionGenerator.csproj	(revision 14873)
@@ -77,4 +77,5 @@
     <Compile Include="ExpressionTemplate.cs" />
     <Compile Include="Interfaces\IExpression.cs" />
+    <Compile Include="PointDistribution.cs" />
     <Compile Include="Plugin.cs" />
   </ItemGroup>
Index: branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/PointDistribution.cs
===================================================================
--- branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/PointDistribution.cs	(revision 14873)
+++ branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/PointDistribution.cs	(revision 14873)
@@ -0,0 +1,65 @@
+﻿#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 System;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.ExpressionGenerator {
+
+  public class PointDistribution : Item, IRandom {
+    private double value;
+    public PointDistribution() : base() { }
+
+    public PointDistribution(PointDistribution original, Cloner cloner) : base(original, cloner) {
+      value = original.value;
+    }
+
+    public PointDistribution(double value) {
+      this.value = value;
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new PointDistribution(this, cloner);
+    }
+
+    public void Reset() {
+    }
+
+    public void Reset(int seed) {
+    }
+
+    public int Next() {
+      throw new NotSupportedException();
+    }
+
+    public int Next(int maxVal) {
+      throw new NotSupportedException();
+    }
+
+    public int Next(int minVal, int maxVal) {
+      throw new NotSupportedException();
+    }
+
+    public double NextDouble() {
+      return value;
+    }
+  }
+}
