Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2780_SAPBA/SAPBA.patch @ 18092

Last change on this file since 18092 was 16108, checked in by bwerth, 6 years ago

#2780 renamed branch to include ticket number

File size: 76.1 KB
RevLine 
[16108]1Index: .
2===================================================================
3--- . (revision 15449)
4+++ . (working copy)
5
6Property changes on: .
7___________________________________________________________________
8Added: svn:global-ignores
9## -0,0 +1 ##
10+.vs
11Added: svn:ignore
12## -0,0 +1 ##
13+.vs
14Index: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
15===================================================================
16Cannot display: file marked as a binary type.
17svn:mime-type = application/octet-stream
18Index: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
19===================================================================
20--- .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo  (revision 15449)
21+++ .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo  (nonexistent)
22
23Property changes on: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
24___________________________________________________________________
25Deleted: svn:mime-type
26## -1 +0,0 ##
27-application/octet-stream
28\ No newline at end of property
29Index: .vs/Sliding Window GP/v14/.suo
30===================================================================
31Cannot display: file marked as a binary type.
32svn:mime-type = application/octet-stream
33Index: .vs/Sliding Window GP/v14/.suo
34===================================================================
35--- .vs/Sliding Window GP/v14/.suo  (revision 15449)
36+++ .vs/Sliding Window GP/v14/.suo  (nonexistent)
37
38Property changes on: .vs/Sliding Window GP/v14/.suo
39___________________________________________________________________
40Deleted: svn:mime-type
41## -1 +0,0 ##
42-application/octet-stream
43\ No newline at end of property
44Index: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
45===================================================================
46Cannot display: file marked as a binary type.
47svn:mime-type = application/octet-stream
48Index: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
49===================================================================
50--- .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo  (revision 15449)
51+++ .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo  (nonexistent)
52
53Property changes on: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
54___________________________________________________________________
55Deleted: svn:mime-type
56## -1 +0,0 ##
57-application/octet-stream
58\ No newline at end of property
59Index: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
60===================================================================
61Cannot display: file marked as a binary type.
62svn:mime-type = application/octet-stream
63Index: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
64===================================================================
65--- .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo  (revision 15449)
66+++ .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo  (nonexistent)
67
68Property changes on: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
69___________________________________________________________________
70Deleted: svn:mime-type
71## -1 +0,0 ##
72-application/octet-stream
73\ No newline at end of property
74Index: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
75===================================================================
76Cannot display: file marked as a binary type.
77svn:mime-type = application/octet-stream
78Index: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
79===================================================================
80--- .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo  (revision 15449)
81+++ .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo  (nonexistent)
82
83Property changes on: .vs/HeuristicLab.Algorithms.SAPBA/v14/.suo
84___________________________________________________________________
85Deleted: svn:mime-type
86## -1 +0,0 ##
87-application/octet-stream
88\ No newline at end of property
89Index: .vs/Sliding Window GP/v14/.suo
90===================================================================
91Cannot display: file marked as a binary type.
92svn:mime-type = application/octet-stream
93Index: .vs/Sliding Window GP/v14/.suo
94===================================================================
95--- .vs/Sliding Window GP/v14/.suo  (revision 15449)
96+++ .vs/Sliding Window GP/v14/.suo  (nonexistent)
97
98Property changes on: .vs/Sliding Window GP/v14/.suo
99___________________________________________________________________
100Deleted: svn:mime-type
101## -1 +0,0 ##
102-application/octet-stream
103\ No newline at end of property
104Index: .vs/Sliding Window GP/v14/.suo
105===================================================================
106Cannot display: file marked as a binary type.
107svn:mime-type = application/octet-stream
108Index: .vs/Sliding Window GP/v14/.suo
109===================================================================
110--- .vs/Sliding Window GP/v14/.suo  (revision 15449)
111+++ .vs/Sliding Window GP/v14/.suo  (nonexistent)
112
113Property changes on: .vs/Sliding Window GP/v14/.suo
114___________________________________________________________________
115Deleted: svn:mime-type
116## -1 +0,0 ##
117-application/octet-stream
118\ No newline at end of property
119Index: .vs/Sliding Window GP/v14/.suo
120===================================================================
121Cannot display: file marked as a binary type.
122svn:mime-type = application/octet-stream
123Index: .vs/Sliding Window GP/v14/.suo
124===================================================================
125--- .vs/Sliding Window GP/v14/.suo  (revision 15449)
126+++ .vs/Sliding Window GP/v14/.suo  (nonexistent)
127
128Property changes on: .vs/Sliding Window GP/v14/.suo
129___________________________________________________________________
130Deleted: svn:mime-type
131## -1 +0,0 ##
132-application/octet-stream
133\ No newline at end of property
134Index: HeuristicLab.Algorithms.SAPBA/HeuristicLab.Algorithms.SAPBA-3.4.csproj
135===================================================================
136--- HeuristicLab.Algorithms.SAPBA/HeuristicLab.Algorithms.SAPBA-3.4.csproj  (revision 15449)
137+++ HeuristicLab.Algorithms.SAPBA/HeuristicLab.Algorithms.SAPBA-3.4.csproj  (working copy)
138@@ -30,22 +30,22 @@
139     <WarningLevel>4</WarningLevel>
140   </PropertyGroup>
141   <ItemGroup>
142-    <Reference Include="HeuristicLab.Algorithms.CMAEvolutionStrategy-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
143-      <SpecificVersion>False</SpecificVersion>
144-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.CMAEvolutionStrategy-3.4.dll</HintPath>
145-    </Reference>
146     <Reference Include="HeuristicLab.Algorithms.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
147       <SpecificVersion>False</SpecificVersion>
148       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.DataAnalysis-3.4.dll</HintPath>
149     </Reference>
150-    <Reference Include="HeuristicLab.Algorithms.EvolutionStrategy-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
151+    <Reference Include="HeuristicLab.Algorithms.EGO-3.4, Version=3.4.0.0, Culture=neutral, processorArchitecture=MSIL">
152       <SpecificVersion>False</SpecificVersion>
153-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.EvolutionStrategy-3.3.dll</HintPath>
154+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.EGO-3.4.dll</HintPath>
155     </Reference>
156     <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
157       <SpecificVersion>False</SpecificVersion>
158       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath>
159     </Reference>
160+    <Reference Include="HeuristicLab.Algorithms.OffspringSelectionEvolutionStrategy-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
161+      <SpecificVersion>False</SpecificVersion>
162+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.OffspringSelectionEvolutionStrategy-3.3.dll</HintPath>
163+    </Reference>
164     <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
165       <SpecificVersion>False</SpecificVersion>
166       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
167@@ -58,10 +58,6 @@
168       <SpecificVersion>False</SpecificVersion>
169       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
170     </Reference>
171-    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
172-      <SpecificVersion>False</SpecificVersion>
173-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
174-    </Reference>
175     <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
176       <SpecificVersion>False</SpecificVersion>
177       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
178@@ -74,7 +70,10 @@
179       <SpecificVersion>False</SpecificVersion>
180       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath>
181     </Reference>
182-    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec" />
183+    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
184+      <SpecificVersion>False</SpecificVersion>
185+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
186+    </Reference>
187     <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
188       <SpecificVersion>False</SpecificVersion>
189       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
190@@ -99,18 +98,6 @@
191       <SpecificVersion>False</SpecificVersion>
192       <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
193     </Reference>
194-    <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
195-      <SpecificVersion>False</SpecificVersion>
196-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath>
197-    </Reference>
198-    <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
199-      <SpecificVersion>False</SpecificVersion>
200-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3.dll</HintPath>
201-    </Reference>
202-    <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
203-      <SpecificVersion>False</SpecificVersion>
204-      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
205-    </Reference>
206     <Reference Include="System" />
207     <Reference Include="System.Core" />
208     <Reference Include="System.Windows.Forms" />
209@@ -122,9 +109,10 @@
210     <Reference Include="System.Xml" />
211   </ItemGroup>
212   <ItemGroup>
213-    <Compile Include="EgoUtilities.cs" />
214-    <Compile Include="Strategies\IndividualStrategy.cs" />
215-    <Compile Include="Strategies\GenerationalStrategy.cs" />
216+    <Compile Include="Operators\FixedSolutionCreator.cs" />
217+    <Compile Include="SapbaUtilities.cs" />
218+    <Compile Include="Strategies\LamarckianStrategy.cs" />
219+    <Compile Include="Strategies\InfillStrategy.cs" />
220     <Compile Include="SurrogateAssistedPopulationBasedAlgorithm.cs" />
221     <Compile Include="Interfaces\ISurrogateStrategy.cs" />
222     <Compile Include="Interfaces\ISurrogateAlgorithm.cs" />
223Index: HeuristicLab.Algorithms.SAPBA/Interfaces/ISurrogateStrategy.cs
224===================================================================
225--- HeuristicLab.Algorithms.SAPBA/Interfaces/ISurrogateStrategy.cs  (revision 15449)
226+++ HeuristicLab.Algorithms.SAPBA/Interfaces/ISurrogateStrategy.cs  (working copy)
227@@ -19,7 +19,6 @@
228  */
229 #endregion
230 
231-using System.Threading;
232 using HeuristicLab.Core;
233 using HeuristicLab.Encodings.RealVectorEncoding;
234 using HeuristicLab.Optimization;
235@@ -29,6 +28,6 @@
236     double Evaluate(RealVector r, IRandom random);
237     void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random);
238     void Initialize(SurrogateAssistedPopulationBasedAlgorithm algorithm);
239-    void UpdateCancellation(CancellationToken cancellationToken);
240+    bool Maximization();
241   }
242 }
243Index: HeuristicLab.Algorithms.SAPBA/Operators/FixedSolutionCreator.cs
244===================================================================
245--- HeuristicLab.Algorithms.SAPBA/Operators/FixedSolutionCreator.cs (nonexistent)
246+++ HeuristicLab.Algorithms.SAPBA/Operators/FixedSolutionCreator.cs (working copy)
247@@ -0,0 +1,30 @@
248+using HeuristicLab.Common;
249+using HeuristicLab.Core;
250+using HeuristicLab.Data;
251+using HeuristicLab.Encodings.RealVectorEncoding;
252+using HeuristicLab.Optimization;
253+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
254+
255+namespace HeuristicLab.Algorithms.SAPBA.Operators {
256+  [Item("FixedRealVectorCreator", "An operator which creates a new real vector cloned from a single Point")]
257+  [StorableClass]
258+  public class FixedRealVectorCreator : RealVectorCreator, IStrategyParameterCreator {
259+    [Storable]
260+    private RealVector Point;
261+
262+    [StorableConstructor]
263+    protected FixedRealVectorCreator(bool deserializing) : base(deserializing) { }
264+    protected FixedRealVectorCreator(FixedRealVectorCreator original, Cloner cloner) : base(original, cloner) {
265+      Point = cloner.Clone(original.Point);
266+    }
267+    public FixedRealVectorCreator(RealVector r) : base() {
268+      Point = r;
269+    }
270+    public override IDeepCloneable Clone(Cloner cloner) { return new FixedRealVectorCreator(this, cloner); }
271+    protected override RealVector Create(IRandom random, IntValue length, DoubleMatrix bounds) {
272+      return (RealVector)Point.Clone();
273+    }
274+  }
275+
276+}
277+
278Index: HeuristicLab.Algorithms.SAPBA/Operators/FixedSolutionCreator.cs
279===================================================================
280--- HeuristicLab.Algorithms.SAPBA/Operators/FixedSolutionCreator.cs (nonexistent)
281+++ HeuristicLab.Algorithms.SAPBA/Operators/FixedSolutionCreator.cs (working copy)
282@@ -0,0 +1,30 @@
283+using HeuristicLab.Common;
284+using HeuristicLab.Core;
285+using HeuristicLab.Data;
286+using HeuristicLab.Encodings.RealVectorEncoding;
287+using HeuristicLab.Optimization;
288+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
289+
290+namespace HeuristicLab.Algorithms.SAPBA.Operators {
291+  [Item("FixedRealVectorCreator", "An operator which creates a new real vector cloned from a single Point")]
292+  [StorableClass]
293+  public class FixedRealVectorCreator : RealVectorCreator, IStrategyParameterCreator {
294+    [Storable]
295+    private RealVector Point;
296+
297+    [StorableConstructor]
298+    protected FixedRealVectorCreator(bool deserializing) : base(deserializing) { }
299+    protected FixedRealVectorCreator(FixedRealVectorCreator original, Cloner cloner) : base(original, cloner) {
300+      Point = cloner.Clone(original.Point);
301+    }
302+    public FixedRealVectorCreator(RealVector r) : base() {
303+      Point = r;
304+    }
305+    public override IDeepCloneable Clone(Cloner cloner) { return new FixedRealVectorCreator(this, cloner); }
306+    protected override RealVector Create(IRandom random, IntValue length, DoubleMatrix bounds) {
307+      return (RealVector)Point.Clone();
308+    }
309+  }
310+
311+}
312+
313Index: HeuristicLab.Algorithms.SAPBA/Plugin.cs
314===================================================================
315--- HeuristicLab.Algorithms.SAPBA/Plugin.cs (revision 15449)
316+++ HeuristicLab.Algorithms.SAPBA/Plugin.cs (working copy)
317@@ -25,25 +25,22 @@
318 using HeuristicLab.PluginInfrastructure;
319 
320 namespace HeuristicLab.Algorithms.SAPBA {
321-  [Plugin("HeuristicLab.Algorithms.SAPBA", "3.4.5.14893")]
322+  [Plugin("HeuristicLab.Algorithms.SAPBA", "3.4.5.14894")]
323   [PluginFile("HeuristicLab.Algorithms.SAPBA-3.4.dll", PluginFileType.Assembly)]
324-  [PluginFile("displayModelFrame.html", PluginFileType.Data)]
325-  [PluginDependency("HeuristicLab.Algorithms.CMAEvolutionStrategy", "3.4")]
326   [PluginDependency("HeuristicLab.Algorithms.DataAnalysis", "3.4")]
327+  [PluginDependency("HeuristicLab.Algorithms.EGO", "3.4")]
328+  [PluginDependency("HeuristicLab.Algorithms.GeneticAlgorithm", "3.3")]
329+  [PluginDependency("HeuristicLab.Algorithms.OffspringSelectionEvolutionStrategy", "3.3")]
330   [PluginDependency("HeuristicLab.Analysis", "3.3")]
331   [PluginDependency("HeuristicLab.Collections", "3.3")]
332   [PluginDependency("HeuristicLab.Common", "3.3")]
333-  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
334   [PluginDependency("HeuristicLab.Core", "3.3")]
335   [PluginDependency("HeuristicLab.Data", "3.3")]
336   [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")]
337-  [PluginDependency("HeuristicLab.Operators","3.3")]
338   [PluginDependency("HeuristicLab.Optimization","3.3")]
339   [PluginDependency("HeuristicLab.Parameters","3.3")]
340   [PluginDependency("HeuristicLab.Persistence","3.3")]
341   [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
342-  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
343-  [PluginDependency("HeuristicLab.Random", "3.3")]
344   public class HeuristicLabProblemsDataAnalysisSymbolicViewsPlugin : PluginBase {
345   }
346 }
347Index: HeuristicLab.Algorithms.SAPBA/Plugin.cs.frame
348===================================================================
349--- HeuristicLab.Algorithms.SAPBA/Plugin.cs.frame (revision 15449)
350+++ HeuristicLab.Algorithms.SAPBA/Plugin.cs.frame (working copy)
351@@ -27,23 +27,20 @@
352 namespace HeuristicLab.Algorithms.SAPBA {
353   [Plugin("HeuristicLab.Algorithms.SAPBA", "3.4.5.$WCREV$")]
354   [PluginFile("HeuristicLab.Algorithms.SAPBA-3.4.dll", PluginFileType.Assembly)]
355-  [PluginFile("displayModelFrame.html", PluginFileType.Data)]
356-  [PluginDependency("HeuristicLab.Algorithms.CMAEvolutionStrategy", "3.4")]
357   [PluginDependency("HeuristicLab.Algorithms.DataAnalysis", "3.4")]
358+  [PluginDependency("HeuristicLab.Algorithms.EGO", "3.4")]
359+  [PluginDependency("HeuristicLab.Algorithms.GeneticAlgorithm", "3.3")]
360+  [PluginDependency("HeuristicLab.Algorithms.OffspringSelectionEvolutionStrategy", "3.3")]
361   [PluginDependency("HeuristicLab.Analysis", "3.3")]
362   [PluginDependency("HeuristicLab.Collections", "3.3")]
363   [PluginDependency("HeuristicLab.Common", "3.3")]
364-  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
365   [PluginDependency("HeuristicLab.Core", "3.3")]
366   [PluginDependency("HeuristicLab.Data", "3.3")]
367   [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")]
368-  [PluginDependency("HeuristicLab.Operators","3.3")]
369   [PluginDependency("HeuristicLab.Optimization","3.3")]
370   [PluginDependency("HeuristicLab.Parameters","3.3")]
371   [PluginDependency("HeuristicLab.Persistence","3.3")]
372   [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
373-  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
374-  [PluginDependency("HeuristicLab.Random", "3.3")]
375   public class HeuristicLabProblemsDataAnalysisSymbolicViewsPlugin : PluginBase {
376   }
377 }
378Index: HeuristicLab.Algorithms.SAPBA/Problems/SurrogateProblem.cs
379===================================================================
380--- HeuristicLab.Algorithms.SAPBA/Problems/SurrogateProblem.cs  (revision 15449)
381+++ HeuristicLab.Algorithms.SAPBA/Problems/SurrogateProblem.cs  (working copy)
382@@ -1,5 +1,29 @@
383-using HeuristicLab.Common;
384+#region License Information
385+/* HeuristicLab
386+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
387+ *
388+ * This file is part of HeuristicLab.
389+ *
390+ * HeuristicLab is free software: you can redistribute it and/or modify
391+ * it under the terms of the GNU General Public License as published by
392+ * the Free Software Foundation, either version 3 of the License, or
393+ * (at your option) any later version.
394+ *
395+ * HeuristicLab is distributed in the hope that it will be useful,
396+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
397+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
398+ * GNU General Public License for more details.
399+ *
400+ * You should have received a copy of the GNU General Public License
401+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
402+ */
403+#endregion
404+
405+using System;
406+using System.Collections.Generic;
407+using HeuristicLab.Common;
408 using HeuristicLab.Core;
409+using HeuristicLab.Data;
410 using HeuristicLab.Encodings.RealVectorEncoding;
411 using HeuristicLab.Optimization;
412 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
413@@ -6,9 +30,9 @@
414 
415 namespace HeuristicLab.Algorithms.SAPBA {
416   [StorableClass]
417-  [Item("Surrogate problem (single-objective)", "Wrapper for a problem that allows surrogate models to mitigate some of the work")]
418+  [Item("Surrogate problem (single-objective)", "A problem that uses a Surrogate Strategy to emulate an expensive problem")]
419   public class SurrogateProblem : SingleObjectiveBasicProblem<RealVectorEncoding> {
420-
421+    public override bool Maximization => Strategy?.Maximization() ?? false;
422     [Storable]
423     private ISurrogateStrategy Strategy;
424 
425@@ -18,11 +42,12 @@
426     [StorableHook(HookType.AfterDeserialization)]
427     private void AfterDeserialization() { }
428     protected SurrogateProblem(SurrogateProblem original, Cloner cloner) : base(original, cloner) {
429-      Strategy = original?.Strategy;
430+      Strategy = cloner.Clone(original.Strategy);
431     }
432-    public override IDeepCloneable Clone(Cloner cloner) { return new SurrogateProblem(this, cloner); }
433-    public SurrogateProblem() {
434+    public override IDeepCloneable Clone(Cloner cloner) {
435+      return new SurrogateProblem(this, cloner);
436     }
437+    public SurrogateProblem() { }
438     #endregion
439 
440     public override double Evaluate(Individual individual, IRandom random) {
441@@ -32,15 +57,32 @@
442       base.Analyze(individuals, qualities, results, random);
443       Strategy.Analyze(individuals, qualities, results, random);
444     }
445+    public override IEnumerable<Individual> GetNeighbors(Individual individual, IRandom random) {
446+      var bounds = Encoding.Bounds;
447+      var michalewiczIteration = 0;
448+      while (true) {
449+        var neighbour = individual.Copy();
450+        var r = neighbour.RealVector();
451+        switch (random.Next(5)) {
452+          case 0: UniformOnePositionManipulator.Apply(random, r, bounds); break;
453+          case 1: FixedNormalAllPositionsManipulator.Apply(random, r, new RealVector(new[] { 0.1 })); break;
454+          case 2: MichalewiczNonUniformAllPositionsManipulator.Apply(random, r, bounds, new IntValue(michalewiczIteration++), new IntValue(10000), new DoubleValue(5.0)); break;
455+          case 3: MichalewiczNonUniformOnePositionManipulator.Apply(random, r, bounds, new IntValue(michalewiczIteration++), new IntValue(10000), new DoubleValue(5.0)); break;
456+          case 4: BreederGeneticAlgorithmManipulator.Apply(random, r, bounds, new DoubleValue(0.1)); break;
457+          default: throw new NotImplementedException();
458+        }
459+        yield return neighbour;
460+        michalewiczIteration %= 10000;
461+      }
462+    }
463 
464-    public override bool Maximization { get; }
465-
466-    public void SetStrategy(ISurrogateStrategy strategy) {
467+    public void Initialize(SingleObjectiveBasicProblem<IEncoding> expensiveProblem, ISurrogateStrategy strategy) {
468+      if (expensiveProblem == null) return;
469+      var enc = (RealVectorEncoding)expensiveProblem.Encoding;
470+      Encoding.Bounds = enc.Bounds;
471+      Encoding.Length = enc.Length;
472+      SolutionCreator = expensiveProblem.SolutionCreator;
473       Strategy = strategy;
474     }
475-    public void SetProblem(SingleObjectiveBasicProblem<IEncoding> expensiveProblem) {
476-      if (expensiveProblem != null) Encoding = expensiveProblem.Encoding as RealVectorEncoding;
477-    }
478-
479   }
480 }
481\ No newline at end of file
482Index: HeuristicLab.Algorithms.SAPBA/Properties/AssemblyInfo.cs
483===================================================================
484--- HeuristicLab.Algorithms.SAPBA/Properties/AssemblyInfo.cs  (revision 15449)
485+++ HeuristicLab.Algorithms.SAPBA/Properties/AssemblyInfo.cs  (working copy)
486@@ -52,4 +52,4 @@
487 // You can specify all the values or you can default the Build and Revision Numbers
488 // by using the '*' as shown below:
489 [assembly: AssemblyVersion("3.4.0.0")]
490-[assembly: AssemblyFileVersion("3.4.0.14893")]
491+[assembly: AssemblyFileVersion("3.4.0.14894")]
492Index: HeuristicLab.Algorithms.SAPBA/SapbaUtilities.cs
493===================================================================
494--- HeuristicLab.Algorithms.SAPBA/SapbaUtilities.cs (nonexistent)
495+++ HeuristicLab.Algorithms.SAPBA/SapbaUtilities.cs (working copy)
496@@ -0,0 +1,168 @@
497+#region License Information
498+/* HeuristicLab
499+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
500+ *
501+ * This file is part of HeuristicLab.
502+ *
503+ * HeuristicLab is free software: you can redistribute it and/or modify
504+ * it under the terms of the GNU General Public License as published by
505+ * the Free Software Foundation, either version 3 of the License, or
506+ * (at your option) any later version.
507+ *
508+ * HeuristicLab is distributed in the hope that it will be useful,
509+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
510+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
511+ * GNU General Public License for more details.
512+ *
513+ * You should have received a copy of the GNU General Public License
514+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
515+ */
516+#endregion
517+
518+using System;
519+using System.Collections.Generic;
520+using System.Linq;
521+using System.Threading;
522+using HeuristicLab.Algorithms.DataAnalysis;
523+using HeuristicLab.Common;
524+using HeuristicLab.Core;
525+using HeuristicLab.Data;
526+using HeuristicLab.Encodings.RealVectorEncoding;
527+using HeuristicLab.Optimization;
528+using HeuristicLab.Problems.DataAnalysis;
529+
530+namespace HeuristicLab.Algorithms.SAPBA {
531+  internal static class SapbaUtilities {
532+    //Extention methods for convenience
533+    public static int ArgMax<T>(this IEnumerable<T> values, Func<T, double> func) {
534+      var max = double.MinValue;
535+      var maxIdx = 0;
536+      var idx = 0;
537+      foreach (var v in values) {
538+        var d = func.Invoke(v);
539+        if (d > max) {
540+          max = d;
541+          maxIdx = idx;
542+        }
543+        idx++;
544+      }
545+      return maxIdx;
546+    }
547+    public static int ArgMin<T>(this IEnumerable<T> values, Func<T, double> func) {
548+      return ArgMax(values, x => -func.Invoke(x));
549+    }
550+    public static double GetEstimation(this IRegressionModel model, RealVector r) {
551+      var dataset = GetDataSet(new[] { new Tuple<RealVector, double>(r, 0.0) }, false);
552+      return model.GetEstimatedValues(dataset, new[] { 0 }).First();
553+    }
554+    public static double GetVariance(this IConfidenceRegressionModel model, RealVector r) {
555+      var dataset = GetDataSet(new[] { new Tuple<RealVector, double>(r, 0.0) }, false);
556+      return model.GetEstimatedVariances(dataset, new[] { 0 }).First();
557+    }
558+    public static double GetDoubleValue(this IDataset dataset, int i, int j) {
559+      return dataset.GetDoubleValue("input" + j, i);
560+    }
561+
562+    //Sub-Algorithms
563+    public static ResultCollection SyncRunSubAlgorithm(IAlgorithm alg, int random) {
564+      if (alg.Parameters.ContainsKey("SetSeedRandomly") && alg.Parameters.ContainsKey("Seed")) {
565+        var setSeed = alg.Parameters["SetSeedRandomly"].ActualValue as BoolValue;
566+        var seed = alg.Parameters["Seed"].ActualValue as IntValue;
567+        if (seed == null || setSeed == null) throw new ArgumentException("wrong SeedParametertypes");
568+        setSeed.Value = false;
569+        seed.Value = random;
570+
571+      }
572+      EventWaitHandle trigger = new AutoResetEvent(false);
573+      Exception ex = null;
574+      EventHandler<EventArgs<Exception>> exhandler = (sender, e) => ex = e.Value;
575+      EventHandler stoppedHandler = (sender, e) => trigger.Set();
576+      alg.ExceptionOccurred += exhandler;
577+      alg.Stopped += stoppedHandler;
578+      alg.Prepare();
579+      alg.Start();
580+      trigger.WaitOne();
581+      alg.ExceptionOccurred -= exhandler;
582+      alg.Stopped -= stoppedHandler;
583+      if (ex != null) throw ex;
584+      return alg.Results;
585+    }
586+    public static IRegressionSolution BuildModel(IReadOnlyList<Tuple<RealVector, double>> samples, IDataAnalysisAlgorithm<IRegressionProblem> regressionAlgorithm, IRandom random, bool removeDuplicates = true, IRegressionSolution oldSolution = null) {
587+      var dataset = GetDataSet(samples, removeDuplicates);
588+      var problemdata = new RegressionProblemData(dataset, dataset.VariableNames.Where(x => !x.Equals("output")), "output");
589+      problemdata.TrainingPartition.Start = 0;
590+      problemdata.TrainingPartition.End = dataset.Rows;
591+      problemdata.TestPartition.Start = dataset.Rows;
592+      problemdata.TestPartition.End = dataset.Rows;
593+
594+      if (regressionAlgorithm.Problem == null) regressionAlgorithm.Problem = new RegressionProblem();
595+      var problem = regressionAlgorithm.Problem;
596+      problem.ProblemDataParameter.Value = problemdata;
597+      var i = 0;
598+      IRegressionSolution solution = null;
599+
600+      while (solution == null && i++ < 100) {
601+        var results = SyncRunSubAlgorithm(regressionAlgorithm, random.Next(int.MaxValue));
602+        solution = results.Select(x => x.Value).OfType<IRegressionSolution>().SingleOrDefault();
603+      }
604+
605+      //special treatement for GaussianProcessRegression
606+      var gp = regressionAlgorithm as GaussianProcessRegression;
607+      var oldGaussian = oldSolution as GaussianProcessRegressionSolution;
608+      if (gp != null && oldGaussian != null) {
609+        const double noise = 0.0;
610+        var n = samples.First().Item1.Length;
611+        var mean = (IMeanFunction)oldGaussian.Model.MeanFunction.Clone();
612+        var cov = (ICovarianceFunction)oldGaussian.Model.CovarianceFunction.Clone();
613+        if (mean.GetNumberOfParameters(n) != 0 || cov.GetNumberOfParameters(n) != 0) throw new ArgumentException("DEBUG: assumption about fixed paramters wrong");
614+        double[] hyp = { noise };
615+        try {
616+          var model = new GaussianProcessModel(problemdata.Dataset, problemdata.TargetVariable, problemdata.AllowedInputVariables, problemdata.TrainingIndices, hyp, mean, cov);
617+          model.FixParameters();
618+          var sol = new GaussianProcessRegressionSolution(model, problemdata);
619+          if (solution == null || solution.TrainingMeanSquaredError > sol.TrainingMeanSquaredError) solution = sol;
620+        }
621+        catch (ArgumentException) { }
622+      }
623+      if (solution == null) throw new ArgumentException("The algorithm didn't return a model");
624+      regressionAlgorithm.Runs.Clear();
625+      return solution;
626+    }
627+
628+    //RegressionModel extensions
629+    public const double DuplicateResolution = 0.000001;
630+    public static Dataset GetDataSet(IReadOnlyList<Tuple<RealVector, double>> samples, bool removeDuplicates) {
631+      if (removeDuplicates) samples = RemoveDuplicates(samples); //TODO duplicate removal leads to incorrect uncertainty values in models
632+      var dimensions = samples[0].Item1.Length + 1;
633+      var data = new double[samples.Count, dimensions];
634+      var names = new string[dimensions - 1];
635+      for (var i = 0; i < names.Length; i++) names[i] = "input" + i;
636+      for (var j = 0; j < samples.Count; j++) {
637+        for (var i = 0; i < names.Length; i++) data[j, i] = samples[j].Item1[i];
638+        data[j, dimensions - 1] = samples[j].Item2;
639+      }
640+      return new Dataset(names.Concat(new[] { "output" }).ToArray(), data);
641+    }
642+    private static IReadOnlyList<Tuple<RealVector, double>> RemoveDuplicates(IReadOnlyList<Tuple<RealVector, double>> samples) {
643+      var res = new List<Tuple<RealVector, double, int>>();
644+      foreach (var sample in samples) {
645+        if (res.Count == 0) {
646+          res.Add(new Tuple<RealVector, double, int>(sample.Item1, sample.Item2, 1));
647+          continue;
648+        }
649+        var index = res.ArgMin(x => Euclidian(sample.Item1, x.Item1));
650+        var d = Euclidian(res[index].Item1, sample.Item1);
651+        if (d > DuplicateResolution) res.Add(new Tuple<RealVector, double, int>(sample.Item1, sample.Item2, 1));
652+        else {
653+          var t = res[index];
654+          res.RemoveAt(index);
655+          res.Add(new Tuple<RealVector, double, int>(t.Item1, t.Item2 + sample.Item2, t.Item3 + 1));
656+        }
657+      }
658+      return res.Select(x => new Tuple<RealVector, double>(x.Item1, x.Item2 / x.Item3)).ToArray();
659+    }
660+    private static double Euclidian(IEnumerable<double> a, IEnumerable<double> b) {
661+      return Math.Sqrt(a.Zip(b, (d, d1) => d - d1).Sum(d => d * d));
662+    }
663+  }
664+}
665Index: HeuristicLab.Algorithms.SAPBA/Strategies/InfillStrategy.cs
666===================================================================
667--- HeuristicLab.Algorithms.SAPBA/Strategies/InfillStrategy.cs  (nonexistent)
668+++ HeuristicLab.Algorithms.SAPBA/Strategies/InfillStrategy.cs  (working copy)
669@@ -0,0 +1,113 @@
670+#region License Information
671+/* HeuristicLab
672+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
673+ *
674+ * This file is part of HeuristicLab.
675+ *
676+ * HeuristicLab is free software: you can redistribute it and/or modify
677+ * it under the terms of the GNU General Public License as published by
678+ * the Free Software Foundation, either version 3 of the License, or
679+ * (at your option) any later version.
680+ *
681+ * HeuristicLab is distributed in the hope that it will be useful,
682+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
683+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
684+ * GNU General Public License for more details.
685+ *
686+ * You should have received a copy of the GNU General Public License
687+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
688+ */
689+#endregion
690+
691+using System;
692+using System.Linq;
693+using HeuristicLab.Algorithms.EGO;
694+using HeuristicLab.Common;
695+using HeuristicLab.Core;
696+using HeuristicLab.Data;
697+using HeuristicLab.Encodings.RealVectorEncoding;
698+using HeuristicLab.Optimization;
699+using HeuristicLab.Parameters;
700+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
701+
702+namespace HeuristicLab.Algorithms.SAPBA {
703+  [StorableClass]
704+  public class InfillStrategy : StrategyBase {
705+    #region Parameternames
706+    public const string NoGenerationsParameterName = "Number of generations";
707+    public const string NoIndividualsParameterName = "Number of individuals";
708+    public const string InfillCriterionParameterName = "InfillCriterion";
709+    #endregion
710+    #region Paramterproperties
711+    public IFixedValueParameter<IntValue> NoGenerationsParameter => Parameters[NoGenerationsParameterName] as IFixedValueParameter<IntValue>;
712+    public IFixedValueParameter<IntValue> NoIndividualsParameter => Parameters[NoIndividualsParameterName] as IFixedValueParameter<IntValue>;
713+    public IConstrainedValueParameter<IInfillCriterion> InfillCriterionParameter => Parameters[InfillCriterionParameterName] as IConstrainedValueParameter<IInfillCriterion>;
714+    #endregion
715+    #region Properties
716+    public IntValue NoGenerations => NoGenerationsParameter.Value;
717+    public IntValue NoIndividuals => NoIndividualsParameter.Value;
718+    public IInfillCriterion InfillCriterion => InfillCriterionParameter.Value;
719+    [Storable]
720+    public int Generations;
721+    #endregion
722+
723+    #region Constructors
724+    [StorableConstructor]
725+    protected InfillStrategy(bool deserializing) : base(deserializing) { }
726+    [StorableHook(HookType.AfterDeserialization)]
727+    private void AfterDeserialization() {
728+      AttachListeners();
729+    }
730+    protected InfillStrategy(InfillStrategy original, Cloner cloner) : base(original, cloner) {
731+      Generations = original.Generations;
732+      AttachListeners();
733+    }
734+    public InfillStrategy() {
735+      var critera = new ItemSet<IInfillCriterion> { new ExpectedImprovement(), new AugmentedExpectedImprovement(), new ExpectedQuality(), new ExpectedQuantileImprovement(), new MinimalQuantileCriterium(), new PluginExpectedImprovement() };
736+      Parameters.Add(new FixedValueParameter<IntValue>(NoGenerationsParameterName, "The number of generations before a new model is constructed", new IntValue(3)));
737+      Parameters.Add(new FixedValueParameter<IntValue>(NoIndividualsParameterName, "The number of individuals that are sampled each generation ", new IntValue(3)));
738+      Parameters.Add(new ConstrainedValueParameter<IInfillCriterion>(InfillCriterionParameterName, "The infill criterion used to cheaply evaluate points.", critera, critera.First()));
739+      AttachListeners();
740+    }
741+    public override IDeepCloneable Clone(Cloner cloner) {
742+      return new InfillStrategy(this, cloner);
743+    }
744+    #endregion
745+
746+    protected override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, ResultCollection globalResults, IRandom random) { }
747+    protected override void ProcessPopulation(Individual[] individuals, double[] qualities, IRandom random) {
748+      if (RegressionSolution != null && Generations < NoGenerations.Value) Generations++;
749+      else {
750+        //Select NoIndividuals best samples
751+        var samples = individuals
752+          .Zip(qualities, (individual, d) => new Tuple<Individual, double>(individual, d))
753+          .OrderBy(t => Problem.Maximization ? -t.Item2 : t.Item2)
754+          .Take(NoIndividuals.Value)
755+          .Select(t => t.Item1.RealVector());
756+        foreach (var indi in samples) EvaluateSample(indi, random);
757+        BuildRegressionSolution(random);
758+        Generations = 0;
759+      }
760+    }
761+    protected override void Initialize() {
762+      Generations = 0;
763+    }
764+
765+    #region events
766+    private void AttachListeners() {
767+      ModelChanged += OnModelChanged;
768+    }
769+    private void OnModelChanged(object sender, EventArgs e) {
770+      InfillCriterion.Encoding = Problem?.Encoding as RealVectorEncoding;
771+      InfillCriterion.RegressionSolution = RegressionSolution;
772+      InfillCriterion.ExpensiveMaximization = Problem?.Maximization ?? false;
773+      if (RegressionSolution != null && InfillCriterion.Encoding != null)
774+        InfillCriterion.Initialize();
775+    }
776+    #endregion
777+
778+    protected override double Estimate(RealVector point, IRandom random) {
779+      return InfillCriterion.Maximization() != Maximization() ? -InfillCriterion.Evaluate(point) : InfillCriterion.Evaluate(point);
780+    }
781+  }
782+}
783Index: HeuristicLab.Algorithms.SAPBA/Strategies/LamarckianStrategy.cs
784===================================================================
785--- HeuristicLab.Algorithms.SAPBA/Strategies/LamarckianStrategy.cs  (nonexistent)
786+++ HeuristicLab.Algorithms.SAPBA/Strategies/LamarckianStrategy.cs  (working copy)
787@@ -0,0 +1,249 @@
788+#region License Information
789+/* HeuristicLab
790+ * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
791+ *
792+ * This file is part of HeuristicLab.
793+ *
794+ * HeuristicLab is free software: you can redistribute it and/or modify
795+ * it under the terms of the GNU General Public License as published by
796+ * the Free Software Foundation, either version 3 of the License, or
797+ * (at your option) any later version.
798+ *
799+ * HeuristicLab is distributed in the hope that it will be useful,
800+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
801+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
802+ * GNU General Public License for more details.
803+ *
804+ * You should have received a copy of the GNU General Public License
805+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
806+ */
807+#endregion
808+
809+using System;
810+using System.Collections.Generic;
811+using System.Linq;
812+using HeuristicLab.Algorithms.DataAnalysis;
813+using HeuristicLab.Algorithms.EGO;
814+using HeuristicLab.Algorithms.SAPBA.Operators;
815+using HeuristicLab.Analysis;
816+using HeuristicLab.Common;
817+using HeuristicLab.Core;
818+using HeuristicLab.Data;
819+using HeuristicLab.Encodings.RealVectorEncoding;
820+using HeuristicLab.Optimization;
821+using HeuristicLab.Parameters;
822+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
823+using HeuristicLab.Problems.DataAnalysis;
824+
825+namespace HeuristicLab.Algorithms.SAPBA {
826+  [StorableClass]
827+  public class LamarckianStrategy : InfillStrategy {
828+    #region Parameternames
829+    public const string NoTrainingPointsParameterName = "Number of Trainingpoints";
830+    public const string LocalInfillCriterionParameterName = "LocalInfillCriterion";
831+    public const string OptimizationAlgorithmParameterName = "Optimization Algorithm";
832+    public const string RegressionAlgorithmParameterName = "Regression Algorithm";
833+    #endregion
834+    #region Parameters
835+    public IFixedValueParameter<IntValue> NoTrainingPointsParameter => Parameters[NoTrainingPointsParameterName] as IFixedValueParameter<IntValue>;
836+    public IValueParameter<IAlgorithm> OptimizationAlgorithmParameter => Parameters[OptimizationAlgorithmParameterName] as IValueParameter<IAlgorithm>;
837+    public IValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>> RegressionAlgorithmParameter => Parameters[RegressionAlgorithmParameterName] as IValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>>;
838+    public IConstrainedValueParameter<IInfillCriterion> LocalInfillCriterionParameter => Parameters[LocalInfillCriterionParameterName] as IConstrainedValueParameter<IInfillCriterion>;
839+    #endregion
840+    #region Properties
841+    public IntValue NoTrainingPoints => NoTrainingPointsParameter.Value;
842+    public IAlgorithm OptimizationAlgorithm => OptimizationAlgorithmParameter.Value;
843+    public IDataAnalysisAlgorithm<IRegressionProblem> RegressionAlgorithm => RegressionAlgorithmParameter.Value;
844+    public IInfillCriterion LocalInfillCriterion => LocalInfillCriterionParameter.Value;
845+    #endregion
846+
847+    #region Constructors
848+    [StorableConstructor]
849+    protected LamarckianStrategy(bool deserializing) : base(deserializing) { }
850+    [StorableHook(HookType.AfterDeserialization)]
851+    private void AfterDeserialization() {
852+      RegisterParameterEvents();
853+    }
854+    protected LamarckianStrategy(LamarckianStrategy original, Cloner cloner) : base(original, cloner) {
855+      RegisterParameterEvents();
856+    }
857+    public LamarckianStrategy() {
858+      var localCritera = new ItemSet<IInfillCriterion> { new ExpectedQuality(), new ExpectedImprovement(), new AugmentedExpectedImprovement(), new ExpectedQuantileImprovement(), new MinimalQuantileCriterium(), new PluginExpectedImprovement() };
859+      var osEs = new OffspringSelectionEvolutionStrategy.OffspringSelectionEvolutionStrategy {
860+        Problem = new InfillProblem(),
861+        ComparisonFactor = { Value = 1.0 },
862+        MaximumGenerations = { Value = 1000 },
863+        MaximumEvaluatedSolutions = { Value = 100000 },
864+        PlusSelection = { Value = true },
865+        PopulationSize = { Value = 1 }
866+      };
867+      osEs.MutatorParameter.Value = osEs.MutatorParameter.ValidValues.OfType<MultiRealVectorManipulator>().First();
868+      Parameters.Add(new FixedValueParameter<IntValue>(NoTrainingPointsParameterName, "The number of sample points used to create a local model", new IntValue(50)));
869+      Parameters.Add(new ConstrainedValueParameter<IInfillCriterion>(LocalInfillCriterionParameterName, "The infill criterion used to cheaply evaluate points.", localCritera, localCritera.First()));
870+      Parameters.Add(new ValueParameter<IAlgorithm>(OptimizationAlgorithmParameterName, "The algorithm used to solve the expected improvement subproblem", osEs));
871+      Parameters.Add(new ValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>>(RegressionAlgorithmParameterName, "The model used to approximate the problem", new GaussianProcessRegression { Problem = new RegressionProblem() }));
872+      RegisterParameterEvents();
873+    }
874+    public override IDeepCloneable Clone(Cloner cloner) {
875+      return new LamarckianStrategy(this, cloner);
876+    }
877+    #endregion
878+
879+    //Short lived stores for analysis
880+    private readonly List<double> LamarckValues = new List<double>();
881+    private readonly List<double> SampleValues = new List<double>();
882+
883+    protected override void Initialize() {
884+      base.Initialize();
885+      var infillProblem = OptimizationAlgorithm.Problem as InfillProblem;
886+      if (infillProblem == null) throw new ArgumentException("InfillOptimizationAlgorithm does not have an InfillProblem.");
887+      infillProblem.InfillCriterion = LocalInfillCriterion;
888+    }
889+    protected override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, ResultCollection globalResults, IRandom random) {
890+      base.Analyze(individuals, qualities, results, globalResults, random);
891+      const string plotName = "Lamarck Comparison";
892+      const string lamarckRow = "Lamarck Values";
893+      const string samplesRow = "Original Values";
894+      if (!globalResults.ContainsKey(plotName))
895+        globalResults.Add(new Result(plotName, new DataTable(plotName)));
896+
897+      var plot = (DataTable)globalResults[plotName].Value;
898+      if (!plot.Rows.ContainsKey(lamarckRow)) plot.Rows.Add(new DataRow(lamarckRow));
899+      if (!plot.Rows.ContainsKey(samplesRow)) plot.Rows.Add(new DataRow(samplesRow));
900+      plot.Rows[lamarckRow].Values.AddRange(LamarckValues);
901+      plot.Rows[samplesRow].Values.AddRange(SampleValues);
902+      LamarckValues.Clear();
903+      SampleValues.Clear();
904+
905+      //analyze Hypervolumes
906+      const string volPlotName = "Hypervolumes Comparison";
907+      const string mainRowName = "Population Volume (log)";
908+      const string subspaceRowName = "Subspace Volume (log) for Lamarck Candidate ";
909+      if (!globalResults.ContainsKey(volPlotName))
910+        globalResults.Add(new Result(volPlotName, new DataTable(volPlotName)));
911+
912+      plot = (DataTable)globalResults[volPlotName].Value;
913+      if (!plot.Rows.ContainsKey(mainRowName)) plot.Rows.Add(new DataRow(mainRowName));
914+      var v = Math.Log(GetStableVolume(GetBoundingBox(individuals.Select(x => x.RealVector()))));
915+      plot.Rows[mainRowName].Values.Add(v);
916+
917+      var indis = individuals
918+          .Zip(qualities, (individual, d) => new Tuple<Individual, double>(individual, d))
919+          .OrderBy(t => SapbaAlgorithm.Problem.Maximization ? -t.Item2 : t.Item2)
920+          .Take(NoIndividuals.Value)
921+          .Select(t => t.Item1).ToArray();
922+
923+      for (var i = 0; i < indis.Length; i++) {
924+        var samples = GetNearestSamples(NoTrainingPoints.Value, indis[i].RealVector());
925+        var d = Math.Log(GetStableVolume(GetBoundingBox(samples.Select(x => x.Item1))));
926+        if (!plot.Rows.ContainsKey(subspaceRowName + i)) plot.Rows.Add(new DataRow(subspaceRowName + i));
927+        plot.Rows[subspaceRowName + i].Values.Add(d);
928+      }
929+
930+
931+
932+    }
933+    protected override void ProcessPopulation(Individual[] individuals, double[] qualities, IRandom random) {
934+      if (RegressionSolution == null) return;
935+      if (Generations < NoGenerations.Value) Generations++;
936+      else {
937+        //Select best Individuals
938+        var indis = individuals
939+          .Zip(qualities, (individual, d) => new Tuple<Individual, double>(individual, d))
940+          .OrderBy(t => Problem.Maximization ? -t.Item2 : t.Item2)
941+          .Take(NoIndividuals.Value)
942+          .Select(t => t.Item1).ToArray();
943+        //Evaluate individuals
944+        foreach (var individual in indis)
945+          SampleValues.Add(EvaluateSample(individual.RealVector(), random).Item2);
946+
947+        //Perform memetic replacement for all points
948+        for (var i = 0; i < indis.Length; i++) {
949+          var vector = indis[i].RealVector();
950+          var altVector = OptimizeInfillProblem(vector, random);
951+          LamarckValues.Add(EvaluateSample(altVector, random).Item2);
952+          if (LamarckValues[i] < SampleValues[i] == Problem.Maximization) continue;
953+          for (var j = 0; j < vector.Length; j++) vector[j] = altVector[j];
954+        }
955+
956+        BuildRegressionSolution(random);
957+        Generations = 0;
958+      }
959+    }
960+
961+    #region Events
962+    private void RegisterParameterEvents() {
963+      OptimizationAlgorithmParameter.ValueChanged += OnInfillAlgorithmChanged;
964+      OptimizationAlgorithm.ProblemChanged += OnInfillProblemChanged;
965+      LocalInfillCriterionParameter.ValueChanged += OnInfillCriterionChanged;
966+    }
967+    private void OnInfillCriterionChanged(object sender, EventArgs e) {
968+      ((InfillProblem)OptimizationAlgorithm.Problem).InfillCriterion = LocalInfillCriterion;
969+    }
970+    private void OnInfillAlgorithmChanged(object sender, EventArgs e) {
971+      OptimizationAlgorithm.Problem = new InfillProblem { InfillCriterion = LocalInfillCriterion };
972+      OptimizationAlgorithm.ProblemChanged -= OnInfillProblemChanged; //avoid double attaching
973+      OptimizationAlgorithm.ProblemChanged += OnInfillProblemChanged;
974+    }
975+    private void OnInfillProblemChanged(object sender, EventArgs e) {
976+      OptimizationAlgorithm.ProblemChanged -= OnInfillProblemChanged;
977+      OptimizationAlgorithm.Problem = new InfillProblem { InfillCriterion = LocalInfillCriterion };
978+      OptimizationAlgorithm.ProblemChanged += OnInfillProblemChanged;
979+    }
980+    #endregion
981+
982+    #region helpers
983+    private RealVector OptimizeInfillProblem(RealVector point, IRandom random) {
984+      var infillProblem = OptimizationAlgorithm.Problem as InfillProblem;
985+      if (infillProblem == null) throw new ArgumentException("InfillOptimizationAlgorithm does not have an InfillProblem.");
986+      if (infillProblem.InfillCriterion != LocalInfillCriterion) throw new ArgumentException("InfillCiriterion for Problem is not correctly set.");
987+
988+      var points = Math.Min(NoTrainingPoints.Value, Samples.Count);
989+      var samples = GetNearestSamples(points, point);
990+      var regression = SapbaUtilities.BuildModel(samples, RegressionAlgorithm, random);
991+      var box = GetBoundingBox(samples.Select(x => x.Item1));
992+
993+      infillProblem.Encoding.Length = ((RealVectorEncoding)Problem.Encoding).Length;
994+      infillProblem.Encoding.Bounds = box;
995+      infillProblem.Encoding.SolutionCreator = new FixedRealVectorCreator(point);
996+      infillProblem.Initialize(regression, Problem.Maximization);
997+      var res = SapbaUtilities.SyncRunSubAlgorithm(OptimizationAlgorithm, random.Next(int.MaxValue));
998+      if (!res.ContainsKey(InfillProblem.BestInfillSolutionResultName)) throw new ArgumentException("The InfillOptimizationAlgorithm did not return a best solution");
999+      var v = res[InfillProblem.BestInfillSolutionResultName].Value as RealVector;
1000+      if (v == null) throw new ArgumentException("The InfillOptimizationAlgorithm did not return the expected result types");
1001+      if (!InBounds(v, box)) throw new ArgumentException("Vector not in bounds");
1002+      OptimizationAlgorithm.Runs.Clear();
1003+      return v;
1004+    }
1005+    private Tuple<RealVector, double>[] GetNearestSamples(int noSamples, RealVector point) {
1006+      return Samples.Select(sample => Tuple.Create(SquaredEuclidean(sample.Item1, point), sample)).OrderBy(x => x.Item1).Take(noSamples).Select(x => x.Item2).ToArray();
1007+    }
1008+    private static DoubleMatrix GetBoundingBox(IEnumerable<RealVector> samples) {
1009+      DoubleMatrix m = null;
1010+      foreach (var sample in samples)
1011+        if (m == null) {
1012+          m = new DoubleMatrix(sample.Length, 2);
1013+          for (var i = 0; i < sample.Length; i++) m[i, 0] = m[i, 1] = sample[i];
1014+        } else
1015+          for (var i = 0; i < sample.Length; i++) {
1016+            m[i, 0] = Math.Min(m[i, 0], sample[i]);
1017+            m[i, 1] = Math.Max(m[i, 1], sample[i]);
1018+          }
1019+      return m;
1020+    }
1021+
1022+    //the volume of a bounded-box whith slightly increased dimensions (Volume can never reach 0)
1023+    private static double GetStableVolume(DoubleMatrix bounds) {
1024+      var res = 1.0;
1025+      for (var i = 0; i < bounds.Rows; i++) res *= bounds[i, 1] - bounds[i, 0] + 0.1;
1026+      return res;
1027+    }
1028+    private static bool InBounds(RealVector r, DoubleMatrix bounds) {
1029+      return !r.Where((t, i) => t < bounds[i, 0] || t > bounds[i, 1]).Any();
1030+    }
1031+    private static double SquaredEuclidean(RealVector a, RealVector b) {
1032+      return a.Select((t, i) => t - b[i]).Sum(d => d * d);
1033+    }
1034+    #endregion
1035+  }
1036+}
1037Index: HeuristicLab.Algorithms.SAPBA/Strategies/StrategyBase.cs
1038===================================================================
1039--- HeuristicLab.Algorithms.SAPBA/Strategies/StrategyBase.cs  (revision 15449)
1040+++ HeuristicLab.Algorithms.SAPBA/Strategies/StrategyBase.cs  (working copy)
1041@@ -22,7 +22,6 @@
1042 using System;
1043 using System.Collections.Generic;
1044 using System.Linq;
1045-using System.Threading;
1046 using HeuristicLab.Analysis;
1047 using HeuristicLab.Common;
1048 using HeuristicLab.Core;
1049@@ -32,20 +31,39 @@
1050 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
1051 using HeuristicLab.Problems.DataAnalysis;
1052 
1053-namespace HeuristicLab.Algorithms.SAPBA.Strategies {
1054+namespace HeuristicLab.Algorithms.SAPBA {
1055   [StorableClass]
1056   public abstract class StrategyBase : ParameterizedNamedItem, ISurrogateStrategy {
1057     #region Properties
1058     [Storable]
1059-    protected SurrogateAssistedPopulationBasedAlgorithm Algorithm;
1060+    protected SurrogateAssistedPopulationBasedAlgorithm SapbaAlgorithm;
1061+    protected SingleObjectiveBasicProblem<IEncoding> Problem => SapbaAlgorithm?.Problem;
1062     [Storable]
1063-    private List<Tuple<RealVector, double>> Samples;
1064+    protected List<Tuple<RealVector, double>> Samples;
1065     [Storable]
1066-    protected IRegressionSolution RegressionSolution;
1067-    protected CancellationToken Cancellation;
1068-    private IEnumerable<Tuple<RealVector, double>> TruncatedSamples => Samples.Count > Algorithm.MaximalDatasetSize && Algorithm.MaximalDatasetSize > 0 ? Samples.Skip(Samples.Count - Algorithm.MaximalDatasetSize) : Samples;
1069+    private IRegressionSolution regressionSolution;
1070+
1071+    public IRegressionSolution RegressionSolution
1072+    {
1073+      get { return regressionSolution; }
1074+      protected set
1075+      {
1076+        regressionSolution = value;
1077+        OnModelChanged();
1078+      }
1079+    }
1080+
1081+    private List<Tuple<RealVector, double>> TruncatedSamples => Samples.Count > SapbaAlgorithm.MaximalDatasetSize && SapbaAlgorithm.MaximalDatasetSize > 0 ? Samples.Skip(Samples.Count - SapbaAlgorithm.MaximalDatasetSize).ToList() : Samples;
1082     #endregion
1083 
1084+    #region Events
1085+    public event EventHandler ModelChanged;
1086+    private void OnModelChanged() {
1087+      ModelChanged?.Invoke(this, EventArgs.Empty);
1088+      OnToStringChanged();
1089+    }
1090+    #endregion
1091+
1092     #region ResultName
1093     private const string BestQualityResultName = "Best Quality";
1094     private const string BestSolutionResultName = "Best Solution";
1095@@ -64,55 +82,44 @@
1096     [StorableConstructor]
1097     protected StrategyBase(bool deserializing) : base(deserializing) { }
1098     protected StrategyBase(StrategyBase original, Cloner cloner) : base(original, cloner) {
1099-      if (original.Samples != null) Samples = original.Samples.Select(x => new Tuple<RealVector, double>(cloner.Clone(x.Item1), x.Item2)).ToList();
1100+      Samples = original.Samples?.Select(x => new Tuple<RealVector, double>(cloner.Clone(x.Item1), x.Item2)).ToList();
1101       RegressionSolution = cloner.Clone(original.RegressionSolution);
1102+      SapbaAlgorithm = cloner.Clone(original.SapbaAlgorithm);
1103     }
1104     protected StrategyBase() { }
1105     #endregion
1106 
1107-    public abstract double Evaluate(RealVector r, IRandom random);
1108     protected abstract void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, ResultCollection globalResults, IRandom random);
1109     protected abstract void ProcessPopulation(Individual[] individuals, double[] qualities, IRandom random);
1110-    protected abstract void Initialize();
1111+    protected virtual void Initialize() { }
1112+    //protected virtual void OnModelChanged() { }
1113 
1114+    protected abstract double Estimate(RealVector r, IRandom random);
1115+
1116+    public double Evaluate(RealVector r, IRandom random) {
1117+      if (Samples.Count < SapbaAlgorithm.InitialEvaluations) return EvaluateSample(r, random).Item2;
1118+      if (Samples.Count == SapbaAlgorithm.InitialEvaluations && RegressionSolution == null) {
1119+        BuildRegressionSolution(random);
1120+        OnModelChanged();
1121+      }
1122+      return Estimate(r, random);
1123+    }
1124     public void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
1125-      Algorithm.Problem.Analyze(individuals, qualities, results, random);
1126+      SapbaAlgorithm.Problem.Analyze(individuals, qualities, results, random);
1127       ProcessPopulation(individuals, qualities, random);
1128 
1129-      var globalResults = Algorithm.Results;
1130+      var globalResults = SapbaAlgorithm.Results;
1131       if (!globalResults.ContainsKey(EvaluatedSoultionsResultName)) globalResults.Add(new Result(EvaluatedSoultionsResultName, new IntValue(Samples.Count)));
1132       else ((IntValue)globalResults[EvaluatedSoultionsResultName].Value).Value = Samples.Count;
1133       if (!globalResults.ContainsKey(IterationsResultName)) globalResults.Add(new Result(IterationsResultName, new IntValue(0)));
1134       else ((IntValue)globalResults[IterationsResultName].Value).Value++;
1135 
1136-      if (Samples.Count != 0) {
1137-        var min = Samples.Min(x => x.Item2);
1138-        var max = Samples.Max(x => x.Item2);
1139-        var bestIdx = Algorithm.Problem.Maximization ? Samples.ArgMax(x => x.Item2) : Samples.ArgMin(x => x.Item2);
1140 
1141-        if (!globalResults.ContainsKey(BestQualityResultName)) globalResults.Add(new Result(BestQualityResultName, new DoubleValue(0.0)));
1142-        ((DoubleValue)globalResults[BestQualityResultName].Value).Value = Samples[bestIdx].Item2;
1143-        if (!globalResults.ContainsKey(BestSolutionResultName)) globalResults.Add(new Result(BestSolutionResultName, new RealVector()));
1144-        globalResults[BestSolutionResultName].Value = Samples[bestIdx].Item1;
1145+      AnalyzeSamplesProgression(globalResults);
1146+      AnalyzeQualities(globalResults);
1147 
1148-        DataTable table;
1149-        if (!globalResults.ContainsKey(QualityTableResultName)) {
1150-          table = new DataTable("Qualites", "Qualites over iteration");
1151-          globalResults.Add(new Result(QualityTableResultName, table));
1152-          table.Rows.Add(new DataRow(BestQualityRowName, "Best Quality"));
1153-          table.Rows.Add(new DataRow(WorstQualityRowName, "Worst Quality"));
1154-          table.Rows.Add(new DataRow(CurrentQualityRowName, "Current Quality"));
1155-          table.Rows.Add(new DataRow(MedianQualityRowName, "Median Quality"));
1156-          table.Rows.Add(new DataRow(AverageQualityRowName, "Average Quality"));
1157-        }
1158-        table = (DataTable)globalResults[QualityTableResultName].Value;
1159-        table.Rows[BestQualityResultName].Values.Add(Algorithm.Problem.Maximization ? max : min);
1160-        table.Rows[WorstQualityRowName].Values.Add(Algorithm.Problem.Maximization ? min : max);
1161-        table.Rows[CurrentQualityRowName].Values.Add(Samples[Samples.Count - 1].Item2);
1162-        table.Rows[AverageQualityRowName].Values.Add(Samples.Average(x => x.Item2));
1163-        table.Rows[MedianQualityRowName].Values.Add(Samples.Select(x => x.Item2).Median());
1164-      }
1165 
1166+
1167       if (RegressionSolution != null) {
1168         if (!globalResults.ContainsKey(RegressionSolutionResultName))
1169           globalResults.Add(new Result(RegressionSolutionResultName, RegressionSolution));
1170@@ -122,40 +129,93 @@
1171 
1172       Analyze(individuals, qualities, results, globalResults, random);
1173     }
1174+    private void AnalyzeSamplesProgression(ResultCollection globalResults) {
1175+      const string samplesTableName = "SamplesProgression";
1176+      const string minRowName = "Minimum";
1177+      const string maxRowName = "Maximum";
1178+      const string medianRowName = "Median";
1179+      const string averageRowName = "Average";
1180+      const string currentRowName = "Current";
1181+
1182+      if (!globalResults.ContainsKey(samplesTableName)) { globalResults.Add(new Result(samplesTableName, new DataTable())); }
1183+      var table = (DataTable)globalResults[samplesTableName].Value;
1184+
1185+      if (!table.Rows.ContainsKey(minRowName)) table.Rows.Add(new DataRow(minRowName));
1186+      if (!table.Rows.ContainsKey(maxRowName)) table.Rows.Add(new DataRow(maxRowName));
1187+      if (!table.Rows.ContainsKey(medianRowName)) table.Rows.Add(new DataRow(medianRowName));
1188+      if (!table.Rows.ContainsKey(averageRowName)) table.Rows.Add(new DataRow(averageRowName));
1189+      if (!table.Rows.ContainsKey(currentRowName)) table.Rows.Add(new DataRow(currentRowName));
1190+
1191+      for (var i = table.Rows[minRowName].Values.Count + 1; i < Samples.Count; i++) {
1192+        var subSamples = Samples.Take(i).Select(x => x.Item2).ToArray();
1193+        table.Rows[minRowName].Values.Add(subSamples.Min());
1194+        table.Rows[maxRowName].Values.Add(subSamples.Max());
1195+        table.Rows[medianRowName].Values.Add(subSamples.Median());
1196+        table.Rows[averageRowName].Values.Add(subSamples.Average());
1197+        table.Rows[currentRowName].Values.Add(subSamples[subSamples.Length - 1]);
1198+      }
1199+    }
1200+    private void AnalyzeQualities(ResultCollection globalResults) {
1201+      if (Samples.Count == 0) return;
1202+      var min = Samples.Min(x => x.Item2);
1203+      var max = Samples.Max(x => x.Item2);
1204+      var bestIdx = SapbaAlgorithm.Problem.Maximization ? Samples.ArgMax(x => x.Item2) : Samples.ArgMin(x => x.Item2);
1205+
1206+      if (!globalResults.ContainsKey(BestQualityResultName)) globalResults.Add(new Result(BestQualityResultName, new DoubleValue(0.0)));
1207+      ((DoubleValue)globalResults[BestQualityResultName].Value).Value = Samples[bestIdx].Item2;
1208+      if (!globalResults.ContainsKey(BestSolutionResultName)) globalResults.Add(new Result(BestSolutionResultName, new RealVector()));
1209+      globalResults[BestSolutionResultName].Value = Samples[bestIdx].Item1;
1210+
1211+      DataTable table;
1212+      if (!globalResults.ContainsKey(QualityTableResultName)) {
1213+        table = new DataTable("Qualites", "Qualites over iteration");
1214+        globalResults.Add(new Result(QualityTableResultName, table));
1215+        table.Rows.Add(new DataRow(BestQualityRowName, "Best Quality"));
1216+        table.Rows.Add(new DataRow(WorstQualityRowName, "Worst Quality"));
1217+        table.Rows.Add(new DataRow(CurrentQualityRowName, "Current Quality"));
1218+        table.Rows.Add(new DataRow(MedianQualityRowName, "Median Quality"));
1219+        table.Rows.Add(new DataRow(AverageQualityRowName, "Average Quality"));
1220+      }
1221+      table = (DataTable)globalResults[QualityTableResultName].Value;
1222+      table.Rows[BestQualityResultName].Values.Add(SapbaAlgorithm.Problem.Maximization ? max : min);
1223+      table.Rows[WorstQualityRowName].Values.Add(SapbaAlgorithm.Problem.Maximization ? min : max);
1224+      table.Rows[CurrentQualityRowName].Values.Add(Samples[Samples.Count - 1].Item2);
1225+      table.Rows[AverageQualityRowName].Values.Add(Samples.Average(x => x.Item2));
1226+      table.Rows[MedianQualityRowName].Values.Add(Samples.Select(x => x.Item2).Median());
1227+    }
1228+
1229     public void Initialize(SurrogateAssistedPopulationBasedAlgorithm algorithm) {
1230-      Algorithm = algorithm;
1231-      Samples = algorithm.InitialSamples?.ToList() ?? new List<Tuple<RealVector, double>>();
1232+      SapbaAlgorithm = algorithm;
1233+      Samples = algorithm?.InitialSamples?.ToList() ?? new List<Tuple<RealVector, double>>();
1234       RegressionSolution = null;
1235       Initialize();
1236     }
1237+    public virtual bool Maximization() {
1238+      return SapbaAlgorithm?.Problem?.Maximization ?? false;
1239+    }
1240 
1241     #region Helpers for Subclasses
1242     protected void BuildRegressionSolution(IRandom random) {
1243-      RegressionSolution = EgoUtilities.BuildModel(Cancellation, TruncatedSamples, Algorithm.RegressionAlgorithm, random, Algorithm.RemoveDuplicates, RegressionSolution);
1244+      RegressionSolution = SapbaUtilities.BuildModel(TruncatedSamples, SapbaAlgorithm.RegressionAlgorithm, random, SapbaAlgorithm.RemoveDuplicates, RegressionSolution);
1245     }
1246     protected Tuple<RealVector, double> EvaluateSample(RealVector point, IRandom random) {
1247-      Cancellation.ThrowIfCancellationRequested();
1248-      if (Samples.Count >= Algorithm.MaximumEvaluations) { Algorithm.OptimizationAlgorithm.Stop(); return new Tuple<RealVector, double>(point, 0.0); }
1249-      var p = new Tuple<RealVector, double>(point, Algorithm.Problem.Evaluate(GetIndividual(point), random));
1250+      if (Samples.Count >= SapbaAlgorithm.MaximumEvaluations) { SapbaAlgorithm.OptimizationAlgorithm.Stop(); return new Tuple<RealVector, double>(point, 0.0); }
1251+      var p = new Tuple<RealVector, double>((RealVector)point.Clone(), SapbaAlgorithm.Problem.Evaluate(GetIndividual(point), random));
1252       Samples.Add(p);
1253       return p;
1254     }
1255-    protected Tuple<RealVector, double> EstimateSample(RealVector point, IRandom random) {
1256-      if (Samples.Count == Algorithm.InitialEvaluations && RegressionSolution == null) BuildRegressionSolution(random);
1257-      return Samples.Count < Algorithm.InitialEvaluations ? EvaluateSample(point, random) : new Tuple<RealVector, double>(point, RegressionSolution.Model.GetEstimation(point));
1258+    protected double EstimateSample(RealVector r) {
1259+      return RegressionSolution.Model.GetEstimation(r);
1260     }
1261+
1262     #endregion
1263 
1264     #region Helpers
1265     private Individual GetIndividual(RealVector r) {
1266       var scope = new Scope();
1267-      scope.Variables.Add(new Variable(Algorithm.Problem.Encoding.Name, r));
1268-      return new SingleEncodingIndividual(Algorithm.Problem.Encoding, scope);
1269+      scope.Variables.Add(new Variable(SapbaAlgorithm.Problem.Encoding.Name, r));
1270+      return new SingleEncodingIndividual(SapbaAlgorithm.Problem.Encoding, scope);
1271     }
1272-
1273-    public void UpdateCancellation(CancellationToken cancellationToken) {
1274-      Cancellation = cancellationToken;
1275-    }
1276     #endregion
1277   }
1278 }
1279\ No newline at end of file
1280Index: HeuristicLab.Algorithms.SAPBA/SurrogateAssistedPopulationBasedAlgorithm.cs
1281===================================================================
1282--- HeuristicLab.Algorithms.SAPBA/SurrogateAssistedPopulationBasedAlgorithm.cs  (revision 15449)
1283+++ HeuristicLab.Algorithms.SAPBA/SurrogateAssistedPopulationBasedAlgorithm.cs  (working copy)
1284@@ -24,7 +24,6 @@
1285 using System.Linq;
1286 using System.Threading;
1287 using HeuristicLab.Algorithms.DataAnalysis;
1288-using HeuristicLab.Algorithms.SAPBA.Strategies;
1289 using HeuristicLab.Common;
1290 using HeuristicLab.Core;
1291 using HeuristicLab.Data;
1292@@ -33,7 +32,6 @@
1293 using HeuristicLab.Parameters;
1294 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
1295 using HeuristicLab.Problems.DataAnalysis;
1296-using HeuristicLab.Random;
1297 
1298 namespace HeuristicLab.Algorithms.SAPBA {
1299   [StorableClass]
1300@@ -41,7 +39,7 @@
1301   [Item("SurrogateAssistedPopulationBasedAlgorithm", "")]
1302   public class SurrogateAssistedPopulationBasedAlgorithm : BasicAlgorithm, ISurrogateAlgorithm<RealVector> {
1303     #region Basic-Alg-Essentials
1304-    public override bool SupportsPause => true;
1305+    public override bool SupportsPause => false;
1306     public override Type ProblemType => typeof(SingleObjectiveBasicProblem<IEncoding>);
1307     public new SingleObjectiveBasicProblem<IEncoding> Problem
1308     {
1309@@ -91,14 +89,9 @@
1310 
1311     #region StorableProperties
1312     [Storable]
1313-    private IRandom Random = new MersenneTwister();
1314-    [Storable]
1315     public List<Tuple<RealVector, double>> InitialSamples { get; private set; }
1316     [Storable]
1317-    public SurrogateProblem surrogateProblem;
1318-    public void SetInitialSamples(RealVector[] solutions, double[] qualities) {
1319-      InitialSamples = solutions.Zip(qualities, (vector, d) => new Tuple<RealVector, double>(vector, d)).ToList();
1320-    }
1321+    public SurrogateProblem SurrogateProblem;
1322     #endregion
1323 
1324     #region HLConstructors
1325@@ -109,59 +102,50 @@
1326       RegisterEventhandlers();
1327     }
1328     protected SurrogateAssistedPopulationBasedAlgorithm(SurrogateAssistedPopulationBasedAlgorithm original, Cloner cloner) : base(original, cloner) {
1329-      Random = cloner.Clone(Random);
1330-      if (original.InitialSamples != null) InitialSamples = original.InitialSamples.Select(x => new Tuple<RealVector, double>(cloner.Clone(x.Item1), x.Item2)).ToList();
1331+      InitialSamples = original.InitialSamples?.Select(x => new Tuple<RealVector, double>(cloner.Clone(x.Item1), x.Item2)).ToList();
1332+      SurrogateProblem = cloner.Clone(original.SurrogateProblem);
1333       RegisterEventhandlers();
1334     }
1335     public override IDeepCloneable Clone(Cloner cloner) { return new SurrogateAssistedPopulationBasedAlgorithm(this, cloner); }
1336     public SurrogateAssistedPopulationBasedAlgorithm() {
1337-      surrogateProblem = new SurrogateProblem();
1338-      var geneticAlgorithm = new GeneticAlgorithm.GeneticAlgorithm {
1339-        PopulationSize = { Value = 50 },
1340-        Problem = surrogateProblem
1341-      };
1342-      var model = new GaussianProcessRegression {
1343-        Problem = new RegressionProblem()
1344-      };
1345+      SurrogateProblem = new SurrogateProblem();
1346+      var geneticAlgorithm = new GeneticAlgorithm.GeneticAlgorithm { PopulationSize = { Value = 50 }, Problem = SurrogateProblem, Elites = { Value = 0 } };
1347+      var model = new GaussianProcessRegression { Problem = new RegressionProblem() };
1348+      var strategies = new ItemSet<ISurrogateStrategy> { new InfillStrategy(), new LamarckianStrategy() };
1349+
1350       model.CovarianceFunctionParameter.Value = new CovarianceRationalQuadraticIso();
1351-
1352-      Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluationsParameterName, "", new IntValue(int.MaxValue)));
1353-      Parameters.Add(new FixedValueParameter<IntValue>(InitialEvaluationsParameterName, "", new IntValue(10)));
1354+      Parameters.Add(new FixedValueParameter<IntValue>(InitialEvaluationsParameterName, "The initial number of evaluations performed before the first model is constructed", new IntValue(10)));
1355+      Parameters.Add(new FixedValueParameter<IntValue>(MaximalDataSetSizeParameterName, "The maximum number of sample points used to generate the model. Set 0 or less to use always all samples ", new IntValue(-1)));
1356+      Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluationsParameterName, "The maximum number of evaluations performed", new IntValue(int.MaxValue)));
1357       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)));
1358+      Parameters.Add(new ValueParameter<Algorithm>(OptimizationAlgorithmParameterName, "The algorithm used to solve the expected improvement subproblem", geneticAlgorithm));
1359+      Parameters.Add(new ValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>>(RegressionAlgorithmParameterName, "The model used to approximate the problem", model));
1360+      Parameters.Add(new FixedValueParameter<BoolValue>(RemoveDuplicatesParamterName, "Wether duplicate samples should be replaced by a single sample with an averaged quality. This GREATLY decreases the chance of ill conditioned models (unbuildable models) but is not theoretically sound as the model ignores the increasing certainty in this region"));
1361       Parameters.Add(new FixedValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
1362       Parameters.Add(new FixedValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
1363-      Parameters.Add(new ValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>>(RegressionAlgorithmParameterName, "The model used to approximate the problem", model));
1364-      Parameters.Add(new ValueParameter<Algorithm>(OptimizationAlgorithmParameterName, "The algorithm used to solve the expected improvement subproblem", geneticAlgorithm));
1365-      Parameters.Add(new FixedValueParameter<IntValue>(MaximalDataSetSizeParameterName, "The maximum number of sample points used to generate the model. Set 0 or less to use always all samples ", new IntValue(-1)));
1366-      Parameters.Add(new FixedValueParameter<BoolValue>(RemoveDuplicatesParamterName, "Wether duplicate samples should be replaced by a single sample with an averaged quality. This GREATLY decreases the chance of ill conditioned models (unbuildable models) but is not theoretically sound as the model ignores the increasing certainty in this region"));
1367-      var strategies = new ItemSet<ISurrogateStrategy> { new GenerationalStrategy(), new IndividualStrategy() };
1368       Parameters.Add(new ConstrainedValueParameter<ISurrogateStrategy>(StrategyParameterName, "The surrogate strategy that dictates how the optimization alg is assisted", strategies, strategies.First()));
1369       RegisterEventhandlers();
1370     }
1371     #endregion
1372 
1373+    public void SetInitialSamples(RealVector[] solutions, double[] qualities) {
1374+      InitialSamples = solutions.Zip(qualities, (vector, d) => new Tuple<RealVector, double>(vector, d)).ToList();
1375+    }
1376     protected override void Initialize(CancellationToken cancellationToken) {
1377       base.Initialize(cancellationToken);
1378-      //encoding
1379       var enc = Problem.Encoding as RealVectorEncoding;
1380       if (enc == null) throw new ArgumentException("The SAPBA algorithm can only be applied to RealVectorEncodings");
1381-
1382-      //random
1383       if (SetSeedRandomly) SeedParameter.Value.Value = new System.Random().Next();
1384-      Random.Reset(Seed);
1385-
1386-      //initialize Strategy and Problem
1387       SurrogateStrategy.Initialize(this);
1388-      SurrogateStrategy.UpdateCancellation(cancellationToken);
1389-      surrogateProblem.SetStrategy(SurrogateStrategy);
1390-      surrogateProblem.SetProblem(Problem);
1391+      SurrogateProblem.Initialize(Problem, SurrogateStrategy);
1392     }
1393     protected override void Run(CancellationToken cancellationToken) {
1394-      SurrogateStrategy.UpdateCancellation(cancellationToken);
1395-      try { EgoUtilities.SyncRunSubAlgorithm(OptimizationAlgorithm, Random.Next()); }
1396-      finally { Analyze(); }
1397+      try { SapbaUtilities.SyncRunSubAlgorithm(OptimizationAlgorithm, Seed); }
1398+      finally {
1399+        foreach (var surrogateStrategy in StrategyParameter.ValidValues) surrogateStrategy.Initialize(null);
1400+        OptimizationAlgorithm.Runs.Clear();
1401+      }
1402     }
1403-    private void Analyze() { }
1404 
1405     #region Eventhandling
1406     private void RegisterEventhandlers() {
1407@@ -172,7 +156,7 @@
1408       OptimizationAlgorithmParameter.ValueChanged -= OnOptimizationAlgorithmChanged;
1409     }
1410     private void OnOptimizationAlgorithmChanged(object sender, EventArgs e) {
1411-      OptimizationAlgorithm.Problem = surrogateProblem;
1412+      OptimizationAlgorithm.Problem = SurrogateProblem;
1413     }
1414 
1415     protected override void OnExecutionTimeChanged() {
1416@@ -179,23 +163,18 @@
1417       base.OnExecutionTimeChanged();
1418       if (CancellationTokenSource == null) return;
1419       if (MaximumRuntime == -1) return;
1420-      if (ExecutionTime.TotalSeconds > MaximumRuntime) CancellationTokenSource.Cancel();
1421+      if (ExecutionTime.TotalSeconds > MaximumRuntime) OptimizationAlgorithm.Stop();
1422     }
1423     public override void Pause() {
1424       base.Pause();
1425-      if (RegressionAlgorithm.ExecutionState == ExecutionState.Started) RegressionAlgorithm.Pause();
1426-      if (OptimizationAlgorithm.ExecutionState == ExecutionState.Started) OptimizationAlgorithm.Pause();
1427-
1428+      if (RegressionAlgorithm.ExecutionState == ExecutionState.Started) RegressionAlgorithm.Stop();
1429+      if (OptimizationAlgorithm.ExecutionState == ExecutionState.Started) OptimizationAlgorithm.Stop();
1430     }
1431     public override void Stop() {
1432       base.Stop();
1433-      if (RegressionAlgorithm.ExecutionState == ExecutionState.Started) RegressionAlgorithm.Stop();
1434-      if (OptimizationAlgorithm.ExecutionState == ExecutionState.Started) OptimizationAlgorithm.Stop();
1435+      //if (RegressionAlgorithm.ExecutionState == ExecutionState.Started || RegressionAlgorithm.ExecutionState == ExecutionState.Paused) RegressionAlgorithm.Stop();
1436+      if (OptimizationAlgorithm.ExecutionState == ExecutionState.Started || OptimizationAlgorithm.ExecutionState == ExecutionState.Paused) OptimizationAlgorithm.Stop();
1437     }
1438-    protected override void OnProblemChanged() {
1439-      base.OnProblemChanged();
1440-      surrogateProblem.SetProblem(Problem);
1441-    }
1442     #endregion
1443 
1444   }
Note: See TracBrowser for help on using the repository browser.