Index: trunk/sources/HeuristicLab.Optimization/3.3/Calculator.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization/3.3/Calculator.cs	(revision 6663)
+++ trunk/sources/HeuristicLab.Optimization/3.3/Calculator.cs	(revision 6663)
@@ -0,0 +1,106 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text.RegularExpressions;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System.Globalization;
+
+namespace HeuristicLab.Optimization {  
+    
+  [StorableClass]
+  public class Calculator : IDeepCloneable {
+
+    #region Fields & Properties
+    
+    private List<string> tokens;
+
+    [Storable]
+    public string Formula {
+      get { return string.Join(" ", tokens); }
+      set { tokens = Tokenize(value).ToList(); }
+    }
+
+    private static readonly Regex TokenRegex = new Regex(@"[a-zA-Z0-9._]+|""([^""]|\"")+""|[-+*/^]|log");    
+
+    #endregion
+
+    #region Construction & Cloning
+
+    [StorableConstructor]
+    protected Calculator(bool deserializing) { }
+    public Calculator() { }
+    public Calculator(Calculator original, Cloner cloner) {
+      this.tokens = original.tokens.ToList();
+    }
+    public IDeepCloneable Clone(Cloner cloner) {
+      return new Calculator(this, cloner);
+    }
+    public object Clone() {
+      return Clone(new Cloner());
+    }
+    #endregion
+
+    public IEnumerable<string> Tokenize(string s) {
+      return TokenRegex.Matches(s).Cast<Match>().Select(m => m.Value);
+    }
+
+    private double GetVariableValue(IDictionary<string, IItem> variables, string name) {
+      if (variables.ContainsKey(name)) {
+        var item = variables[name];
+        var intValue = item as IntValue;
+        if (intValue != null) {
+          return intValue.Value;
+        } else {
+          var doubleValue = item as DoubleValue;
+          if (doubleValue != null)
+            return doubleValue.Value;
+          else
+            throw new InvalidOperationException("Non numerical argument");
+        }
+      } else {
+        throw new InvalidOperationException(string.Format("variable \"{0}\" not found", name));
+      }
+    }
+
+    public IItem GetValue(IDictionary<string, IItem> variables) {
+      var stack = new Stack<double>();
+      Action<Func<double, double, double>> binf = op => {
+        var b = stack.Pop();
+        stack.Push(op(stack.Pop(), b));
+      };
+      try {
+        foreach (var token in tokens) {
+          double d;
+          if (double.TryParse(token,
+                NumberStyles.AllowDecimalPoint |
+              NumberStyles.AllowExponent |
+              NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out d)) {
+            stack.Push(d);
+          } else if (token.StartsWith("\"")) {
+            stack.Push(GetVariableValue(variables, token.Substring(1, token.Length - 2).Replace(@"\""", @"""")));
+          } else {
+            switch (token) {
+              case "log": stack.Push(Math.Log(stack.Pop())); break;
+              case "+": binf((x, y) => x + y); break;
+              case "-": binf((x, y) => x - y); break;
+              case "*": binf((x, y) => x * y); break;
+              case "/": binf((x, y) => x / y); break;
+              case "^": binf(Math.Pow); break;
+              default: stack.Push(GetVariableValue(variables, token)); break;
+            }
+          }
+        }
+      } catch (InvalidOperationException x) {
+        return new StringValue(string.Format("Calculation Failed: {0}", x.Message));
+      }
+      if (stack.Count != 1)
+        return new StringValue("Invalid final evaluation stack size != 1");
+      return new DoubleValue(stack.Pop());      
+    }    
+  }
+}
Index: trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj	(revision 6662)
+++ trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj	(revision 6663)
@@ -111,7 +111,9 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="IRunCollectionModifier.cs" />
     <None Include="HeuristicLabOptimizationPlugin.cs.frame" />
     <Compile Include="Algorithms\Algorithm.cs" />
     <Compile Include="BatchRun.cs" />
+    <Compile Include="Calculator.cs" />
     <Compile Include="Interfaces\IDiscreteDoubleMatrixModifier.cs" />
     <Compile Include="Algorithms\HeuristicOptimizationEngineAlgorithm.cs" />
@@ -136,4 +138,7 @@
     <Compile Include="Interfaces\ISingleObjectiveHeuristicOptimizationProblem.cs" />
     <Compile Include="Problems\Problem.cs" />
+    <Compile Include="RunCollectionFormulaModifer.cs" />
+    <Compile Include="RunCollectionFuzzifier.cs" />
+    <Compile Include="RunCollectionModificationEvaluator.cs" />
     <Compile Include="RunCollectionConstraints\RunCollectionComparisonConstraint.cs" />
     <Compile Include="RunCollectionConstraints\RunCollectionConstraintCollection.cs" />
@@ -244,4 +249,35 @@
     </BootstrapperPackage>
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="bin\x86\Debug\HeuristicLab.Collections-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Collections-3.3.pdb" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Common-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Common-3.3.pdb" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Common.Resources-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Common.Resources-3.3.pdb" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Core-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Core-3.3.pdb" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Data-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Data-3.3.pdb" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Optimization-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Optimization-3.3.pdb" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Parameters-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Parameters-3.3.pdb" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Persistence-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Persistence-3.3.pdb" />
+    <Content Include="bin\x86\Debug\HeuristicLab.PluginInfrastructure-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.PluginInfrastructure-3.3.pdb" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Tracing-3.3.dll" />
+    <Content Include="bin\x86\Debug\HeuristicLab.Tracing-3.3.pdb" />
+    <Content Include="bin\x86\Debug\ICSharpCode.SharpZipLib License.txt" />
+    <Content Include="bin\x86\Debug\ICSharpCode.SharpZipLib.dll" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="bin\Debug\" />
+    <Folder Include="bin\Release\" />
+    <Folder Include="bin\x64\Debug\" />
+    <Folder Include="bin\x64\Release\" />
+    <Folder Include="bin\x86\Release\" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
Index: trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionFormulaModifer.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionFormulaModifer.cs	(revision 6663)
+++ trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionFormulaModifer.cs	(revision 6663)
@@ -0,0 +1,76 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Optimization {
+
+  [Item("RunCollection Formula Modifier", "Modifies a RunCollection by adding results using the given formula.")]
+  [StorableClass]
+  public class RunCollectionFormulaModifer : ParameterizedNamedItem, IRunCollectionModifier {
+
+    public override bool CanChangeName { get { return false; } }
+    public override bool CanChangeDescription { get { return false; } }
+
+    public ValueParameter<StringValue> ResultNameParameter {
+      get { return (ValueParameter<StringValue>)Parameters["ResultName"]; }
+    }    
+    
+    public ValueParameter<StringValue> FormulaParameter {
+      get { return (ValueParameter<StringValue>)Parameters["Formula"]; }
+    }    
+
+    #region Construction & Cloning    
+    [StorableConstructor]
+    protected RunCollectionFormulaModifer(bool deserializing) : base(deserializing) { }
+    protected RunCollectionFormulaModifer(RunCollectionFormulaModifer original, Cloner cloner)
+      : base(original, cloner) {
+    }
+    public RunCollectionFormulaModifer() {
+      Parameters.Add(new ValueParameter<StringValue>("ResultName", "The name of the result to be generated by this formula.", new StringValue("Calc.Value")));
+      Parameters.Add(new ValueParameter<StringValue>("Formula", "RPN formula for new value. This can contain existing run parameters or results (optionally in quotes if they contain whitespace), numbers and arithmetic operators in postfix notation.", new StringValue("1 1 +")));
+      UpdateName();
+      RegisterEvents();
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RunCollectionFormulaModifer(this, cloner);
+    }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      RegisterEvents();
+    }
+    #endregion
+
+    private void RegisterEvents() {
+      ResultNameParameter.ToStringChanged += Parameter_NameChanged;
+      FormulaParameter.ToStringChanged += Parameter_NameChanged;
+    }
+
+    void Parameter_NameChanged(object sender, EventArgs e) {
+      UpdateName();
+    }
+
+    private void UpdateName() {
+      name = string.Format("{0} := {1}", ResultNameParameter.Value.Value, FormulaParameter.Value.Value);
+      OnNameChanged();
+    }
+
+    public void Modify(List<IRun> runs) {
+      var calc = new Calculator {Formula = FormulaParameter.Value.Value};      
+      foreach (var run in runs) {
+        var variables = new Dictionary<string, IItem>();
+        foreach (var param in run.Parameters)
+          variables[param.Key] = param.Value;
+        foreach (var result in run.Results)
+          variables[result.Key] = result.Value;
+        run.Results[ResultNameParameter.Value.Value] = calc.GetValue(variables);        
+      }      
+    }
+    
+  }
+}
Index: trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionFuzzifier.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionFuzzifier.cs	(revision 6663)
+++ trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionFuzzifier.cs	(revision 6663)
@@ -0,0 +1,141 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Optimization {
+  [Item("RunCollection Fuzzifier", "Creates several levels from the distribution of a certain result accross a run collection and assignes a fuzzified value.")]
+  [StorableClass]
+  public class RunCollectionFuzzifier : ParameterizedNamedItem, IRunCollectionModifier {
+
+    #region Parameters
+    public ValueParameter<StringValue> SourceParameter {
+      get { return (ValueParameter<StringValue>)Parameters["Source"]; }
+    }
+    public ValueParameter<StringValue> TargetParameter {
+      get { return (ValueParameter<StringValue>)Parameters["Target"]; }
+    }
+    public ValueParameter<StringValue> SuffixParameter {
+      get { return (ValueParameter<StringValue>)Parameters["Suffix"]; }
+    }
+    public ValueParameter<DoubleValue> SpreadParameter {
+      get { return (ValueParameter<DoubleValue>)Parameters["Spread"]; }
+    }
+    public ValueParameter<ItemList<StringValue>> LevelsParameter {
+      get { return (ValueParameter<ItemList<StringValue>>)Parameters["Levels"]; }
+    }
+    #endregion
+
+    private string Source { get { return SourceParameter.Value.Value; } }
+    private string Target { get { return TargetParameter.Value.Value; } }
+    private string Suffix { get { return SuffixParameter.Value.Value; } }
+    private double Spread { get { return SpreadParameter.Value.Value; } }
+    private List<string> Levels { get { return LevelsParameter.Value.Select(v => v.Value).ToList(); } }
+
+      #region Construction & Cloning
+    [StorableConstructor]
+    protected RunCollectionFuzzifier(bool deserializing) : base(deserializing) { }
+    protected RunCollectionFuzzifier(RunCollectionFuzzifier original, Cloner cloner)
+      : base(original, cloner) {
+    }
+    public RunCollectionFuzzifier() {
+      Parameters.Add(new ValueParameter<StringValue>("Source", "Source value name to be fuzzified.", new StringValue("Value")));
+      Parameters.Add(new ValueParameter<StringValue>("Target", "Target value name. The new, fuzzified variable to be created.", new StringValue("Calc.Value")));
+      Parameters.Add(new ValueParameter<StringValue>("Suffix", "The suffix of all fuzzified values.", new StringValue()));
+      Parameters.Add(new ValueParameter<DoubleValue>("Spread", "The number of standard deviations considered one additional level.", new DoubleValue(1)));
+      Parameters.Add(new ValueParameter<ItemList<StringValue>>("Levels", "The list of levels to be assigned.",
+        new ItemList<StringValue> {
+          new StringValue("Very Low"),
+          new StringValue("Low"),
+          new StringValue("Average"),
+          new StringValue("High"),
+          new StringValue("Very High"),
+        }));
+      RegisterEvents();
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new RunCollectionFuzzifier(this, cloner);
+    }
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      RegisterEvents();
+    }
+    #endregion
+
+    private void RegisterEvents() {
+      SourceParameter.ToStringChanged += Parameter_NameChanged;
+      TargetParameter.ToStringChanged += Parameter_NameChanged;
+      SuffixParameter.ToStringChanged += Parameter_NameChanged;
+    }
+
+    private void Parameter_NameChanged(object sender, EventArgs e) {
+      UpdateName();
+    }
+
+    private void UpdateName() {
+      name = string.Format("{0} := Fuzzy({1}) {2}", Target,Source, Suffix);
+      OnNameChanged();
+    }
+
+    #region IRunCollectionModifier Members
+
+    public void Modify(List<IRun> runs) {
+      var values =
+        (from run in runs
+         select GetSourceValue(run) into value
+         where value.HasValue
+         select value.Value).ToList();
+      if (values.Count == 0)
+        return;
+      var avg = values.Average();
+      var stdDev = values.StandardDeviation();
+      foreach (var run in runs) {
+        double? value = GetSourceValue(run);
+        if (value.HasValue) {
+          run.Results[Target] = new StringValue(Fuzzify(value.Value, avg, stdDev));
+        }
+      }      
+    }
+
+    private double? GetSourceValue(IRun run) {
+      return CastSourceValue(run.Results) ?? CastSourceValue(run.Parameters);
+    }
+
+    private double? CastSourceValue(IDictionary<string, IItem> variables) {
+      IItem value;
+      variables.TryGetValue(Source, out value);
+      var intValue = value as IntValue;
+      if (intValue != null) {
+        return intValue.Value;
+      } else {
+        var doubleValue = value as DoubleValue;
+        if (doubleValue != null)
+          return doubleValue.Value;
+      }
+      return null;
+    }
+
+    private string Fuzzify(double value, double avg, double stdDev) {
+      double dev = (value - avg)/(stdDev*Spread);
+      int index;
+      if (Levels.Count % 2 == 1) {
+        index = (int) Math.Floor(Math.Abs(dev));        
+        index = (Levels.Count - 1)/2 + Math.Sign(dev) * index;        
+      } else {
+        index = (int) Math.Ceiling(Math.Abs(dev));
+        if (dev > 0)
+          index = Levels.Count/2 + index;
+        else
+          index = Levels.Count/2 + 1 - index;        
+      }            
+      return Levels[Math.Min(Levels.Count - 1, Math.Max(0, index))];
+    }
+
+    #endregion
+  }
+}
