Index: branches/ALPS/HeuristicLab.Tests/AssemblyInitializer.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/AssemblyInitializer.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/AssemblyInitializer.cs	(revision 11677)
@@ -0,0 +1,21 @@
+﻿using System.IO;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  [TestClass]
+  public static class AssemblyInitializer {
+    private static string SamplesDirectory = SamplesUtils.SamplesDirectory;
+    private static string ScriptsDirectory = ScriptingUtils.ScriptsDirectory;
+
+    [AssemblyInitialize]
+    public static void AssemblyInitialize(TestContext testContext) {
+      // load all assemblies
+      PluginLoader.Assemblies.Any();
+
+      // create output directories for samples and scripts
+      if (!Directory.Exists(SamplesDirectory)) Directory.CreateDirectory(SamplesDirectory);
+      if (!Directory.Exists(ScriptsDirectory)) Directory.CreateDirectory(ScriptsDirectory);
+    }
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/CloningConstructorTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/CloningConstructorTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/CloningConstructorTest.cs	(revision 11677)
@@ -21,5 +21,4 @@
 
 using System;
-using System.Linq;
 using System.Reflection;
 using System.Text;
@@ -31,10 +30,4 @@
   [TestClass]
   public class CloningConstructorTest {
-    // Use ClassInitialize to run code before running the first test in the class
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
-    }
-
     [TestMethod]
     [TestCategory("General")]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ContentViewTests.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ContentViewTests.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ContentViewTests.cs	(revision 11677)
@@ -31,14 +31,4 @@
   [TestClass]
   public class ContentViewTests {
-    public ContentViewTests() {
-    }
-
-    // Use ClassInitialize to run code before running the first test in the class
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
-    }
-
-
     [TestMethod]
     [TestCategory("General")]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/DeepCloneableCloningTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/DeepCloneableCloningTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/DeepCloneableCloningTest.cs	(revision 11677)
@@ -32,15 +32,6 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for DeepCloneableCloningTest
-  /// </summary>
   [TestClass]
   public class DeepCloneableCloningTest {
-
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
-    }
-
     private TestContext testContextInstance;
     public TestContext TestContext {
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/InstantiateCreatablesTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/InstantiateCreatablesTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/InstantiateCreatablesTest.cs	(revision 11677)
@@ -31,9 +31,4 @@
   [TestClass]
   public class InstantiateCreatablesTest {
-    // Use ClassInitialize to run code before running the first test in the class
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
-    }
     [TestMethod]
     [TestCategory("General")]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/NamedItemTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/NamedItemTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/NamedItemTest.cs	(revision 11677)
@@ -1,4 +1,3 @@
-﻿using System.Linq;
-using System.Text;
+﻿using System.Text;
 using HeuristicLab.Common;
 using HeuristicLab.Core;
@@ -9,9 +8,4 @@
   [TestClass]
   public class NamedItemTest {
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
-    }
-
     [TestMethod]
     [TestCategory("General")]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ParameterVisibilityTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ParameterVisibilityTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ParameterVisibilityTest.cs	(revision 11677)
@@ -31,10 +31,4 @@
   [TestClass]
   public class ParameterVisibilityTest {
-    // Use ClassInitialize to run code before running the first test in the class
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
-    }
-
     private TestContext testContextInstance;
     public TestContext TestContext {
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/EsGriewankSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/EsGriewankSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/EsGriewankSampleTest.cs	(revision 11677)
@@ -29,16 +29,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for EsGriewankSampleTest
-  /// </summary>
   [TestClass]
   public class EsGriewankSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "ES_Griewank";
 
     [TestMethod]
@@ -47,5 +38,6 @@
     public void CreateEsGriewankSampleTest() {
       var es = CreateEsGriewankSample();
-      XmlGenerator.Serialize(es, @"Samples\ES_Griewank.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(es, path);
     }
 
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GATspSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GATspSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GATspSampleTest.cs	(revision 11677)
@@ -33,11 +33,5 @@
   [TestClass]
   public class GATspSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
-
+    private const string SampleFileName = "GA_TSP";
 
     [TestMethod]
@@ -46,6 +40,8 @@
     public void CreateGaTspSampleTest() {
       var ga = CreateGaTspSample();
-      XmlGenerator.Serialize(ga, @"Samples\GA_TSP.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ga, path);
     }
+
     [TestMethod]
     [TestCategory("Samples.Execute")]
@@ -63,4 +59,5 @@
     private GeneticAlgorithm CreateGaTspSample() {
       GeneticAlgorithm ga = new GeneticAlgorithm();
+
       #region Problem Configuration
       var provider = new TSPLIBTSPInstanceProvider();
@@ -77,4 +74,5 @@
         ga, 100, 1, 1000, 0.05);
       #endregion
+
       return ga;
     }
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GAVrpSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GAVrpSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GAVrpSampleTest.cs	(revision 11677)
@@ -34,16 +34,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for GAVrpSampleTest
-  /// </summary>
   [TestClass]
   public class GAVrpSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
-
+    private const string SampleFileName = "GA_VRP";
 
     [TestMethod]
@@ -52,5 +43,6 @@
     public void CreateGaVrpSampleTest() {
       var ga = CreateGaVrpSample();
-      XmlGenerator.Serialize(ga, @"Samples\GA_VRP.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ga, path);
     }
 
@@ -70,4 +62,5 @@
     private GeneticAlgorithm CreateGaVrpSample() {
       GeneticAlgorithm ga = new GeneticAlgorithm();
+
       #region Problem Configuration
       VehicleRoutingProblem vrpProblem = new VehicleRoutingProblem();
@@ -117,4 +110,5 @@
         .Single(), true);
       #endregion
+
       return ga;
     }
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPArtificialAntSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPArtificialAntSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPArtificialAntSampleTest.cs	(revision 11677)
@@ -30,15 +30,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for GPArtificialAntSampleTest
-  /// </summary>
   [TestClass]
   public class GPArtificialAntSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "SGP_SantaFe";
 
     [TestMethod]
@@ -47,5 +39,6 @@
     public void CreateGpArtificialAntSampleTest() {
       var ga = CreateGpArtificialAntSample();
-      XmlGenerator.Serialize(ga, @"Samples\SGP_SantaFe.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ga, path);
     }
 
@@ -65,4 +58,5 @@
     public GeneticAlgorithm CreateGpArtificialAntSample() {
       GeneticAlgorithm ga = new GeneticAlgorithm();
+
       #region Problem Configuration
       ArtificialAntProblem antProblem = new ArtificialAntProblem();
@@ -94,4 +88,5 @@
         .Single(), false);
       #endregion
+
       return ga;
     }
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPLawnMowerSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPLawnMowerSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPLawnMowerSampleTest.cs	(revision 11677)
@@ -20,5 +20,4 @@
 #endregion
 
-using System.IO;
 using System.Linq;
 using HeuristicLab.Algorithms.GeneticAlgorithm;
@@ -28,16 +27,6 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for GPLawnMowerSampleTest
-  /// </summary>
   [TestClass]
   public class GPLawnMowerSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
-
     [TestMethod]
     [TestCategory("Samples.Execute")]
@@ -57,5 +46,4 @@
 
       #endregion
-
       #region Algorithm Configuration
 
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPMultiplexerSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPMultiplexerSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPMultiplexerSampleTest.cs	(revision 11677)
@@ -33,10 +33,5 @@
   [TestClass]
   public class GPMultiplexerSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "GP_Multiplexer";
 
     [TestMethod]
@@ -45,5 +40,5 @@
     public void CreateGpMultiplexerSampleTest() {
       var ga = CreateGpMultiplexerSample();
-      var path = Path.Combine(samplesDirectory, "GP_Multiplexer.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
       XmlGenerator.Serialize(ga, path);
     }
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicClassificationSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicClassificationSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicClassificationSampleTest.cs	(revision 11677)
@@ -33,15 +33,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for GPSymbolicClassificationSampleTest
-  /// </summary>
   [TestClass]
   public class GPSymbolicClassificationSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "SGP_SymbClass";
 
     [TestMethod]
@@ -50,5 +42,6 @@
     public void CreateGpSymbolicClassificationSampleTest() {
       var ga = CreateGpSymbolicClassificationSample();
-      XmlGenerator.Serialize(ga, @"Samples\SGP_SymbClass.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ga, path);
     }
 
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicRegressionSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicRegressionSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPSymbolicRegressionSampleTest.cs	(revision 11677)
@@ -33,16 +33,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for GPSymbolicRegressionSampleTest
-  /// </summary>
   [TestClass]
   public class GPSymbolicRegressionSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
-
+    private const string SampleFileName = "SGP_SymbReg";
 
     [TestMethod]
@@ -51,5 +42,6 @@
     public void CreateGpSymbolicRegressionSampleTest() {
       var ga = CreateGpSymbolicRegressionSample();
-      XmlGenerator.Serialize(ga, @"Samples\SGP_SymbReg.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ga, path);
     }
     [TestMethod]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPTimeSeriesSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPTimeSeriesSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GPTimeSeriesSampleTest.cs	(revision 11677)
@@ -32,10 +32,5 @@
   [TestClass]
   public class GPTimeSeriesSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "OSGP_TimeSeries";
 
     [TestMethod]
@@ -44,5 +39,5 @@
     public void CreateGpTimeSeriesSampleTest() {
       var ga = CreateGpTimeSeriesSample();
-      var path = Path.Combine(samplesDirectory, "OSGP_TimeSeries.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
       XmlGenerator.Serialize(ga, path);
     }
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GaussianProcessRegressionSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GaussianProcessRegressionSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GaussianProcessRegressionSampleTest.cs	(revision 11677)
@@ -29,15 +29,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for GaussianProcessRegressionSampleTest
-  /// </summary>
   [TestClass]
   public class GaussianProcessRegressionSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "GPR";
 
     [TestMethod]
@@ -46,6 +38,8 @@
     public void CreateGaussianProcessRegressionSampleTest() {
       var gpr = CreateGaussianProcessRegressionSample();
-      XmlGenerator.Serialize(gpr, @"Samples\GPR.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(gpr, path);
     }
+
     [TestMethod]
     [TestCategory("Samples.Execute")]
@@ -66,4 +60,5 @@
       var regProblem = new RegressionProblem();
       regProblem.Load(provider.LoadData(instance));
+
       #region Algorithm Configuration
       gpr.Name = "Gaussian Process Regression";
@@ -77,4 +72,5 @@
       gpr.SetSeedRandomly = true;
       #endregion
+
       gpr.Engine = new ParallelEngine.ParallelEngine();
       return gpr;
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GeSymbolicRegressionSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GeSymbolicRegressionSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GeSymbolicRegressionSampleTest.cs	(revision 11677)
@@ -30,17 +30,9 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for GeSymbolicRegressionSampleTest
-  /// </summary>
   [TestClass]
   public class GeSymbolicRegressionSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    #region artificial ant
+    private const string GeArtificialAntSampleFileName = "GE_ArtificialAnt";
 
-    #region artificial ant
     [TestMethod]
     [TestCategory("Samples.Create")]
@@ -48,5 +40,6 @@
     public void CreateGeArtificialAntSampleTest() {
       var geaa = CreateGeArtificialAntSample();
-      XmlGenerator.Serialize(geaa, @"Samples\GE_ArtificialAnt.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, GeArtificialAntSampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(geaa, path);
     }
 
@@ -62,4 +55,5 @@
     public OffspringSelectionGeneticAlgorithm CreateGeArtificialAntSample() {
       OffspringSelectionGeneticAlgorithm ga = new OffspringSelectionGeneticAlgorithm();
+
       #region Problem Configuration
       var problem = new HeuristicLab.Problems.GrammaticalEvolution.GEArtificialAntProblem();
@@ -72,4 +66,5 @@
         ga, 200, 1, 50, 0.05, 200);
       #endregion
+
       return ga;
     }
@@ -77,5 +72,6 @@
 
     #region symbolic regression
-    #endregion
+    private const string GeSymbolicRegressionSampleFileName = "GE_SymbReg";
+
     [TestMethod]
     [TestCategory("Samples.Create")]
@@ -83,5 +79,6 @@
     public void CreateGeSymbolicRegressionSampleTest() {
       var geSymbReg = CreateGeSymbolicRegressionSample();
-      XmlGenerator.Serialize(geSymbReg, @"Samples\GE_SymbReg.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, GeSymbolicRegressionSampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(geSymbReg, path);
     }
 
@@ -97,4 +94,5 @@
     public OffspringSelectionGeneticAlgorithm CreateGeSymbolicRegressionSample() {
       var ga = new OffspringSelectionGeneticAlgorithm();
+
       #region Problem Configuration
       var problem = new HeuristicLab.Problems.GrammaticalEvolution.GESymbolicRegressionSingleObjectiveProblem();
@@ -116,6 +114,8 @@
         ga, 1000, 1, 50, 0.05, 200);
       #endregion
+
       return ga;
     }
+    #endregion
   }
 }
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/IslandGaTspSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/IslandGaTspSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/IslandGaTspSampleTest.cs	(revision 11677)
@@ -34,10 +34,5 @@
   [TestClass]
   public class UnitTest1 {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "IslandGA_TSP";
 
     [TestMethod]
@@ -46,5 +41,6 @@
     public void CreateIslandGaTspSampleTest() {
       var ga = CreateIslandGaTspSample();
-      XmlGenerator.Serialize(ga, @"Samples\IslandGA_TSP.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ga, path);
     }
     [TestMethod]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/LocalSearchKnapsackSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/LocalSearchKnapsackSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/LocalSearchKnapsackSampleTest.cs	(revision 11677)
@@ -30,15 +30,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for LocalSearchKnapsackSampleTest
-  /// </summary>
   [TestClass]
   public class LocalSearchKnapsackSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "LS_Knapsack";
 
     [TestMethod]
@@ -47,5 +39,6 @@
     public void CreateLocalSearchKnapsackSampleTest() {
       var ls = CreateLocalSearchKnapsackSample();
-      XmlGenerator.Serialize(ls, @"Samples\LS_Knapsack.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ls, path);
     }
     [TestMethod]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/PsoSchwefelSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/PsoSchwefelSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/PsoSchwefelSampleTest.cs	(revision 11677)
@@ -32,15 +32,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for PsoSchwefelSampleTest
-  /// </summary>
   [TestClass]
   public class PsoSchwefelSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "PSO_Schwefel";
 
     [TestMethod]
@@ -49,5 +41,6 @@
     public void CreatePsoSchwefelSampleTest() {
       var pso = CreatePsoSchwefelSample();
-      XmlGenerator.Serialize(pso, @"Samples\PSO_Schwefel.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(pso, path);
     }
     [TestMethod]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/RAPGASchedulingSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/RAPGASchedulingSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/RAPGASchedulingSampleTest.cs	(revision 11677)
@@ -29,15 +29,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for RAPGASchedulingSampleTest
-  /// </summary>
   [TestClass]
   public class RAPGASchedulingSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "RAPGA_JSSP";
 
     [TestMethod]
@@ -46,5 +38,6 @@
     public void CreateRAPGASchedulingSampleTest() {
       var ss = CreateRAPGASchedulingSample();
-      XmlGenerator.Serialize(ss, @"Samples\RAPGA_JSSP.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ss, path);
     }
 
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SamplesUtils.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SamplesUtils.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SamplesUtils.cs	(revision 11677)
@@ -12,5 +12,6 @@
 namespace HeuristicLab.Tests {
   public static class SamplesUtils {
-    public const string Directory = @"Samples\";
+    public const string SamplesDirectory = @"Samples\";
+    public const string SampleFileExtension = ".hl";
 
     public static void RunAlgorithm(IAlgorithm a) {
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/ScatterSearchVRPSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/ScatterSearchVRPSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/ScatterSearchVRPSampleTest.cs	(revision 11677)
@@ -29,15 +29,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for ScatterSearchVRPSampleTest
-  /// </summary>
   [TestClass]
   public class ScatterSearchVRPSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "SS_VRP";
 
     [TestMethod]
@@ -46,5 +38,6 @@
     public void CreateScatterSearchVRPSampleTest() {
       var ss = CreateScatterSearchVRPSample();
-      XmlGenerator.Serialize(ss, @"Samples\SS_VRP.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ss, path);
     }
 
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SimulatedAnnealingRastriginSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SimulatedAnnealingRastriginSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SimulatedAnnealingRastriginSampleTest.cs	(revision 11677)
@@ -31,15 +31,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for SimulatedAnnealingRastriginSampleTest
-  /// </summary>
   [TestClass]
   public class SimulatedAnnealingRastriginSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "SA_Rastrigin";
 
     [TestMethod]
@@ -48,5 +40,6 @@
     public void CreateSimulatedAnnealingRastriginSampleTest() {
       var sa = CreateSimulatedAnnealingRastriginSample();
-      XmlGenerator.Serialize(sa, @"Samples\SA_Rastrigin.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(sa, path);
     }
     [TestMethod]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/TabuSearchTspSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/TabuSearchTspSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/TabuSearchTspSampleTest.cs	(revision 11677)
@@ -30,16 +30,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for TabuSearchTspSampleTest
-  /// </summary>
   [TestClass]
   public class TabuSearchTspSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
-
+    private const string SampleFileName = "TS_TSP";
 
     [TestMethod]
@@ -48,5 +39,6 @@
     public void CreateTabuSearchTspSampleTest() {
       var ts = CreateTabuSearchTspSample();
-      XmlGenerator.Serialize(ts, @"Samples\TS_TSP.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(ts, path);
     }
     [TestMethod]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/TabuSearchVRPSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/TabuSearchVRPSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/TabuSearchVRPSampleTest.cs	(revision 11677)
@@ -30,15 +30,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for TabuSearchVRPSampleTest
-  /// </summary>
   [TestClass]
   public class TabuSearchVRPSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "TS_VRP";
 
     [TestMethod]
@@ -47,5 +39,6 @@
     public void CreateTabuSearchVRPSampleTest() {
       var vrp = CreateTabuSearchVrpSample();
-      XmlGenerator.Serialize(vrp, @"Samples\TS_VRP.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(vrp, path);
     }
     [TestMethod]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/VnsTspSampleTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/VnsTspSampleTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/Samples/VnsTspSampleTest.cs	(revision 11677)
@@ -31,15 +31,7 @@
 
 namespace HeuristicLab.Tests {
-  /// <summary>
-  /// Summary description for VnsTspSampleTest
-  /// </summary>
   [TestClass]
   public class VnsTspSampleTest {
-    private const string samplesDirectory = SamplesUtils.Directory;
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      if (!Directory.Exists(samplesDirectory))
-        Directory.CreateDirectory(samplesDirectory);
-    }
+    private const string SampleFileName = "VNS_TSP";
 
     [TestMethod]
@@ -48,5 +40,6 @@
     public void CreateVnsTspSampleTest() {
       var vns = CreateVnsTspSample();
-      XmlGenerator.Serialize(vns, @"Samples\VNS_TSP.hl");
+      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
+      XmlGenerator.Serialize(vns, path);
     }
     [TestMethod]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/StorableConstructorTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/StorableConstructorTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/StorableConstructorTest.cs	(revision 11677)
@@ -33,11 +33,4 @@
   [TestClass]
   public class StorableConstructorTest {
-
-    // Use ClassInitialize to run code before running the first test in the class
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
-    }
-
     [TestMethod]
     [TestCategory("General")]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ThreadSafeLogTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ThreadSafeLogTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ThreadSafeLogTest.cs	(revision 11677)
@@ -28,5 +28,4 @@
   [TestClass]
   public class ThreadSafeLogTest {
-
     [TestMethod]
     [TestCategory("General")]
@@ -43,4 +42,20 @@
       Assert.AreEqual(count, log.Messages.Count());
     }
+
+    [TestMethod]
+    [TestCategory("General")]
+    [TestProperty("Time", "short")]
+    public void ThreadSafeLogCapTest() {
+      int count = 10000;
+      int cap = 500;
+      ThreadSafeLog log = new ThreadSafeLog(cap);
+
+      Parallel.For(0, count, (i) => {
+        log.LogMessage("Message " + i); // write something
+        log.Messages.Count(); // iterate over all messages
+      });
+
+      Assert.AreEqual(cap, log.Messages.Count());
+    }
   }
 }
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ToStringTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ToStringTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab-3.3/ToStringTest.cs	(revision 11677)
@@ -21,5 +21,4 @@
 
 using System;
-using System.Linq;
 using HeuristicLab.Core;
 using HeuristicLab.PluginInfrastructure;
@@ -29,15 +28,8 @@
   [TestClass]
   public class ToStringTest {
-
     private TestContext testContextInstance;
     public TestContext TestContext {
       get { return testContextInstance; }
       set { testContextInstance = value; }
-    }
-
-    // Use ClassInitialize to run code before running the first test in the class
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
     }
 
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.PluginInfraStructure-3.3/TypeExtensionsTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.PluginInfraStructure-3.3/TypeExtensionsTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.PluginInfraStructure-3.3/TypeExtensionsTest.cs	(revision 11677)
@@ -29,7 +29,4 @@
 
 namespace HeuristicLab.PluginInfrastructure.Tests {
-  /// <summary>
-  /// Summary description for TypeDiscoveryTest
-  /// </summary>
   [TestClass]
   public class TypeExtensionsTest {
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Problems.VehicleRouting-3.4/VRPInstancesTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Problems.VehicleRouting-3.4/VRPInstancesTest.cs	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Problems.VehicleRouting-3.4/VRPInstancesTest.cs	(revision 11677)
@@ -25,5 +25,4 @@
 using System.Text;
 using HeuristicLab.Problems.Instances;
-using HeuristicLab.Tests;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 
@@ -31,9 +30,4 @@
   [TestClass]
   public class VRPInstancesTest {
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
-    }
-
     [TestMethod]
     [TestCategory("Problems.VehicleRouting")]
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/GridSearchScriptTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/GridSearchScriptTest.cs	(revision 11507)
+++ 	(revision )
@@ -1,207 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2014 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.CodeDom.Compiler;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Threading;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Optimizer;
-using HeuristicLab.Persistence.Default.Xml;
-using HeuristicLab.Problems.DataAnalysis;
-using HeuristicLab.Scripting;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace HeuristicLab.Tests {
-  [TestClass]
-  public class GridSearchScriptTest {
-    private const string PathPrefix = "HeuristicLab.Optimizer.Documents.";
-    private const string PathSuffix = ".hl";
-    private const string SvmClassificationScriptName = "GridSearch_SVM_Classification";
-    private const string SvmRegressionScriptName = "GridSearch_SVM_Regression";
-    private const string RandomForestRegressionScriptName = "GridSearch_RF_Regression";
-    private const string RandomForestClassificationScriptName = "GridSearch_RF_Classification";
-    private const string SamplesDirectory = SamplesUtils.Directory;
-
-    private readonly ManualResetEvent manualResetEvent = new ManualResetEvent(false);
-
-    [ClassInitialize]
-    public static void MyClassInitialize(TestContext testContext) {
-      PluginLoader.Assemblies.Any();
-      if (!Directory.Exists(SamplesDirectory))
-        Directory.CreateDirectory(SamplesDirectory);
-    }
-
-    [TestMethod]
-    [TestCategory("Scripting")]
-    public void RunRandomForestRegressionScriptTest() {
-      var assembly = new StartPage().GetType().Assembly;
-      const string name = PathPrefix + RandomForestRegressionScriptName + PathSuffix;
-      var script = (CSharpScript)LoadSample(name, assembly);
-
-      try {
-        script.Compile();
-      }
-      catch {
-        if (script.CompileErrors.HasErrors) {
-          ShowCompilationResults(script);
-          throw new Exception("Compilation failed.");
-        } else {
-          Console.WriteLine("Compilation succeeded.");
-        }
-      }
-      finally {
-        script.ScriptExecutionFinished += script_ExecutionFinished;
-        script.Execute();
-        var vs = script.VariableStore;
-        var solution = (IRegressionSolution)vs["demo_bestSolution"];
-        Assert.IsTrue(solution.TrainingRSquared.IsAlmost(1));
-      }
-    }
-
-    [TestMethod]
-    [TestCategory("Scripting")]
-    public void RunRandomForestClassificationScriptTest() {
-      var assembly = new StartPage().GetType().Assembly;
-      const string name = PathPrefix + RandomForestClassificationScriptName + PathSuffix;
-      var script = (CSharpScript)LoadSample(name, assembly);
-
-      try {
-        script.Compile();
-      }
-      catch {
-        if (script.CompileErrors.HasErrors) {
-          ShowCompilationResults(script);
-          throw new Exception("Compilation failed.");
-        } else {
-          Console.WriteLine("Compilation succeeded.");
-        }
-      }
-      finally {
-        script.ScriptExecutionFinished += script_ExecutionFinished;
-        script.Execute();
-        var vs = script.VariableStore;
-        var solution = (IClassificationSolution)vs["demo_bestSolution"];
-        Assert.IsTrue(solution.TrainingAccuracy.IsAlmost(1) && solution.TestAccuracy.IsAlmost(0.953125));
-      }
-    }
-
-    [TestMethod]
-    [TestCategory("Scripting")]
-    public void RunSvmRegressionScriptTest() {
-      var assembly = new StartPage().GetType().Assembly;
-      const string name = PathPrefix + SvmRegressionScriptName + PathSuffix;
-      var script = (CSharpScript)LoadSample(name, assembly);
-
-      try {
-        script.Compile();
-      }
-      catch {
-        if (script.CompileErrors.HasErrors) {
-          ShowCompilationResults(script);
-          throw new Exception("Compilation failed.");
-        } else {
-          Console.WriteLine("Compilation succeeded.");
-        }
-      }
-      finally {
-        script.ScriptExecutionFinished += script_ExecutionFinished;
-        script.Execute();
-        var vs = script.VariableStore;
-        var solution = (IRegressionSolution)vs["demo_bestSolution"];
-        Assert.IsTrue(solution.TrainingRSquared.IsAlmost(0.066221959224331) && solution.TestRSquared.IsAlmost(0.0794407638195883));
-      }
-    }
-
-    [TestMethod]
-    [TestCategory("Scripting")]
-    public void RunSvmClassificationScriptTest() {
-      var assembly = new StartPage().GetType().Assembly;
-      const string name = PathPrefix + SvmClassificationScriptName + PathSuffix;
-      var script = (CSharpScript)LoadSample(name, assembly);
-
-      try {
-        script.Compile();
-      }
-      catch {
-        if (script.CompileErrors.HasErrors) {
-          ShowCompilationResults(script);
-          throw new Exception("Compilation failed.");
-        } else {
-          Console.WriteLine("Compilation succeeded.");
-        }
-      }
-      finally {
-        script.ScriptExecutionFinished += script_ExecutionFinished;
-        script.Execute();
-        manualResetEvent.WaitOne();
-        var vs = script.VariableStore;
-        var solution = (IClassificationSolution)vs["demo_bestSolution"];
-        Assert.IsTrue(solution.TrainingAccuracy.IsAlmost(0.817472698907956) && solution.TestAccuracy.IsAlmost(0.809375));
-      }
-    }
-
-    #region Helpers
-    private static void ShowCompilationResults(Script script) {
-      if (script.CompileErrors.Count == 0) return;
-      var msgs = script.CompileErrors.OfType<CompilerError>()
-                                      .OrderBy(x => x.IsWarning)
-                                      .ThenBy(x => x.Line)
-                                      .ThenBy(x => x.Column);
-      foreach (var m in msgs) {
-        Console.WriteLine(m);
-      }
-    }
-
-    private INamedItem LoadSample(string name, Assembly assembly) {
-      string path = Path.GetTempFileName();
-      INamedItem item = null;
-      try {
-        using (var stream = assembly.GetManifestResourceStream(name)) {
-          WriteStreamToTempFile(stream, path); // create a file in a temporary folder (persistence cannot load these files directly from the stream)
-          item = XmlParser.Deserialize<INamedItem>(path);
-        }
-      }
-      catch (Exception) {
-      }
-      finally {
-        if (File.Exists(path)) {
-          File.Delete(path); // make sure we remove the temporary file
-        }
-      }
-      return item;
-    }
-
-    private void WriteStreamToTempFile(Stream stream, string path) {
-      using (FileStream output = new FileStream(path, FileMode.Create, FileAccess.Write)) {
-        stream.CopyTo(output);
-      }
-    }
-
-    private void script_ExecutionFinished(object sender, EventArgs a) {
-      manualResetEvent.Set();
-    }
-    #endregion
-  }
-}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/ScriptingUtils.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/ScriptingUtils.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/ScriptingUtils.cs	(revision 11677)
@@ -0,0 +1,55 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 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.IO;
+using System.Threading;
+using HeuristicLab.Scripting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  public static class ScriptingUtils {
+    public const string ScriptsDirectory = @"Scripts\";
+    public const string ScriptSourcesDirectory = @"Test Resources\Script Sources\";
+    public const string ScriptFileExtension = ".hl";
+    public const string ScriptSourceFileExtension = ".cs";
+
+    public static void RunScript(CSharpScript s) {
+      var trigger = new EventWaitHandle(false, EventResetMode.ManualReset);
+      Exception ex = null;
+
+      s.ScriptExecutionFinished += (sender, e) => { ex = e.Value; trigger.Set(); };
+      s.Execute();
+      trigger.WaitOne();
+
+      Assert.IsNull(ex);
+    }
+
+    public static T GetVariable<T>(CSharpScript a, string resultName) {
+      return (T)a.VariableStore[resultName];
+    }
+
+    public static string LoadScriptCodeFromFile(string scriptName) {
+      string path = Path.Combine(ScriptSourcesDirectory, scriptName + ScriptSourceFileExtension);
+      return File.ReadAllText(path);
+    }
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GAQAPScriptTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GAQAPScriptTest.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GAQAPScriptTest.cs	(revision 11677)
@@ -0,0 +1,80 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 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.IO;
+using System.Linq;
+using HeuristicLab.Persistence.Default.Xml;
+using HeuristicLab.Problems.Instances.QAPLIB;
+using HeuristicLab.Problems.QuadraticAssignment;
+using HeuristicLab.Scripting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  [TestClass]
+  public class GAQAPScriptTest {
+    private const string ScriptFileName = "GA_QAP_Script";
+    private const string ScriptItemName = "Genetic Algorithm Script - QAP";
+    private const string ScriptItemDescription = "A scripted genetic algorithm which solves the \"" + ProblemInstanceName + "\" quadratic assignment problem (imported from Drezner)";
+    private const string ProblemInstanceName = "dre56";
+    private const string BestQualityVariableName = "bestQuality";
+
+    [TestMethod]
+    [TestCategory("Scripts.Create")]
+    [TestProperty("Time", "short")]
+    public void CreateGAQAPScriptScriptTest() {
+      var script = CreateGAQAPScript();
+      string path = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);
+      XmlGenerator.Serialize(script, path);
+    }
+
+    [TestMethod]
+    [TestCategory("Scripts.Execute")]
+    [TestProperty("Time", "long")]
+    public void RunGAQAPScriptTest() {
+      var script = CreateGAQAPScript();
+
+      script.Compile();
+      ScriptingUtils.RunScript(script);
+
+      var bestQuality = ScriptingUtils.GetVariable<double>(script, BestQualityVariableName);
+      Assert.AreEqual(2410.0, bestQuality, 1E-8);
+    }
+
+    private CSharpScript CreateGAQAPScript() {
+      var script = new CSharpScript {
+        Name = ScriptItemName,
+        Description = ScriptItemDescription
+      };
+      #region Variables
+      var provider = new DreznerQAPInstanceProvider();
+      var instance = provider.GetDataDescriptors().Single(x => x.Name == ProblemInstanceName);
+      var data = provider.LoadData(instance);
+      var problem = new QuadraticAssignmentProblem();
+      problem.Load(data);
+      script.VariableStore.Add(ProblemInstanceName, problem);
+      #endregion
+      #region Code
+      script.Code = ScriptingUtils.LoadScriptCodeFromFile(ScriptFileName);
+      #endregion
+      return script;
+    }
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GUIAutomationScriptTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GUIAutomationScriptTest.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GUIAutomationScriptTest.cs	(revision 11677)
@@ -0,0 +1,55 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 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.IO;
+using HeuristicLab.Persistence.Default.Xml;
+using HeuristicLab.Scripting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  [TestClass]
+  public class GUIAutomationScriptTest {
+    private const string ScriptFileName = "GUI_Automation_Script";
+    private const string ScriptItemName = "GUI Automation Script";
+    private const string ScriptItemDescription = "A script that runs a genetic algorithm on a traveling salesman problem with 5 different settings for population sizes and with 10 repetitions, then opens a bubble chart of the results and chooses the appropriate values for x and y axis automatically";
+    private const string ExperimentVariableName = "experiment";
+
+    [TestMethod]
+    [TestCategory("Scripts.Create")]
+    [TestProperty("Time", "short")]
+    public void CreateGUIAutomationScriptTest() {
+      var script = CreateGUIAutomationScript();
+      string path = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);
+      XmlGenerator.Serialize(script, path);
+    }
+
+    private CSharpScript CreateGUIAutomationScript() {
+      var script = new CSharpScript {
+        Name = ScriptItemName,
+        Description = ScriptItemDescription
+      };
+      #region Code
+      script.Code = ScriptingUtils.LoadScriptCodeFromFile(ScriptFileName);
+      #endregion
+      return script;
+    }
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchRFClassificationScriptTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchRFClassificationScriptTest.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchRFClassificationScriptTest.cs	(revision 11677)
@@ -0,0 +1,80 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 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.IO;
+using System.Linq;
+using HeuristicLab.Persistence.Default.Xml;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.Instances.DataAnalysis;
+using HeuristicLab.Scripting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  [TestClass]
+  public class GridSearchRFClassificationScriptTest {
+    private const string ScriptFileName = "GridSearch_RF_Classification_Script";
+    private const string ScriptItemName = "Grid Search Random Forest Script - Classification";
+    private const string ScriptItemDescription = "A script that runs a grid search for random forest parameters for solving symbolic classification problems";
+    private const string ProblemInstanceName = "Mammography, M. Elter, 2007";
+    private const string ProblemInstanceDataVaribleName = "problem";
+    private const string BestSolutionVariableName = "bestSolution";
+
+    [TestMethod]
+    [TestCategory("Scripts.Create")]
+    [TestProperty("Time", "short")]
+    public void CreateGridSearchRFClassificationScriptTest() {
+      var script = CreateGridSearchRFClassificationScript();
+      string path = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);
+      XmlGenerator.Serialize(script, path);
+    }
+
+    [TestMethod]
+    [TestCategory("Scripts.Execute")]
+    [TestProperty("Time", "long")]
+    public void RunGridSearchRFClassificationScriptTest() {
+      var script = CreateGridSearchRFClassificationScript();
+
+      script.Compile();
+      ScriptingUtils.RunScript(script);
+
+      var bestSolution = ScriptingUtils.GetVariable<IClassificationSolution>(script, BestSolutionVariableName);
+      Assert.AreEqual(0.946957878315133, bestSolution.TrainingAccuracy, 1E-8);
+      Assert.AreEqual(0.734375, bestSolution.TestAccuracy, 1E-8);
+    }
+
+    private CSharpScript CreateGridSearchRFClassificationScript() {
+      var script = new CSharpScript {
+        Name = ScriptItemName,
+        Description = ScriptItemDescription
+      };
+      #region Variables
+      var provider = new UCIInstanceProvider();
+      var instance = (UCIDataDescriptor)provider.GetDataDescriptors().Single(x => x.Name == ProblemInstanceName);
+      var data = provider.LoadData(instance);
+      script.VariableStore.Add(ProblemInstanceDataVaribleName, data);
+      #endregion
+      #region Code
+      script.Code = ScriptingUtils.LoadScriptCodeFromFile(ScriptFileName);
+      #endregion
+      return script;
+    }
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchRFRegressionScriptTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchRFRegressionScriptTest.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchRFRegressionScriptTest.cs	(revision 11677)
@@ -0,0 +1,80 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 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.IO;
+using System.Linq;
+using HeuristicLab.Persistence.Default.Xml;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.Instances.DataAnalysis;
+using HeuristicLab.Scripting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  [TestClass]
+  public class GridSearchRFRegressionScriptTest {
+    private const string ScriptFileName = "GridSearch_RF_Regression_Script";
+    private const string ScriptItemName = "Grid Search Random Forest Script - Regression";
+    private const string ScriptItemDescription = "A script that runs a grid search for random forest parameters for solving symbolic regression problems";
+    private const string ProblemInstanceName = "Keijzer 3 f(x) = 0.3 * x *sin(2 * PI * x); Interval [-3, 3]";
+    private const string ProblemInstanceDataVaribleName = "problem";
+    private const string BestSolutionVariableName = "bestSolution";
+
+    [TestMethod]
+    [TestCategory("Scripts.Create")]
+    [TestProperty("Time", "short")]
+    public void CreateGridSearchRFRegressionScriptTest() {
+      var script = CreateGridSearchRFRegressionScript();
+      string path = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);
+      XmlGenerator.Serialize(script, path);
+    }
+
+    [TestMethod]
+    [TestCategory("Scripts.Execute")]
+    [TestProperty("Time", "long")]
+    public void RunGridSearchRFRegressionScriptTest() {
+      var script = CreateGridSearchRFRegressionScript();
+
+      script.Compile();
+      ScriptingUtils.RunScript(script);
+
+      var bestSolution = ScriptingUtils.GetVariable<IRegressionSolution>(script, BestSolutionVariableName);
+      Assert.AreEqual(1.0, bestSolution.TrainingRSquared, 1E-8);
+      Assert.AreEqual(0.966618401251492, bestSolution.TestRSquared, 1E-8);
+    }
+
+    private CSharpScript CreateGridSearchRFRegressionScript() {
+      var script = new CSharpScript {
+        Name = ScriptItemName,
+        Description = ScriptItemDescription
+      };
+      #region Variables
+      var provider = new KeijzerInstanceProvider();
+      var instance = (ArtificialRegressionDataDescriptor)provider.GetDataDescriptors().Single(x => x.Name == ProblemInstanceName);
+      var data = instance.GenerateRegressionData();
+      script.VariableStore.Add(ProblemInstanceDataVaribleName, data);
+      #endregion
+      #region Code
+      script.Code = ScriptingUtils.LoadScriptCodeFromFile(ScriptFileName);
+      #endregion
+      return script;
+    }
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchSVMClassificationScriptTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchSVMClassificationScriptTest.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchSVMClassificationScriptTest.cs	(revision 11677)
@@ -0,0 +1,80 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 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.IO;
+using System.Linq;
+using HeuristicLab.Persistence.Default.Xml;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.Instances.DataAnalysis;
+using HeuristicLab.Scripting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  [TestClass]
+  public class GridSearchSVMClassificationScriptTest {
+    private const string ScriptFileName = "GridSearch_SVM_Classification_Script";
+    private const string ScriptItemName = "Grid Search SVM Script - Classification";
+    private const string ScriptItemDescription = "A script that runs a grid search for SVM parameters for solving symbolic classification problems";
+    private const string ProblemInstanceName = "Mammography, M. Elter, 2007";
+    private const string ProblemInstanceDataVaribleName = "problem";
+    private const string BestSolutionVariableName = "bestSolution";
+
+    [TestMethod]
+    [TestCategory("Scripts.Create")]
+    [TestProperty("Time", "short")]
+    public void CreateGridSearchSVMClassificationScriptTest() {
+      var script = CreateGridSearchSVMClassificationScript();
+      string path = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);
+      XmlGenerator.Serialize(script, path);
+    }
+
+    [TestMethod]
+    [TestCategory("Scripts.Execute")]
+    [TestProperty("Time", "medium")]
+    public void RunGridSearchSVMClassificationScriptTest() {
+      var script = CreateGridSearchSVMClassificationScript();
+
+      script.Compile();
+      ScriptingUtils.RunScript(script);
+
+      var bestSolution = ScriptingUtils.GetVariable<IClassificationSolution>(script, BestSolutionVariableName);
+      Assert.AreEqual(0.819032761310452, bestSolution.TrainingAccuracy, 1E-8);
+      Assert.AreEqual(0.721875, bestSolution.TestAccuracy, 1E-8);
+    }
+
+    private CSharpScript CreateGridSearchSVMClassificationScript() {
+      var script = new CSharpScript {
+        Name = ScriptItemName,
+        Description = ScriptItemDescription
+      };
+      #region Variables
+      var provider = new UCIInstanceProvider();
+      var instance = (UCIDataDescriptor)provider.GetDataDescriptors().Single(x => x.Name == ProblemInstanceName);
+      var data = provider.LoadData(instance);
+      script.VariableStore.Add(ProblemInstanceDataVaribleName, data);
+      #endregion
+      #region Code
+      script.Code = ScriptingUtils.LoadScriptCodeFromFile(ScriptFileName);
+      #endregion
+      return script;
+    }
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchSVMRegressionScriptTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchSVMRegressionScriptTest.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/GridSearchSVMRegressionScriptTest.cs	(revision 11677)
@@ -0,0 +1,80 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 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.IO;
+using System.Linq;
+using HeuristicLab.Persistence.Default.Xml;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.Instances.DataAnalysis;
+using HeuristicLab.Scripting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  [TestClass]
+  public class GridSearchSVMRegressionScriptTest {
+    private const string ScriptFileName = "GridSearch_SVM_Regression_Script";
+    private const string ScriptItemName = "Grid Search SVM Script - Regression";
+    private const string ScriptItemDescription = "A script that runs a grid search for SVM parameters for solving symbolic regression problems";
+    private const string ProblemInstanceName = "Keijzer 9 f(x) = arcsinh(x)  i.e. ln(x + sqrt(x² + 1))";
+    private const string ProblemInstanceDataVaribleName = "problem";
+    private const string BestSolutionVariableName = "bestSolution";
+
+    [TestMethod]
+    [TestCategory("Scripts.Create")]
+    [TestProperty("Time", "short")]
+    public void CreateGridSearchSVMRegressionScriptTest() {
+      var script = CreateGridSearchSVMRegressionScript();
+      string path = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);
+      XmlGenerator.Serialize(script, path);
+    }
+
+    [TestMethod]
+    [TestCategory("Scripts.Execute")]
+    [TestProperty("Time", "medium")]
+    public void RunGridSearchSVMRegressionScriptTest() {
+      var script = CreateGridSearchSVMRegressionScript();
+
+      script.Compile();
+      ScriptingUtils.RunScript(script);
+
+      var bestSolution = ScriptingUtils.GetVariable<IRegressionSolution>(script, BestSolutionVariableName);
+      Assert.AreEqual(0.982485852864274, bestSolution.TrainingRSquared, 1E-8);
+      Assert.AreEqual(0.98817480950295, bestSolution.TestRSquared, 1E-8);
+    }
+
+    private CSharpScript CreateGridSearchSVMRegressionScript() {
+      var script = new CSharpScript {
+        Name = ScriptItemName,
+        Description = ScriptItemDescription
+      };
+      #region Variables
+      var provider = new KeijzerInstanceProvider();
+      var instance = (ArtificialRegressionDataDescriptor)provider.GetDataDescriptors().Single(x => x.Name == ProblemInstanceName);
+      var data = instance.GenerateRegressionData();
+      script.VariableStore.Add(ProblemInstanceDataVaribleName, data);
+      #endregion
+      #region Code
+      script.Code = ScriptingUtils.LoadScriptCodeFromFile(ScriptFileName);
+      #endregion
+      return script;
+    }
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/OSGARastriginScriptTest.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/OSGARastriginScriptTest.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Scripts/OSGARastriginScriptTest.cs	(revision 11677)
@@ -0,0 +1,79 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2014 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.IO;
+using HeuristicLab.Data;
+using HeuristicLab.Persistence.Default.Xml;
+using HeuristicLab.Scripting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace HeuristicLab.Tests {
+  [TestClass]
+  public class OSGARastriginScriptTest {
+    private const string ScriptFileName = "OSGA_Rastrigin_Script";
+    private const string ScriptItemName = "Offspring Selection Genetic Algorithm Script - Rastrigin";
+    private const string ScriptItemDescription = "A scripted offspring selection genetic algorithm that solves the 100-dimensional Rastrigin test function";
+    private const string LowerBoundVariableName = "minX";
+    private const string UpperBoundVariableName = "maxX";
+    private const string DimensionsVariableName = "N";
+    private const string SeedVariableName = "seed";
+    private const string BestQualityVariableName = "bestFitness";
+
+    [TestMethod]
+    [TestCategory("Scripts.Create")]
+    [TestProperty("Time", "short")]
+    public void CreateOSGARastriginScriptTest() {
+      var script = CreateOSGARastriginScript();
+      string path = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);
+      XmlGenerator.Serialize(script, path);
+    }
+
+    [TestMethod]
+    [TestCategory("Scripts.Execute")]
+    [TestProperty("Time", "long")]
+    public void RunOSGARastriginScriptTest() {
+      var script = CreateOSGARastriginScript();
+
+      script.Compile();
+      ScriptingUtils.RunScript(script);
+
+      var bestQuality = ScriptingUtils.GetVariable<double>(script, BestQualityVariableName);
+      Assert.AreEqual(0.176350329149955, bestQuality, 1E-8);
+    }
+
+    private CSharpScript CreateOSGARastriginScript() {
+      var script = new CSharpScript {
+        Name = ScriptItemName,
+        Description = ScriptItemDescription
+      };
+      #region Variables
+      script.VariableStore.Add(LowerBoundVariableName, new DoubleValue(-5.12));
+      script.VariableStore.Add(UpperBoundVariableName, new DoubleValue(5.12));
+      script.VariableStore.Add(DimensionsVariableName, new IntValue(100));
+      script.VariableStore.Add(SeedVariableName, new IntValue(0));
+      #endregion
+      #region Code
+      script.Code = ScriptingUtils.LoadScriptCodeFromFile(ScriptFileName);
+      #endregion
+      return script;
+    }
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/HeuristicLab.Tests.csproj
===================================================================
--- branches/ALPS/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/HeuristicLab.Tests.csproj	(revision 11677)
@@ -12,7 +12,8 @@
     <RootNamespace>HeuristicLab.Tests</RootNamespace>
     <AssemblyName>HeuristicLab.Tests</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -24,4 +25,5 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@@ -32,4 +34,5 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup>
@@ -54,4 +57,5 @@
     <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
     <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
@@ -70,4 +74,5 @@
     <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
     <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
@@ -86,4 +91,5 @@
     <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
     <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
@@ -100,7 +106,8 @@
     <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
     <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="ALGLIB-3.7.0, Version=3.7.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+    <Reference Include="ALGLIB-3.7.0">
       <HintPath>..\bin\ALGLIB-3.7.0.dll</HintPath>
       <Private>False</Private>
@@ -122,7 +129,7 @@
       <Private>False</Private>
     </Reference>
-    <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
+    <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3">
       <HintPath>..\bin\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll</HintPath>
+      <Private>False</Private>
     </Reference>
     <Reference Include="HeuristicLab.Algorithms.ParticleSwarmOptimization-3.3">
@@ -150,5 +157,5 @@
       <Private>False</Private>
     </Reference>
-    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0">
+    <Reference Include="HeuristicLab.Analysis-3.3">
       <HintPath>..\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
       <Private>False</Private>
@@ -214,8 +221,11 @@
       <Private>False</Private>
     </Reference>
-    <Reference Include="HeuristicLab.Optimizer-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
+    <Reference Include="HeuristicLab.Optimization.Views-3.3">
+      <HintPath>..\bin\HeuristicLab.Optimization.Views-3.3.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="HeuristicLab.Optimizer-3.3">
       <HintPath>..\bin\HeuristicLab.Optimizer-3.3.dll</HintPath>
-      <Private>True</Private>
+      <Private>False</Private>
     </Reference>
     <Reference Include="HeuristicLab.ParallelEngine-3.3">
@@ -259,7 +269,7 @@
       <Private>False</Private>
     </Reference>
-    <Reference Include="HeuristicLab.Problems.GrammaticalEvolution-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
+    <Reference Include="HeuristicLab.Problems.GrammaticalEvolution-3.3">
       <HintPath>..\bin\HeuristicLab.Problems.GrammaticalEvolution-3.3.dll</HintPath>
+      <Private>False</Private>
     </Reference>
     <Reference Include="HeuristicLab.Problems.Instances-3.3">
@@ -327,6 +337,5 @@
       <Private>False</Private>
     </Reference>
-    <Reference Include="HeuristicLab.Scripting-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
+    <Reference Include="HeuristicLab.Scripting-3.3">
       <HintPath>..\bin\HeuristicLab.Scripting-3.3.dll</HintPath>
       <Private>False</Private>
@@ -338,4 +347,8 @@
     <Reference Include="HeuristicLab.SequentialEngine-3.3">
       <HintPath>..\bin\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="LibSVM-3.12">
+      <HintPath>..\bin\LibSVM-3.12.dll</HintPath>
       <Private>False</Private>
     </Reference>
@@ -358,4 +371,5 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="AssemblyInitializer.cs" />
     <Compile Include="HeuristicLab-3.3\AlgorithmExtensions.cs" />
     <Compile Include="HeuristicLab-3.3\CloningConstructorTest.cs" />
@@ -504,6 +518,34 @@
     <Compile Include="HeuristicLab.Problems.VehicleRouting-3.4\VRPInstancesTest.cs" />
     <Compile Include="HeuristicLab.Random-3.3\RandomEnumerableSampleTest.cs" />
-    <Compile Include="HeuristicLab.Scripting-3.3\GridSearchScriptTest.cs" />
+    <Compile Include="HeuristicLab.Scripting-3.3\Scripts\GAQAPScriptTest.cs" />
+    <Compile Include="HeuristicLab.Scripting-3.3\Scripts\GridSearchRFClassificationScriptTest.cs" />
+    <Compile Include="HeuristicLab.Scripting-3.3\Scripts\GridSearchRFRegressionScriptTest.cs" />
+    <Compile Include="HeuristicLab.Scripting-3.3\Scripts\GridSearchSVMClassificationScriptTest.cs" />
+    <Compile Include="HeuristicLab.Scripting-3.3\Scripts\GridSearchSVMRegressionScriptTest.cs" />
+    <Compile Include="HeuristicLab.Scripting-3.3\ScriptingUtils.cs" />
+    <Compile Include="HeuristicLab.Scripting-3.3\Scripts\GUIAutomationScriptTest.cs" />
+    <Compile Include="HeuristicLab.Scripting-3.3\Scripts\OSGARastriginScriptTest.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Test Resources\Script Sources\GridSearch_RF_Classification_Script.cs">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Compile>
+    <Compile Include="Test Resources\Script Sources\GridSearch_RF_Regression_Script.cs">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Compile>
+    <Compile Include="Test Resources\Script Sources\GridSearch_SVM_Classification_Script.cs">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Compile>
+    <Compile Include="Test Resources\Script Sources\GridSearch_SVM_Regression_Script.cs">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Compile>
+    <Compile Include="Test Resources\Script Sources\GA_QAP_Script.cs">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Compile>
+    <Compile Include="Test Resources\Script Sources\OSGA_Rastrigin_Script.cs">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Compile>
+    <Compile Include="Test Resources\Script Sources\GUI_Automation_Script.cs">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Compile>
     <Compile Include="TestRandom.cs" />
   </ItemGroup>
Index: branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GA_QAP_Script.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GA_QAP_Script.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GA_QAP_Script.cs	(revision 11677)
@@ -0,0 +1,69 @@
+﻿using System;
+using System.Linq;
+
+using HeuristicLab.Analysis;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.PermutationEncoding;
+using HeuristicLab.Problems.Instances.QAPLIB;
+using HeuristicLab.Problems.QuadraticAssignment;
+using HeuristicLab.Random;
+
+public class GAQAPScript : HeuristicLab.Scripting.CSharpScriptBase {
+  public override void Main() {
+    DateTime start = DateTime.UtcNow;
+
+    QuadraticAssignmentProblem qap;
+    if (vars.Contains("qap")) qap = vars.qap;
+    else {
+      var provider = new DreznerQAPInstanceProvider();
+      var instance = provider.GetDataDescriptors().Single(x => x.Name == "dre56");
+      var data = provider.LoadData(instance);
+      qap = new QuadraticAssignmentProblem();
+      qap.Load(data);
+      vars.qap = qap;
+    }
+
+    const uint seed = 0;
+    const int popSize = 100;
+    const int generations = 1000;
+    const double mutationRate = 0.05;
+
+    var random = new MersenneTwister(seed);
+    var population = new Permutation[popSize];
+    var qualities = new double[popSize];
+    var nextGen = new Permutation[popSize];
+    var nextQual = new double[popSize];
+
+    var qualityChart = new DataTable("Quality Chart");
+    var qualityRow = new DataRow("Best Quality");
+    qualityChart.Rows.Add(qualityRow);
+    vars.qualityChart = qualityChart;
+
+    for (int i = 0; i < popSize; i++) {
+      population[i] = new Permutation(PermutationTypes.Absolute, qap.Weights.Rows, random);
+      qualities[i] = QAPEvaluator.Apply(population[i], qap.Weights, qap.Distances);
+    }
+    var bestQuality = qualities.Min();
+    var bestQualityGeneration = 0;
+
+    for (int g = 0; g < generations; g++) {
+      var parents = population.SampleProportional(random, 2 * popSize, qualities, windowing: true, inverseProportional: true).ToArray();
+      for (int i = 0; i < popSize; i++) {
+        nextGen[i] = PartiallyMatchedCrossover.Apply(random, parents[i * 2], parents[i * 2 + 1]);
+        if (random.NextDouble() < mutationRate) Swap2Manipulator.Apply(random, nextGen[i]);
+        nextQual[i] = QAPEvaluator.Apply(nextGen[i], qap.Weights, qap.Distances);
+        if (nextQual[i] < bestQuality) {
+          bestQuality = nextQual[i];
+          bestQualityGeneration = g;
+        }
+      }
+      qualityRow.Values.Add(bestQuality);
+      Array.Copy(nextGen, population, popSize);
+      Array.Copy(nextQual, qualities, popSize);
+    }
+
+    vars.elapsed = new TimeSpanValue(DateTime.UtcNow - start);
+    vars.bestQuality = bestQuality;
+    vars.bestQualityFoundAt = bestQualityGeneration;
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GUI_Automation_Script.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GUI_Automation_Script.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GUI_Automation_Script.cs	(revision 11677)
@@ -0,0 +1,46 @@
+﻿using System;
+using System.Linq;
+using System.Threading;
+using System.Windows.Forms;
+
+using HeuristicLab.Algorithms.GeneticAlgorithm;
+using HeuristicLab.Core;
+using HeuristicLab.MainForm;
+using HeuristicLab.MainForm.WindowsForms;
+using HeuristicLab.Optimization;
+using HeuristicLab.Optimization.Views;
+using HeuristicLab.Problems.TravelingSalesman;
+
+public class GUIAutomationScript : HeuristicLab.Scripting.CSharpScriptBase {
+  readonly ManualResetEvent mutex = new ManualResetEvent(false);
+
+  public override void Main() {
+    var ga = new GeneticAlgorithm {
+      MaximumGenerations = { Value = 50 },
+      PopulationSize = { Value = 10 },
+      Problem = new TravelingSalesmanProblem()
+    };
+
+    var experiment = new Experiment();
+    for (int i = 0; i < 5; i++) {
+      experiment.Optimizers.Add(new BatchRun() { Optimizer = (IOptimizer)ga.Clone(), Repetitions = 10 });
+      ga.PopulationSize.Value *= 2;
+    }
+
+    experiment.ExecutionStateChanged += OnExecutionStateChanged;
+    experiment.Start();
+    mutex.WaitOne();
+
+    vars.experiment = experiment;
+    MainFormManager.MainForm.ShowContent(experiment);
+    var viewHost = (ViewHost)MainFormManager.MainForm.ShowContent(experiment.Runs, typeof(RunCollectionBubbleChartView));
+    var bubbleChart = (UserControl)(viewHost.ActiveView);
+    bubbleChart.Controls.OfType<ComboBox>().Single(x => x.Name == "yAxisComboBox").SelectedItem = "BestQuality";
+    bubbleChart.Controls.OfType<ComboBox>().Single(x => x.Name == "xAxisComboBox").SelectedItem = "PopulationSize";
+  }
+
+  private void OnExecutionStateChanged(object sender, EventArgs e) {
+    if (((IExecutable)sender).ExecutionState == ExecutionState.Stopped)
+      mutex.Set();
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_RF_Classification_Script.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_RF_Classification_Script.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_RF_Classification_Script.cs	(revision 11677)
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using HeuristicLab.Algorithms.DataAnalysis;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.Instances.DataAnalysis;
+using HeuristicLab.Scripting;
+
+public class RFClassificationCrossValidationScript : HeuristicLab.Scripting.CSharpScriptBase {
+  /* Maximum degree of parallelism (specifies whether or not the grid search should be parallelized) */
+  const int maximumDegreeOfParallelism = 4;
+  /* Number of crossvalidation folds: */
+  const int numberOfFolds = 3;
+  /* Specify whether the folds should be shuffled before doing crossvalidation */
+  const bool shuffleFolds = true;
+
+  /* The tunable Random Forest parameters:
+     - "N" (number of trees). In the random forests literature, this is referred to as the ntree parameter.
+       Larger number of trees produce more stable models and covariate importance estimates, but require more memory and a longer run time.
+       For small datasets, 50 trees may be sufficient. For larger datasets, 500 or more may be required. Please consult the random forests
+       literature for extensive discussion of this parameter (e.g. Cutler et al., 2007; Strobl et al., 2007; Strobl et al., 2008).
+
+     - "R" The ratio of the training set that will be used in the construction of individual trees (0<r<=1). Should be adjusted depending on
+       the noise level in the dataset in the range from 0.66 (low noise) to 0.05 (high noise). This parameter should be adjusted to achieve
+       good generalization error.
+
+     - "M" The ratio of features that will be used in the construction of individual trees (0<m<=1)
+  */
+  static Dictionary<string, IEnumerable<double>> randomForestParameterRanges = new Dictionary<string, IEnumerable<double>> {
+    { "N", ValueGenerator.GenerateSteps(5m, 10, 1).Select(x => Math.Pow(2,(double)x)) },
+    { "R", ValueGenerator.GenerateSteps(0.05m, 1, 0.05m).Select(x => (double)x) },
+    { "M", ValueGenerator.GenerateSteps(0.1m, 1, 0.1m).Select(x => (double)x) }
+  };
+
+  private static RandomForestClassificationSolution GridSearchWithCrossvalidation(IClassificationProblemData problemData, int numberOfCrossvalidationFolds, out RFParameter bestParameters,
+  int seed = 3141519) {
+    double rmsError, outOfBagRmsError, relClassificationError, outOfBagRelClassificationError;
+    bestParameters = RandomForestUtil.GridSearch(problemData, numberOfFolds, shuffleFolds, randomForestParameterRanges, seed, maximumDegreeOfParallelism);
+    var model = RandomForestModel.CreateClassificationModel(problemData, problemData.TrainingIndices, bestParameters.N, bestParameters.R, bestParameters.M, seed,
+                                                            out rmsError, out outOfBagRmsError, out relClassificationError, out outOfBagRelClassificationError);
+    return (RandomForestClassificationSolution)model.CreateClassificationSolution(problemData);
+  }
+
+  private static RandomForestClassificationSolution GridSearch(IClassificationProblemData problemData, out RFParameter bestParameters, int seed = 3141519) {
+    double rmsError, outOfBagRmsError, relClassificationError, outOfBagRelClassificationError;
+    bestParameters = RandomForestUtil.GridSearch(problemData, randomForestParameterRanges, seed, maximumDegreeOfParallelism);
+    var model = RandomForestModel.CreateClassificationModel(problemData, problemData.TrainingIndices, bestParameters.N, bestParameters.R, bestParameters.M, seed,
+                                                            out rmsError, out outOfBagRmsError, out relClassificationError, out outOfBagRelClassificationError);
+    return (RandomForestClassificationSolution)model.CreateClassificationSolution(problemData);
+  }
+
+  public override void Main() {
+    var variables = (Variables)vars;
+    var item = variables.SingleOrDefault(x => x.Value is IClassificationProblem || x.Value is IClassificationProblemData);
+    if (item.Equals(default(KeyValuePair<string, object>)))
+      throw new ArgumentException("Could not find a suitable problem or problem data.");
+
+    string name = item.Key;
+    IClassificationProblemData problemData;
+    if (item.Value is IClassificationProblem)
+      problemData = ((IClassificationProblem)item.Value).ProblemData;
+    else
+      problemData = (IClassificationProblemData)item.Value;
+
+    var bestParameters = new RFParameter();
+    var bestSolution = GridSearch(problemData, out bestParameters);
+    vars["bestSolution"] = bestSolution;
+    vars["bestParameters"] = bestParameters;
+
+    Console.WriteLine("Accuracy (training): " + bestSolution.TrainingAccuracy + ", Accuracy (test): " + bestSolution.TestAccuracy);
+    Console.WriteLine("Model parameters: n = {0}, r = {1}, m = {2}", bestParameters.N, bestParameters.R, bestParameters.M);
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_RF_Regression_Script.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_RF_Regression_Script.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_RF_Regression_Script.cs	(revision 11677)
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using HeuristicLab.Algorithms.DataAnalysis;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.Instances.DataAnalysis;
+using HeuristicLab.Random;
+using HeuristicLab.Scripting;
+
+public class RFRegressionCrossValidationScript : HeuristicLab.Scripting.CSharpScriptBase {
+  /* Maximum degree of parallelism (specifies whether or not the grid search should be parallelized) */
+  const int maximumDegreeOfParallelism = 4;
+  /* Number of crossvalidation folds: */
+  const int numberOfFolds = 3;
+  /* Specify whether the crossvalidation folds should be shuffled */
+  const bool shuffleFolds = true;
+
+  /* The tunable Random Forest parameters:
+     - "n" (number of trees). In the random forests literature, this is referred to as the ntree parameter.
+       Larger number of trees produce more stable models and covariate importance estimates, but require more memory and a longer run time.
+       For small datasets, 50 trees may be sufficient. For larger datasets, 500 or more may be required. Please consult the random forests
+       literature for extensive discussion of this parameter (e.g. Cutler et al., 2007; Strobl et al., 2007; Strobl et al., 2008).
+
+     - "r" The ratio of the training set that will be used in the construction of individual trees (0<r<=1). Should be adjusted depending on
+       the noise level in the dataset in the range from 0.66 (low noise) to 0.05 (high noise). This parameter should be adjusted to achieve
+       good generalization error.
+
+     - "m" The ratio of features that will be used in the construction of individual trees (0<m<=1)
+  */
+  static Dictionary<string, IEnumerable<double>> randomForestParameterRanges = new Dictionary<string, IEnumerable<double>> {
+    { "N", ValueGenerator.GenerateSteps(5m, 10, 1).Select(x => Math.Pow(2,(double)x)) },
+    { "R", ValueGenerator.GenerateSteps(0.05m, 1, 0.05m).Select(x => (double)x) },
+    { "M", ValueGenerator.GenerateSteps(0.1m, 1, 0.1m).Select(x => (double)x) }
+  };
+
+  private static RandomForestRegressionSolution GridSearchWithCrossvalidation(IRegressionProblemData problemData, out RFParameter bestParameters, int seed = 3141519) {
+    double rmsError, outOfBagRmsError, avgRelError, outOfBagAvgRelError;
+    bestParameters = RandomForestUtil.GridSearch(problemData, numberOfFolds, shuffleFolds, randomForestParameterRanges, seed, maximumDegreeOfParallelism);
+    var model = RandomForestModel.CreateRegressionModel(problemData, problemData.TrainingIndices, bestParameters.N, bestParameters.R, bestParameters.M, seed, out rmsError, out outOfBagRmsError, out avgRelError, out outOfBagAvgRelError);
+    return (RandomForestRegressionSolution)model.CreateRegressionSolution(problemData);
+  }
+
+  private static RandomForestRegressionSolution GridSearch(IRegressionProblemData problemData, out RFParameter bestParameters, int seed = 3141519) {
+    double rmsError, outOfBagRmsError, avgRelError, outOfBagAvgRelError;
+    var random = new MersenneTwister();
+    bestParameters = RandomForestUtil.GridSearch(problemData, randomForestParameterRanges, seed, maximumDegreeOfParallelism);
+    var model = RandomForestModel.CreateRegressionModel(problemData, problemData.TrainingIndices, bestParameters.N, bestParameters.R, bestParameters.M, seed,
+                                                        out rmsError, out outOfBagRmsError, out avgRelError, out outOfBagAvgRelError);
+    return (RandomForestRegressionSolution)model.CreateRegressionSolution(problemData);
+  }
+
+  public override void Main() {
+    var variables = (Variables)vars;
+    var item = variables.SingleOrDefault(x => x.Value is IRegressionProblem || x.Value is IRegressionProblemData);
+    if (item.Equals(default(KeyValuePair<string, object>)))
+      throw new ArgumentException("Could not find a suitable problem or problem data.");
+
+    string name = item.Key;
+    IRegressionProblemData problemData;
+    if (item.Value is IRegressionProblem)
+      problemData = ((IRegressionProblem)item.Value).ProblemData;
+    else
+      problemData = (IRegressionProblemData)item.Value;
+
+    var bestParameters = new RFParameter();
+    var bestSolution = GridSearch(problemData, out bestParameters);
+    vars["bestSolution"] = bestSolution;
+    vars["bestParameters"] = bestParameters;
+
+    Console.WriteLine("R2 (training): " + bestSolution.TrainingRSquared + ", R2 (test): " + bestSolution.TestRSquared);
+    Console.WriteLine("Model parameters: n = {0}, r = {1}, m = {2}", bestParameters.N, bestParameters.R, bestParameters.M);
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_SVM_Classification_Script.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_SVM_Classification_Script.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_SVM_Classification_Script.cs	(revision 11677)
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+
+using HeuristicLab.Algorithms.DataAnalysis;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.Instances.DataAnalysis;
+using HeuristicLab.Scripting;
+
+using LibSVM;
+
+public class SVMClassificationCrossValidationScript : HeuristicLab.Scripting.CSharpScriptBase {
+  /* Maximum degree of parallelism (specifies whether or not the grid search should be parallelized) */
+  const int maximumDegreeOfParallelism = 4;
+
+  /* Number of crossvalidation folds: */
+  const int numberOfFolds = 5;
+
+  /* Specify whether the folds should be shuffled */
+  const bool shuffleFolds = false;
+
+  /* The tunable SVM parameters:
+     - "C" (penalty factor) effects the trade-off between complexity and proportion of nonseparable samples and must be selected by the user. Can have any positive value.
+     - "nu" is an upper bound on the fraction of margin errors and a lower bound of the fraction of support vectors relative to the total number of training examples.
+     - "degree" represents the polynomial kernel degree
+     - "eps" (epsilon) determines the level of accuracy of the approximated function. It controls the width of the epsilon-insensitive zone used to fit the training data.
+       With optimal values of epsilon, the parameter C has negligible effect.
+     - "degree" represents the degree of the polynomial kernel
+     - "kernel_type" specifies the kernel to be used: linear, polynomial, radial basis or sigmoidal.
+       Valid values: svm_parameter.LINEAR, svm_parameter.POLY, svm_parameter.RBF, svm_parameter.SIGMOID
+     Comment or uncomment the parameter ranges below as needed.  */
+
+  static Dictionary<string, IEnumerable<double>> svmParameterRanges = new Dictionary<string, IEnumerable<double>> {
+        { "svm_type", new List<double> {svm_parameter.NU_SVC } },
+        { "kernel_type", new List<double> { svm_parameter.RBF }},
+        { "C", ValueGenerator.GenerateSteps(-1m, 10, 1).Select(x => Math.Pow(2,(double)x)) },
+        { "gamma", ValueGenerator.GenerateSteps(-4m, -1, 1).Select(x => Math.Pow(2,(double)x)) },
+//        { "eps", ValueGenerator.GenerateSteps(-8m, -1, 1).Select(x => Math.Pow(2, (double)x)) },
+        { "nu" , ValueGenerator.GenerateSteps(-10m, 0, 1m).Select(x => Math.Pow(2, (double)x)) },
+//        { "degree", ValueGenerator.GenerateSteps(1m, 4, 1).Select(x => (double)x) }
+  };
+
+  static Dictionary<int, string> svmTypes = new Dictionary<int, string> {
+    { svm_parameter.NU_SVC, "NU_SVC" },
+    { svm_parameter.C_SVC, "C_SVC" }
+  };
+
+  static Dictionary<int, string> kernelTypes = new Dictionary<int, string> {
+    { svm_parameter.LINEAR, "LINEAR" },
+    { svm_parameter.POLY, "POLY" },
+    { svm_parameter.RBF, "RBF" },
+    { svm_parameter.SIGMOID, "SIGMOID" }
+  };
+
+  private static SupportVectorClassificationSolution SvmGridSearch(IClassificationProblemData problemData, out svm_parameter bestParameters, out int nSv, out double cvMse) {
+    bestParameters = SupportVectorMachineUtil.GridSearch(out cvMse, problemData, svmParameterRanges, numberOfFolds, shuffleFolds, maximumDegreeOfParallelism);
+    double trainingError, testError;
+    string svmType = svmTypes[bestParameters.svm_type];
+    string kernelType = kernelTypes[bestParameters.kernel_type];
+    var svm_solution = SupportVectorClassification.CreateSupportVectorClassificationSolution(problemData, problemData.AllowedInputVariables, svmType, kernelType,
+                       bestParameters.C, bestParameters.nu, bestParameters.gamma, bestParameters.degree, out trainingError, out testError, out nSv);
+    return svm_solution;
+  }
+
+  public override void Main() {
+    var variables = (Variables)vars;
+    var item = variables.SingleOrDefault(x => x.Value is IClassificationProblem || x.Value is IClassificationProblemData);
+    if (item.Equals(default(KeyValuePair<string, object>)))
+      throw new ArgumentException("Could not find a suitable problem or problem data.");
+
+    string name = item.Key;
+    IClassificationProblemData problemData;
+    if (item.Value is IClassificationProblem)
+      problemData = ((IClassificationProblem)item.Value).ProblemData;
+    else
+      problemData = (IClassificationProblemData)item.Value;
+
+    int nSv; // number of support vectors
+    double cvMse;
+    svm_parameter bestParameters;
+    var bestSolution = SvmGridSearch(problemData, out bestParameters, out nSv, out cvMse);
+
+    vars["bestSolution"] = bestSolution;
+    Console.WriteLine(name + " parameters: C = {0}, g = {1:0.000}, eps = {2:0.000}, nu = {3:0.000}, degree = {4}", bestParameters.C, bestParameters.gamma, bestParameters.eps, bestParameters.nu, bestParameters.degree);
+    Console.WriteLine(name + " best solution accuracy (training): " + bestSolution.TrainingAccuracy + ", accuracy (test): " + bestSolution.TestAccuracy);
+
+    var bestParametersCollection = new ParameterCollection();
+    foreach (var p in svmParameterRanges.Keys) {
+      var getter = GenerateGetter(p);
+      bestParametersCollection.Add(new FixedValueParameter<DoubleValue>(p, new DoubleValue(getter(bestParameters))));
+    }
+    vars["bestParameters"] = bestParametersCollection;
+  }
+
+  private static Func<svm_parameter, double> GenerateGetter(string field) {
+    var paramExpr = Expression.Parameter(typeof(svm_parameter));
+    var getterExpr = Expression.Convert(Expression.Field(paramExpr, field), typeof(double)); // cast to double
+    Func<svm_parameter, double> f = Expression.Lambda<Func<svm_parameter, double>>(getterExpr, paramExpr).Compile();
+    return f;
+  }
+}
+
Index: branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_SVM_Regression_Script.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_SVM_Regression_Script.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/GridSearch_SVM_Regression_Script.cs	(revision 11677)
@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+
+using HeuristicLab.Algorithms.DataAnalysis;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Parameters;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.Instances.DataAnalysis;
+using HeuristicLab.Scripting;
+
+using LibSVM;
+
+public class SVMRegressionCrossValidationScript : HeuristicLab.Scripting.CSharpScriptBase {
+  /* Maximum degree of parallelism (specifies whether or not the grid search should be parallelized) */
+  const int maximumDegreeOfParallelism = 4;
+
+  /* Number of crossvalidation folds: */
+  const int numberOfFolds = 5;
+
+  /* Specify whether the folds should be shuffled */
+  const bool shuffleFolds = false;
+
+  /* The tunable SVM parameters:
+     - "C" (penalty factor) effects the trade-off between complexity and proportion of nonseparable samples and must be selected by the user. Can have any positive value.
+     - "nu" is an upper bound on the fraction of margin errors and a lower bound of the fraction of support vectors relative to the total number of training examples.
+     - "degree" represents the polynomial kernel degree
+     - "eps" (epsilon) determines the level of accuracy of the approximated function. It controls the width of the epsilon-insensitive zone used to fit the training data.
+       With optimal values of epsilon, the parameter C has negligible effect.
+     - "degree" represents the degree of the polynomial kernel
+     - "kernel_type" specifies the kernel to be used: linear, polynomial, radial basis or sigmoidal.
+       Valid values: svm_parameter.LINEAR, svm_parameter.POLY, svm_parameter.RBF, svm_parameter.SIGMOID
+     Comment or uncomment the parameter ranges below as needed.  */
+
+  static Dictionary<string, IEnumerable<double>> svmParameterRanges = new Dictionary<string, IEnumerable<double>> {
+        { "svm_type", new List<double> {svm_parameter.NU_SVR } },
+        { "kernel_type", new List<double> { svm_parameter.RBF }},
+        { "C", ValueGenerator.GenerateSteps(-1m, 12, 1).Select(x => Math.Pow(2, (double)x)) },
+        { "gamma", ValueGenerator.GenerateSteps(-4m, -1, 1).Select(x => Math.Pow(2, (double)x)) },
+//        { "eps", ValueGenerator.GenerateSteps(-8m, -1, 1).Select(x => Math.Pow(2, (double)x)) },
+        { "nu" , ValueGenerator.GenerateSteps(-10m, 0, 1m).Select(x => Math.Pow(2, (double)x)) },
+//        { "degree", ValueGenerator.GenerateSteps(1m, 4, 1).Select(x => (double)x) }
+  };
+
+  static Dictionary<int, string> svmTypes = new Dictionary<int, string> {
+    { svm_parameter.NU_SVR, "NU_SVR" },
+    { svm_parameter.EPSILON_SVR, "EPSILON_SVR" }
+  };
+
+  static Dictionary<int, string> kernelTypes = new Dictionary<int, string> {
+    { svm_parameter.LINEAR, "LINEAR" },
+    { svm_parameter.POLY, "POLY" },
+    { svm_parameter.RBF, "RBF" },
+    { svm_parameter.SIGMOID, "SIGMOID" }
+  };
+
+  private static SupportVectorRegressionSolution SvmGridSearch(IRegressionProblemData problemData, out svm_parameter bestParameters, out int nSv, out double cvMse) {
+    bestParameters = SupportVectorMachineUtil.GridSearch(out cvMse, problemData, svmParameterRanges, numberOfFolds, shuffleFolds, maximumDegreeOfParallelism);
+    double trainingError, testError;
+    string svmType = svmTypes[bestParameters.svm_type];
+    string kernelType = kernelTypes[bestParameters.kernel_type];
+    var svm_solution = SupportVectorRegression.CreateSupportVectorRegressionSolution(problemData, problemData.AllowedInputVariables, svmType, kernelType,
+                       bestParameters.C, bestParameters.nu, bestParameters.gamma, bestParameters.eps, bestParameters.degree, out trainingError, out testError, out nSv);
+    return svm_solution;
+  }
+
+  public override void Main() {
+    var variables = (Variables)vars;
+    var item = variables.SingleOrDefault(x => x.Value is IRegressionProblem || x.Value is IRegressionProblemData);
+    if (item.Equals(default(KeyValuePair<string, object>)))
+      throw new ArgumentException("Could not find a suitable problem or problem data.");
+
+    string name = item.Key;
+    IRegressionProblemData problemData;
+    if (item.Value is IRegressionProblem)
+      problemData = ((IRegressionProblem)item.Value).ProblemData;
+    else
+      problemData = (IRegressionProblemData)item.Value;
+
+    int nSv; // number of support vectors
+    double cvMse;
+    svm_parameter bestParameters;
+    var bestSolution = SvmGridSearch(problemData, out bestParameters, out nSv, out cvMse);
+
+    vars["bestSolution"] = bestSolution;
+    Console.WriteLine(name + " parameters: C = {0}, g = {1:0.000}, eps = {2:0.000}, nu = {3:0.000}, degree = {4}", bestParameters.C, bestParameters.gamma, bestParameters.eps, bestParameters.nu, bestParameters.degree);
+    Console.WriteLine(name + " best solution mse (training): " + bestSolution.TrainingMeanSquaredError + ", mse (test): " + bestSolution.TestMeanSquaredError);
+    Console.WriteLine(name + " best solution R2 (training): " + bestSolution.TrainingRSquared + ", R2 (test): " + bestSolution.TestRSquared);
+
+    var bestParametersCollection = new ParameterCollection();
+    foreach (var p in svmParameterRanges.Keys) {
+      var getter = GenerateGetter(p);
+      bestParametersCollection.Add(new FixedValueParameter<DoubleValue>(p, new DoubleValue(getter(bestParameters))));
+    }
+    vars["bestParameters"] = bestParametersCollection;
+  }
+
+  private static Func<svm_parameter, double> GenerateGetter(string field) {
+    var paramExpr = Expression.Parameter(typeof(svm_parameter));
+    var getterExpr = Expression.Convert(Expression.Field(paramExpr, field), typeof(double)); // cast to double
+    Func<svm_parameter, double> f = Expression.Lambda<Func<svm_parameter, double>>(getterExpr, paramExpr).Compile();
+    return f;
+  }
+}
+
Index: branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/OSGA_Rastrigin_Script.cs
===================================================================
--- branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/OSGA_Rastrigin_Script.cs	(revision 11677)
+++ branches/ALPS/HeuristicLab.Tests/Test Resources/Script Sources/OSGA_Rastrigin_Script.cs	(revision 11677)
@@ -0,0 +1,111 @@
+﻿using System;
+using System.Linq;
+
+public class OSGARastriginScript : HeuristicLab.Scripting.CSharpScriptBase {
+  public override void Main() {
+    int N = vars.N.Value;
+    double minX = vars.minX.Value;
+    double maxX = vars.maxX.Value;
+    int seed = vars.seed.Value;
+    var rand = new Random(seed);
+
+    var result = OSGA(rand, popSize: 1000, iterations: 5000, maxSelPres: 1000, mutationRate: 0.1,
+         obj: Rastrigin,
+      // x ~(i.i.d) U(0,1) * 10.24 - 5.12
+         creator: () => Enumerable.Range(1, N).Select(_ => rand.NextDouble() * (maxX - minX) + minX).ToArray(),
+      // random parent selection
+         selector: (f) => rand.Next(f.Length),
+      // single point crossover
+         crossover: (p0, p1, cand) => {
+           int cut = rand.Next(cand.Length);
+           Array.Copy(p0, cand, cut);
+           Array.Copy(p1, cut, cand, cut, cand.Length - cut);
+         },
+      // single point manipulation
+         manipulator: (p) => p[rand.Next(N)] = rand.NextDouble() * (maxX - minX) + minX,
+         output: true
+      );
+
+    double bestFit = result.Item2;
+    vars.bestFitness = bestFit;
+    Console.WriteLine("best fitness: {0}", bestFit);
+  }
+
+  private double Rastrigin(double[] x) {
+    return 10.0 * x.Length + x.Sum(xi => xi * xi - 10.0 * Math.Cos(2.0 * Math.PI * xi));
+  }
+
+  private Tuple<T, double> OSGA<T>(Random rand, int popSize, int iterations, double maxSelPres, double mutationRate, Func<T, double> obj,
+      Func<T> creator, Func<double[], int> selector, Action<T, T, T> crossover, Action<T> manipulator,
+      bool output = false)
+      where T : ICloneable {
+    // generate random pop
+    T[] pop = Enumerable.Range(0, popSize).Select(_ => creator()).ToArray();
+    // evaluate initial pop
+    double[] fit = pop.Select(p => obj(p)).ToArray();
+
+    // arrays for next pop (clone current pop because solutions are reused)
+    T[] popNew = pop.Select(pi => (T)pi.Clone()).ToArray();
+    double[] fitNew = new double[popSize];
+
+    var bestSolution = (T)pop.First().Clone(); // take a random solution (don't care)
+    double bestFit = fit.First();
+
+    // run generations
+    double curSelPres = 0;
+    for (int g = 0; g < iterations && curSelPres < maxSelPres; g++) {
+      // keep the first element as elite
+      int i = 1;
+      int genEvals = 0;
+      do {
+        var p1Idx = selector(fit);
+        var p2Idx = selector(fit);
+
+        var p1 = pop[p1Idx];
+        var p2 = pop[p2Idx];
+        var f1 = fit[p1Idx];
+        var f2 = fit[p2Idx];
+
+        // generate candidate solution (reuse old solutions)
+        crossover(p1, p2, popNew[i]);
+        // optional mutation
+        if (rand.NextDouble() < mutationRate) {
+          manipulator(popNew[i]);
+        }
+
+        double f = obj(popNew[i]);
+        genEvals++;
+        // if child is better than best (strict offspring selection)
+        if (f < Math.Min(f1, f2)) {
+          // update best fitness
+          if (f < bestFit) {
+            bestFit = f;
+            bestSolution = (T)popNew[i].Clone(); // overall best
+          }
+
+          // keep
+          fitNew[i] = f;
+          i++;
+        }
+
+        curSelPres = genEvals / (double)popSize;
+      } while (i < popNew.Length && curSelPres < maxSelPres);
+
+      Console.WriteLine("generation {0} obj {1:0.000} sel. pres. {2:###.0}", g, bestFit, curSelPres);
+
+      // swap 
+      var tmpPop = pop;
+      var tmpFit = fit;
+      pop = popNew;
+      fit = fitNew;
+      popNew = tmpPop;
+      fitNew = tmpFit;
+
+      // keep elite
+      popNew[0] = (T)bestSolution.Clone();
+      fitNew[0] = bestFit;
+    }
+
+    return Tuple.Create(bestSolution, bestFit);
+  }
+}
Index: branches/ALPS/HeuristicLab.Tests/app.config
===================================================================
--- branches/ALPS/HeuristicLab.Tests/app.config	(revision 11507)
+++ branches/ALPS/HeuristicLab.Tests/app.config	(revision 11677)
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <configSections>
-    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
-      <section name="HeuristicLab.PluginInfrastructure.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+      <section name="HeuristicLab.PluginInfrastructure.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
     </sectionGroup>
   </configSections>
@@ -30,35 +30,19 @@
     <bindings>
       <wsHttpBinding>
-        <binding name="WSHttpBinding_IUpdateService" closeTimeout="00:01:00"
-          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
-          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
-          maxBufferPoolSize="524288" maxReceivedMessageSize="200000000" messageEncoding="Text"
-          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
-          <readerQuotas maxDepth="32" maxStringContentLength="32000" maxArrayLength="200000000"
-            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
-          <reliableSession ordered="true" inactivityTimeout="00:10:00"
-            enabled="false" />
+        <binding name="WSHttpBinding_IUpdateService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="200000000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
+          <readerQuotas maxDepth="32" maxStringContentLength="32000" maxArrayLength="200000000" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
+          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
           <security mode="Message">
-            <transport clientCredentialType="Windows" proxyCredentialType="None"
-              realm="" />
-            <message clientCredentialType="UserName" negotiateServiceCredential="true"
-              algorithmSuite="Default" />
+            <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
+            <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default"/>
           </security>
         </binding>
 
-        <binding name="WSHttpBinding_IAdminService" closeTimeout="00:01:00"
-          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
-          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
-          maxBufferPoolSize="524288" maxReceivedMessageSize="200000000" messageEncoding="Text"
-          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
-          <readerQuotas maxDepth="32" maxStringContentLength="32000" maxArrayLength="200000000"
-            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
-          <reliableSession ordered="true" inactivityTimeout="00:10:00"
-            enabled="false" />
+        <binding name="WSHttpBinding_IAdminService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="200000000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
+          <readerQuotas maxDepth="32" maxStringContentLength="32000" maxArrayLength="200000000" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
+          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
           <security mode="Message">
-            <transport clientCredentialType="Windows" proxyCredentialType="None"
-              realm="" />
-            <message clientCredentialType="UserName" negotiateServiceCredential="true"
-              algorithmSuite="Default" />
+            <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
+            <message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default"/>
           </security>
         </binding>
@@ -67,21 +51,15 @@
 
     <client>
-      <endpoint address="http://services.heuristiclab.com/Deployment-3.3/UpdateService.svc"
-        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUpdateService"
-        contract="HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.IUpdateService"
-        name="WSHttpBinding_IUpdateService">
+      <endpoint address="http://services.heuristiclab.com/Deployment-3.3/UpdateService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUpdateService" contract="HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.IUpdateService" name="WSHttpBinding_IUpdateService">
         <identity>
-          <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ==" />
+          <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ=="/>
         </identity>
       </endpoint>
-      <endpoint address="http://services.heuristiclab.com/Deployment-3.3/AdminService.svc"
-        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAdminService"
-        contract="HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.IAdminService"
-        name="WSHttpBinding_IAdminService">
+      <endpoint address="http://services.heuristiclab.com/Deployment-3.3/AdminService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAdminService" contract="HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.IAdminService" name="WSHttpBinding_IAdminService">
         <identity>
-          <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ==" />
+          <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ=="/>
         </identity>
       </endpoint>
     </client>
   </system.serviceModel>
-</configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
