Index: /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/EfficientGlobalOptimizationAlgorithm.cs
===================================================================
--- /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/EfficientGlobalOptimizationAlgorithm.cs	(revision 14832)
+++ /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/EfficientGlobalOptimizationAlgorithm.cs	(revision 14833)
@@ -69,4 +69,5 @@
     private const string InitialSamplesParameterName = "InitialSamplesFile";
     private const string BaselineVectorParameterName = "BaselineVector";
+    private const string InitialSamplingPlanParamterName = "InitialSamplingPlan";
     #endregion
 
@@ -101,8 +102,7 @@
     public IFixedValueParameter<IntValue> MaximalDataSetSizeParameter => Parameters[MaximalDataSetSizeParameterName] as IFixedValueParameter<IntValue>;
     public IFixedValueParameter<BoolValue> RemoveDuplicatesParameter => Parameters[RemoveDuplicatesParamterName] as IFixedValueParameter<BoolValue>;
-
     public IFixedValueParameter<FileValue> InitialSamplesParameter => Parameters[InitialSamplesParameterName] as IFixedValueParameter<FileValue>;
-
     public IValueParameter<RealVector> BaselineVectorParameter => Parameters[BaselineVectorParameterName] as IValueParameter<RealVector>;
+    public IConstrainedValueParameter<IInitialSampling> InitialSamplingPlanParameter => Parameters[InitialSamplingPlanParamterName] as IConstrainedValueParameter<IInitialSampling>;
     #endregion
 
@@ -126,4 +126,5 @@
     private bool RemoveDuplicates => RemoveDuplicatesParameter.Value.Value;
     private RealVector BaselineVector => BaselineVectorParameter.Value;
+    private IInitialSampling InitialSamplingPlan => InitialSamplingPlanParameter.Value;
     #endregion
 
@@ -198,5 +199,5 @@
       Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluationsParameterName, "", new IntValue(int.MaxValue)));
       Parameters.Add(new FixedValueParameter<IntValue>(InitialEvaluationsParameterName, "", new IntValue(10)));
-      Parameters.Add(new FixedValueParameter<IntValue>(MaximumRuntimeParameterName, "The maximum runtime in seconds after which the algorithm stops. Use -1 to specify no limit for the runtime", new IntValue(3600)));
+      Parameters.Add(new FixedValueParameter<IntValue>(MaximumRuntimeParameterName, "The maximum runtime in seconds after which the algorithm stops. Use -1 to specify no limit for the runtime", new IntValue(-1)));
       Parameters.Add(new FixedValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
       Parameters.Add(new FixedValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
@@ -206,6 +207,6 @@
       Parameters.Add(new FixedValueParameter<IntValue>(GenerationSizeParameterName, "Number points that are sampled every iteration (stadard EGO: 1)", new IntValue(1)));
       Parameters.Add(new ConstrainedValueParameter<IInfillCriterion>(InfillCriterionParameterName, "Decision what value should decide the next sample"));
+      InfillCriterionParameter.ValidValues.Add(new ExpectedImprovement());
       InfillCriterionParameter.ValidValues.Add(new AugmentedExpectedImprovement());
-      InfillCriterionParameter.ValidValues.Add(new ExpectedImprovement());
       InfillCriterionParameter.ValidValues.Add(new ExpectedQuality());
       var eqi = new ExpectedQuantileImprovement();
@@ -219,4 +220,7 @@
       Parameters.Add(new FixedValueParameter<FileValue>(InitialSamplesParameterName, "The file specifying some initial samples used to jump start the algorithm. These samples are not counted as evaluations. If InitialEvaluations is more than the samples specified in the file, the rest is uniformly random generated and evaluated.", new FileValue()));
       Parameters.Add(new ValueParameter<RealVector>(BaselineVectorParameterName, "A vector used to create a baseline, this vector is evaluated once and is not part of the modeling process (has no influence on algorithm performance)"));
+      var intialSamplingPlans = new ItemSet<IInitialSampling> { new UniformRandomSampling(), new LatinHyperCubeDesign() };
+      Parameters.Add(new ConstrainedValueParameter<IInitialSampling>(InitialSamplingPlanParamterName, intialSamplingPlans, intialSamplingPlans.First()));
+
       SetInfillProblem();
       RegisterEventhandlers();
@@ -237,5 +241,5 @@
       if (SetSeedRandomly) SeedParameter.Value.Value = new System.Random().Next();
       Random.Reset(Seed);
-      Samples = InitialSamples == null ? new List<Tuple<RealVector, double>>() : InitialSamples.ToList();
+      Samples = InitialSamples?.ToList() ?? new List<Tuple<RealVector, double>>();
 
       //results
@@ -250,20 +254,25 @@
       table.Rows.Add(new DataRow(CurrentQualitiesRowResultName));
       Results.Add(new Result(QualitiesChartResultName, table));
-      if (BaselineVector != null && BaselineVector.Length == enc.Length)
-        Results.Add(new Result("BaselineValue", new DoubleValue(Evaluate(BaselineVector).Item2)));
-
+      if (BaselineVector != null && BaselineVector.Length == enc.Length) Results.Add(new Result("BaselineValue", new DoubleValue(Evaluate(BaselineVector).Item2)));
+
+
+
+    }
+
+    protected override void Run(CancellationToken cancellationToken) {
       //initial samples
       if (Samples.Count < InitialEvaluations) {
-        var points = EgoUtilities.GetUniformRandomDesign(InitialEvaluations - Samples.Count, enc.Length, enc.Bounds, Random);
+        var points = InitialSamplingPlan.GetSamples(InitialEvaluations - Samples.Count, Samples.Select(x => x.Item1).ToArray(), (RealVectorEncoding)Problem.Encoding, Random);
         foreach (var t in points) {
-          Samples.Add(Evaluate(t));
-          cancellationToken.ThrowIfCancellationRequested();
+          try {
+            Samples.Add(Evaluate(t));
+            cancellationToken.ThrowIfCancellationRequested();
+          }
+          finally {
+            Analyze();
+          }
         }
       }
-
-      Analyze();
-    }
-
-    protected override void Run(CancellationToken cancellationToken) {
+      //adaptive samples
       for (ResultsIterations = 0; ResultsEvaluations < MaximumEvaluations; ResultsIterations++) {
         try {
@@ -484,4 +493,19 @@
       ResultsQualitiesWorst.Values.Add(Samples[Problem.Maximization ? min : max].Item2);
       Problem.Analyze(Samples.Select(x => GetIndividual(x.Item1)).ToArray(), Samples.Select(x => x.Item2).ToArray(), Results, Random);
+
+      if (Samples.Count != 0 && Samples[0].Item1.Length == 2) {
+        var plotname = "DEBUG:Sample Distribution";
+        var rowInit = "Initial Samples";
+        var rowAll = "All Samples";
+        if (!Results.ContainsKey(plotname)) Results.Add(new Result(plotname, new ScatterPlot()));
+        var plot = Results[plotname].Value as ScatterPlot;
+        if (!plot.Rows.ContainsKey(rowInit) && InitialSamples != null && InitialSamples.Count > 0)
+          plot.Rows.Add(new ScatterPlotDataRow(rowInit, "samples from inital file (already evaulated)", InitialSamples.Select(x => new Point2D<double>(x.Item1[0], x.Item1[1]))));
+        if (!plot.Rows.ContainsKey(rowAll)) plot.Rows.Add(new ScatterPlotDataRow(rowAll, "All samples", new Point2D<double>[0]));
+        else { plot.Rows[rowAll].Points.Clear(); }
+        plot.Rows[rowAll].Points.AddRange(Samples.Select(x => new Point2D<double>(x.Item1[0], x.Item1[1])));
+
+
+      }
     }
     private Individual GetIndividual(RealVector r) {
Index: /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/EgoUtilities.cs
===================================================================
--- /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/EgoUtilities.cs	(revision 14832)
+++ /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/EgoUtilities.cs	(revision 14833)
@@ -25,5 +25,4 @@
 using System.Threading;
 using HeuristicLab.Common;
-using HeuristicLab.Core;
 using HeuristicLab.Data;
 using HeuristicLab.Encodings.RealVectorEncoding;
@@ -76,19 +75,4 @@
       if (ex != null) throw ex;
       return alg.Results;
-    }
-    public static RealVector[] GetUniformRandomDesign(int points, int dim, DoubleMatrix bounds, IRandom random) {
-      var res = new RealVector[points];
-      for (var i = 0; i < points; i++) {
-        var r = new RealVector(dim);
-        res[i] = r;
-        for (var j = 0; j < dim; j++) {
-          var b = j % bounds.Rows;
-          r[j] = UniformRandom(bounds[b, 0], bounds[b, 1], random);
-        }
-      }
-      return res;
-    }
-    public static double UniformRandom(double min, double max, IRandom rand) {
-      return rand.NextDouble() * (max - min) + min;
     }
 
Index: /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/HeuristicLab.Algorithms.EGO-3.4.csproj
===================================================================
--- /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/HeuristicLab.Algorithms.EGO-3.4.csproj	(revision 14832)
+++ /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/HeuristicLab.Algorithms.EGO-3.4.csproj	(revision 14833)
@@ -38,4 +38,8 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.DataAnalysis-3.4.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Algorithms.EvolutionStrategy-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.EvolutionStrategy-3.3.dll</HintPath>
     </Reference>
     <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
@@ -125,4 +129,5 @@
     <Compile Include="InfillCriteria\InfillCriterionBase.cs" />
     <Compile Include="InfillCriteria\ExpectedImprovement.cs" />
+    <Compile Include="Interfaces\IInitialSampling.cs" />
     <Compile Include="Interfaces\ISurrogateAlgorithm.cs" />
     <Compile Include="Interfaces\IInfillCriterion.cs" />
@@ -130,4 +135,6 @@
     <Compile Include="Problems\InfillProblem.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="SamplingMethods\LatinHyperCubeDesign.cs" />
+    <Compile Include="SamplingMethods\UniformRandomSampling.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -135,5 +142,7 @@
     <None Include="Properties\AssemblyInfo.cs.frame" />
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <WCFMetadata Include="Service References\" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
Index: /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/Interfaces/IInitialSampling.cs
===================================================================
--- /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/Interfaces/IInitialSampling.cs	(revision 14833)
+++ /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/Interfaces/IInitialSampling.cs	(revision 14833)
@@ -0,0 +1,30 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+// ReSharper disable once CheckNamespace
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.RealVectorEncoding;
+
+namespace HeuristicLab.Algorithms.EGO {
+  public interface IInitialSampling : INamedItem {
+    RealVector[] GetSamples(int noSamples, RealVector[] existingSamples, RealVectorEncoding encoding, IRandom random);
+  }
+}
Index: /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/SamplingMethods/LatinHyperCubeDesign.cs
===================================================================
--- /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/SamplingMethods/LatinHyperCubeDesign.cs	(revision 14833)
+++ /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/SamplingMethods/LatinHyperCubeDesign.cs	(revision 14833)
@@ -0,0 +1,144 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.RealVectorEncoding;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+// ReSharper disable once CheckNamespace
+namespace HeuristicLab.Algorithms.EGO {
+
+  [StorableClass]
+  [Item("LatinHyperCubeDesign", "A latin hypercube sampling strategy for real valued optimization")]
+  public class LatinHyperCubeDesign : ParameterizedNamedItem, IInitialSampling {
+
+    public const string DesigningAlgorithmParamterName = "DesignningAlgorithm";
+    public IValueParameter<IAlgorithm> DesigningAlgorithmParameter => Parameters[DesigningAlgorithmParamterName] as IValueParameter<IAlgorithm>;
+    private IAlgorithm DesigningAlgorithm => DesigningAlgorithmParameter.Value;
+
+    [StorableConstructor]
+    private LatinHyperCubeDesign(bool deserializing) : base(deserializing) { }
+    private LatinHyperCubeDesign(LatinHyperCubeDesign original, Cloner cloner) : base(original, cloner) { }
+    public LatinHyperCubeDesign() {
+      var es = new EvolutionStrategy.EvolutionStrategy {
+        PopulationSize = { Value = 50 },
+        Children = { Value = 100 },
+        MaximumGenerations = { Value = 300 }
+      };
+      Parameters.Add(new ValueParameter<IAlgorithm>(DesigningAlgorithmParamterName, "The Algorithm used for optimizing the Latin Hypercube (minimax) criterion.", es));
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new LatinHyperCubeDesign(this, cloner);
+    }
+
+    public RealVector[] GetSamples(int noSamples, RealVector[] existingSamples, RealVectorEncoding encoding, IRandom random) {
+      var lhsprob = new LHSProblem(noSamples, existingSamples, encoding);
+      DesigningAlgorithm.Problem = lhsprob;
+      EgoUtilities.SyncRunSubAlgorithm(DesigningAlgorithm, random.Next());
+      return lhsprob.BestSolution;
+    }
+  }
+
+  [StorableClass]
+  internal class LHSProblem : SingleObjectiveBasicProblem<RealVectorEncoding> {
+    [Storable]
+    private int NoVectors;
+    [Storable]
+    private int NoDimensions;
+    [Storable]
+    private RealVector[] ExistingSamples;
+
+    [Storable]
+    public double BestQuality = double.MinValue;
+    [Storable]
+    public RealVector[] BestSolution;
+
+    [StorableConstructor]
+    private LHSProblem(bool deserializing) : base(deserializing) { }
+
+    private LHSProblem(LHSProblem original, Cloner cloner) : base(original, cloner) {
+      NoDimensions = original.NoDimensions;
+      NoVectors = original.NoVectors;
+      ExistingSamples = original.ExistingSamples?.Select(cloner.Clone).ToArray();
+    }
+
+    public LHSProblem(int novectors, RealVector[] existingSamples, RealVectorEncoding encoding) {
+      NoVectors = novectors;
+      NoDimensions = encoding.Length;
+      ExistingSamples = existingSamples;
+      Encoding.Length = novectors * encoding.Length;
+      var b = new DoubleMatrix(Encoding.Length, 2);
+      for (int i = 0; i < novectors; i++) {
+        for (int j = 0; j < encoding.Length; j++) {
+          var k = j % encoding.Bounds.Rows;
+          b[i * encoding.Length + j, 0] = encoding.Bounds[k, 0];
+          b[i * encoding.Length + j, 1] = encoding.Bounds[k, 1];
+        }
+      }
+      Encoding.Bounds = b;
+
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new LHSProblem(this, cloner);
+    }
+
+    public override double Evaluate(Individual individual, IRandom random) {
+      return Enumerable.Range(0, NoVectors).Select(x => MinDistance(x, individual.RealVector())).Min();
+    }
+
+    //returns -1 if no distance can be calculated
+    private double MinDistance(int pointNumber, RealVector design) {
+      var min = double.MaxValue;
+      if (ExistingSamples != null && ExistingSamples.Length != 0) min = ExistingSamples.Select(x => Distance(x, ExtractPoint(pointNumber, design))).Min();
+      if (pointNumber == 0) return min;
+      var min2 = Enumerable.Range(0, pointNumber).Select(i => Distance(ExtractPoint(i, design), ExtractPoint(pointNumber, design))).Min();
+      return min < 0 ? min2 : Math.Min(min, min2);
+    }
+    private IEnumerable<double> ExtractPoint(int pointNumber, RealVector design) {
+      return design.Skip(NoDimensions * pointNumber).Take(NoDimensions);
+    }
+    private static double Distance(IEnumerable<double> a, IEnumerable<double> b) {
+      return a.Zip(b, (d, d1) => d - d1).Sum(d => d * d);
+    }
+
+    public override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
+      base.Analyze(individuals, qualities, results, random);
+      var i = qualities.ArgMin(x => x);
+      if (BestQuality > qualities[i]) return;
+      var r = individuals[i].RealVector();
+      BestSolution = Enumerable.Range(0, NoVectors).Select(x => new RealVector(ExtractPoint(x, r).ToArray())).ToArray();
+    }
+
+    public override bool Maximization => true;
+  }
+
+
+
+
+}
+
Index: /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/SamplingMethods/UniformRandomSampling.cs
===================================================================
--- /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/SamplingMethods/UniformRandomSampling.cs	(revision 14833)
+++ /branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/SamplingMethods/UniformRandomSampling.cs	(revision 14833)
@@ -0,0 +1,68 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Encodings.RealVectorEncoding;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+// ReSharper disable once CheckNamespace
+namespace HeuristicLab.Algorithms.EGO {
+
+  [StorableClass]
+  [Item("UniformRandomSampling", "A uniform random sampling strategy for real valued optimization")]
+  public class UniformRandomSampling : ParameterizedNamedItem, IInitialSampling {
+
+    #region HL-Constructors, Serialization and Cloning 
+    [StorableConstructor]
+    private UniformRandomSampling(bool deserializing) : base(deserializing) { }
+    private UniformRandomSampling(UniformRandomSampling original, Cloner cloner) : base(original, cloner) { }
+    public UniformRandomSampling() {
+    }
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new UniformRandomSampling(this, cloner);
+    }
+
+    public RealVector[] GetSamples(int noSamples, RealVector[] existingSamples, RealVectorEncoding encoding, IRandom random) {
+      var res = new RealVector[noSamples];
+      for (var i = 0; i < noSamples; i++) {
+        var r = new RealVector(encoding.Length);
+        res[i] = r;
+        for (var j = 0; j < encoding.Length; j++) {
+          var b = j % encoding.Bounds.Rows;
+          r[j] = UniformRandom(encoding.Bounds[b, 0], encoding.Bounds[b, 1], random);
+        }
+      }
+      return res;
+    }
+    private static double UniformRandom(double min, double max, IRandom rand) {
+      return rand.NextDouble() * (max - min) + min;
+    }
+  }
+
+
+
+
+  #endregion
+
+
+}
+
