Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2886_SymRegGrammarEnumeration/Test/GrammarEnumerationTest.cs @ 15982

Last change on this file since 15982 was 15915, checked in by lkammere, 7 years ago

#2886: Add separate data structure for storing phrases in the queue.

File size: 43.3 KB
Line 
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Linq;
5using HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration;
6using HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration;
7using HeuristicLab.Common;
8using HeuristicLab.Core;
9using HeuristicLab.Problems.DataAnalysis;
10using HeuristicLab.Problems.Instances.DataAnalysis;
11using HeuristicLab.Random;
12using Microsoft.VisualStudio.TestTools.UnitTesting;
13
14namespace HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression {
15  [TestClass]
16  public class MctsSymbolicRegressionTest {
17    private const int Seed = 1234;
18    private IRandom rand;
19
20    private const double SuccessThreshold = 0.9999999;
21
22    private GrammarEnumerationAlgorithm alg;
23    private RegressionProblem problem;
24
25    [TestInitialize]
26    public void InitTest() {
27      rand = new FastRandom(Seed);
28
29      alg = new GrammarEnumerationAlgorithm();
30      problem = new RegressionProblem();
31      alg.Problem = problem;
32      alg.GuiUpdateInterval = int.MaxValue;
33      foreach (IGrammarEnumerationAnalyzer grammarEnumerationAnalyzer in alg.Analyzers) {
34        alg.Analyzers.SetItemCheckedState(grammarEnumerationAnalyzer, grammarEnumerationAnalyzer is RSquaredEvaluator);
35      }
36      alg.SearchDataStructure = StorageType.PriorityQueue;
37    }
38
39    [TestCleanup]
40    public void Cleanup() {
41      if (alg.BestTrainingSentence != null) {
42        Console.WriteLine("Training: " + alg.Grammar.ToInfixString(alg.BestTrainingSentence));
43      }
44    }
45
46
47    private void EvaluateGrammarEnumeration() {
48      // Evaluate results
49      var eps = 1.0 - SuccessThreshold;
50
51      // Check if algorithm terminated correctly
52      Assert.IsTrue(alg.Results.ContainsKey("Best solution (Training)"), "No training solution returned!");
53
54      // Check resultss
55      Assert.AreEqual(1.0, ((IRegressionSolution)alg.Results["Best solution (Training)"].Value).TestRSquared, eps, "Test quality too low!");
56    }
57
58
59    [TestMethod]
60    [TestProperty("Goal", "structure search")]
61    public void NoConstants_Nguyen1() {
62      // x³ + x² + x
63      alg.OptimizeConstants = false;
64      alg.MaxComplexity = 6;
65      alg.Problem.ProblemData = new NguyenFunctionOne(Seed).GenerateRegressionData();
66
67      alg.Start();
68
69      TerminalSymbol constSymbol = alg.Grammar.Const;
70      TerminalSymbol varSymbol = alg.Grammar.VarTerminals.First();
71      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
72      TerminalSymbol addSymbol = alg.Grammar.Addition;
73
74      SymbolString targetSolution = new SymbolString(new[] {
75        constSymbol, varSymbol, varSymbol, varSymbol, mulSymbol, mulSymbol, mulSymbol,
76        constSymbol, varSymbol, varSymbol, mulSymbol, mulSymbol, addSymbol,
77        constSymbol, varSymbol, mulSymbol, addSymbol,
78        constSymbol, addSymbol
79      });
80
81      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
82      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
83
84      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
85
86      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
87
88      // Evaluate
89      EvaluateGrammarEnumeration();
90    }
91
92    // Too "large" target model for now...
93    //[TestMethod]
94    [TestProperty("Goal", "structure search")]
95    public void NoConstants_Nguyen2() {
96      // x^4 + x³ + x² + x
97      alg.MaxComplexity = 11;
98      alg.Problem.ProblemData = new NguyenFunctionTwo(Seed).GenerateRegressionData();
99
100      alg.Start();
101      EvaluateGrammarEnumeration();
102    }
103
104    // Too "large" target model for now...
105    //[TestMethod]
106    [TestProperty("Goal", "structure search")]
107    public void NoConstants_Nguyen3() {
108      // x^5 + x^4 + x^3 + x^2 + x
109      alg.MaxComplexity = 32;
110      alg.Problem.ProblemData = new NguyenFunctionThree(Seed).GenerateRegressionData();
111
112      alg.Start();
113
114      EvaluateGrammarEnumeration();
115    }
116
117    [TestMethod]
118    [TestProperty("Goal", "structure search")]
119    public void NoConstants_Nguyen6() {
120      // sin(x) + sin(x + x²)
121      alg.OptimizeConstants = false;
122      alg.MaxComplexity = 4;
123      alg.Problem.ProblemData = new NguyenFunctionSix(Seed).GenerateRegressionData();
124
125      alg.Start();
126
127      TerminalSymbol constSymbol = alg.Grammar.Const;
128      TerminalSymbol varSymbol = alg.Grammar.VarTerminals.First();
129      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
130      TerminalSymbol addSymbol = alg.Grammar.Addition;
131      TerminalSymbol sinSymbol = alg.Grammar.Sin;
132
133      // c * sin(c x + c) + c * sin(c * x * x + c * x) + c
134      SymbolString targetSolution = new SymbolString(new[] {
135        varSymbol, constSymbol, mulSymbol, constSymbol, addSymbol, sinSymbol, constSymbol, mulSymbol,
136        varSymbol, varSymbol, mulSymbol, constSymbol, mulSymbol, varSymbol, constSymbol, mulSymbol, addSymbol, constSymbol, addSymbol, sinSymbol, constSymbol, mulSymbol, addSymbol,
137        constSymbol, addSymbol
138      });
139
140      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
141      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
142
143      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
144      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
145
146      EvaluateGrammarEnumeration();
147    }
148
149    [TestMethod]
150    [TestProperty("Goal", "structure search")]
151    public void NoConstants_Nguyen9() {
152      // sin(x) + sin(y²)   
153      alg.OptimizeConstants = false;
154      alg.MaxComplexity = 3;
155      alg.Problem.ProblemData = new NguyenFunctionNine(Seed).GenerateRegressionData();
156
157      alg.Start();
158
159      TerminalSymbol xSymbol = alg.Grammar.VarTerminals.First(v => v.StringRepresentation == "X");
160      TerminalSymbol ySymbol = alg.Grammar.VarTerminals.First(v => v.StringRepresentation == "Y");
161      TerminalSymbol constSymbol = alg.Grammar.Const;
162      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
163      TerminalSymbol addSymbol = alg.Grammar.Addition;
164      TerminalSymbol sinSymbol = alg.Grammar.Sin;
165
166      // c*sin(c*x + c) + c*sin(c*y*y + c) + c
167      SymbolString targetSolution = new SymbolString(new[] {
168        xSymbol, constSymbol, mulSymbol, constSymbol, addSymbol, sinSymbol, constSymbol, mulSymbol,
169        ySymbol, ySymbol, mulSymbol, constSymbol, mulSymbol, constSymbol, addSymbol, sinSymbol, constSymbol, mulSymbol, addSymbol,
170        constSymbol, addSymbol
171      });
172
173      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
174      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
175
176      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
177      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
178
179      EvaluateGrammarEnumeration();
180    }
181
182    // Too much variables for now...
183    //[TestMethod]
184    [TestProperty("Goal", "structure search")]
185    public void MctsSymbReg_NoConstants_Poly10() {
186      alg.MaxComplexity = 10;
187      alg.Problem.ProblemData = new PolyTen(Seed).GenerateRegressionData();
188
189      alg.Start();
190      EvaluateGrammarEnumeration();
191    }
192
193    [TestMethod]
194    [TestProperty("Goal", "structure search")]
195    public void NoConstants_Inverse() {
196      // x / (log(x)*x + x)
197      alg.OptimizeConstants = false;
198      alg.MaxComplexity = 4;
199
200      var x = Enumerable.Range(0, 100).Select(_ => rand.NextDouble() + 1.1).ToList();
201      var y = x.Select(xi => xi / (Math.Log(xi) * xi + xi)).ToList();
202      alg.Problem.ProblemData = new RegressionProblemData(new Dataset(new List<string>() { "x", "y" }, new List<IList>() { x, y }), "x".ToEnumerable(), "y");
203
204      alg.Start();
205      EvaluateGrammarEnumeration();
206    }
207
208    [TestMethod]
209    [TestProperty("Goal", "structure search + const op")]
210    public void Constants_Nguyen7() {
211      // log(x+1) + log(x*x + 1)
212      alg.MaxComplexity = 4;
213      alg.OptimizeConstants = true;
214      alg.Problem.ProblemData = new NguyenFunctionSeven().GenerateRegressionData();
215
216      alg.Start();
217
218      TerminalSymbol constSymbol = alg.Grammar.Const;
219      TerminalSymbol varSymbol = alg.Grammar.VarTerminals.First();
220      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
221      TerminalSymbol addSymbol = alg.Grammar.Addition;
222      TerminalSymbol logSymbol = alg.Grammar.Log;
223
224      SymbolString targetSolution = new SymbolString(new[] {
225        varSymbol, constSymbol, mulSymbol, constSymbol, addSymbol, logSymbol, constSymbol, mulSymbol,
226        varSymbol, varSymbol, mulSymbol, constSymbol, mulSymbol, constSymbol, addSymbol, logSymbol, constSymbol, mulSymbol, addSymbol,
227        constSymbol, addSymbol
228      });
229
230      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
231      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
232
233      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
234      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
235
236      // Evaluate
237      EvaluateGrammarEnumeration();
238    }
239
240    [TestMethod]
241    [TestProperty("Goal", "structure search + const op")]
242    public void Constants_Nguyen12() {
243      // x*x*x*x - x*x*x + y*y/2 -y
244      alg.MaxComplexity = 10;
245      alg.OptimizeConstants = true;
246      alg.Problem.ProblemData = new NguyenFunctionTwelve().GenerateRegressionData();
247
248      alg.Start();
249
250      // Evaluate
251      EvaluateGrammarEnumeration();
252    }
253
254    [TestMethod]
255    [TestProperty("Goal", "sinnus const op")]
256    public void Constants_Keijzer3() {
257      // 0.3*x*sin(2*pi*x)
258      alg.MaxComplexity = 2;
259      alg.Problem.ProblemData = new KeijzerFunctionThree().GenerateRegressionData();
260
261      alg.Start();
262
263      TerminalSymbol constSymbol = alg.Grammar.Const;
264      TerminalSymbol varSymbol = alg.Grammar.VarTerminals.First();
265      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
266      TerminalSymbol addSymbol = alg.Grammar.Addition;
267
268      SymbolString targetSolution = new SymbolString(new[] {
269        constSymbol, varSymbol, mulSymbol, constSymbol, addSymbol, alg.Grammar.Sin,
270        varSymbol, mulSymbol,
271        constSymbol, mulSymbol,
272        constSymbol, addSymbol
273      });
274
275      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
276      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
277
278      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
279      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
280
281      // Evaluate
282      EvaluateGrammarEnumeration();
283    }
284
285    [TestMethod]
286    [TestProperty("Goal", "structure search + const op")]
287    public void Constants_Keijzer5() {
288      // (30*x*z) / ((x - 10)*y*y)
289      alg.MaxComplexity = 5;
290      alg.OptimizeConstants = true;
291      alg.Problem.ProblemData = new KeijzerFunctionFive().GenerateRegressionData();
292
293      alg.Start();
294
295      TerminalSymbol constSymbol = alg.Grammar.Const;
296      TerminalSymbol xSymbol = alg.Grammar.VarTerminals.First(s => s.StringRepresentation == "X");
297      TerminalSymbol ySymbol = alg.Grammar.VarTerminals.First(s => s.StringRepresentation == "Y");
298      TerminalSymbol zSymbol = alg.Grammar.VarTerminals.First(s => s.StringRepresentation == "Z");
299      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
300      TerminalSymbol addSymbol = alg.Grammar.Addition;
301      TerminalSymbol invSymbol = alg.Grammar.Inv;
302
303      // 30 * x * z * 1/(x*y*y - 10*y*y)
304      // --> x z * c *     x y * y * c *  y y * c * + c + inv c +
305      SymbolString targetSolution = new SymbolString(new[] {
306        xSymbol, zSymbol, mulSymbol, constSymbol, mulSymbol,
307        xSymbol, ySymbol, mulSymbol, ySymbol, mulSymbol, constSymbol, mulSymbol,
308        ySymbol, ySymbol, mulSymbol, constSymbol, mulSymbol, addSymbol, constSymbol, addSymbol, invSymbol,
309        constSymbol, addSymbol
310      });
311
312      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
313      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
314
315      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
316
317      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
318
319      // Evaluate
320      EvaluateGrammarEnumeration();
321    }
322
323
324    [TestMethod]
325    [TestProperty("Goal", "structure search + const op")]
326    public void Constants_Keijzer12() {
327      // x*x*x*x - x*x*x + y*y/2 - y
328      alg.MaxComplexity = 10;
329      alg.Problem.ProblemData = new KeijzerFunctionTwelve().GenerateRegressionData();
330
331      alg.Start();
332
333      TerminalSymbol constSymbol = alg.Grammar.Const;
334      TerminalSymbol xSymbol = alg.Grammar.VarTerminals.First();
335      TerminalSymbol ySymbol = alg.Grammar.VarTerminals.Last();
336      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
337      TerminalSymbol addSymbol = alg.Grammar.Addition;
338
339      SymbolString targetSolution = new SymbolString(new[] {
340        xSymbol, xSymbol, mulSymbol, xSymbol, mulSymbol, xSymbol, mulSymbol, constSymbol, mulSymbol,
341        xSymbol, xSymbol, mulSymbol, xSymbol, mulSymbol, constSymbol, mulSymbol, addSymbol,
342        ySymbol, ySymbol, mulSymbol, constSymbol, mulSymbol, addSymbol,
343        ySymbol, constSymbol, mulSymbol, addSymbol,
344        constSymbol, addSymbol
345      });
346
347      var x = alg.Grammar.ToInfixString(targetSolution);
348
349      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
350      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
351
352      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
353      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
354
355      // Evaluate
356      EvaluateGrammarEnumeration();
357    }
358
359    [TestMethod]
360    [TestProperty("Goal", "structure search + const op")]
361    public void Constants_Keijzer14() {
362      // 8 / (2 + x*x + y*y)
363      alg.MaxComplexity = 4;
364      alg.OptimizeConstants = true;
365      alg.Problem.ProblemData = new KeijzerFunctionFourteen().GenerateRegressionData();
366
367      alg.Start();
368
369      TerminalSymbol constSymbol = alg.Grammar.Const;
370      TerminalSymbol xSymbol = alg.Grammar.VarTerminals.First();
371      TerminalSymbol ySymbol = alg.Grammar.VarTerminals.Last();
372      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
373      TerminalSymbol addSymbol = alg.Grammar.Addition;
374      TerminalSymbol divSymbol = alg.Grammar.Inv;
375
376
377      // x x mul c mul y y mul c mul add const add inv const mul const add
378      SymbolString targetSolution = new SymbolString(new[] {
379        xSymbol, xSymbol, mulSymbol, constSymbol, mulSymbol,
380        ySymbol, ySymbol, mulSymbol, constSymbol, mulSymbol, addSymbol,
381        constSymbol, addSymbol, divSymbol,
382        constSymbol, mulSymbol,
383        constSymbol, addSymbol
384      });
385
386      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
387      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
388
389      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
390      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
391
392      // Evaluate
393      EvaluateGrammarEnumeration();
394    }
395
396
397    [TestMethod]
398    [TestProperty("Goal", "structure search + const op")]
399    public void Constants_Keijzer15() {
400      // x*x*x / 5 + y*y*y / 2 - y - x
401      alg.MaxComplexity = 8;
402      alg.OptimizeConstants = true;
403      alg.Problem.ProblemData = new KeijzerFunctionFifteen().GenerateRegressionData();
404
405      alg.Start();
406
407      TerminalSymbol constSymbol = alg.Grammar.Const;
408      TerminalSymbol xSymbol = alg.Grammar.VarTerminals.First();
409      TerminalSymbol ySymbol = alg.Grammar.VarTerminals.Last();
410      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
411      TerminalSymbol addSymbol = alg.Grammar.Addition;
412
413      // x x * x * const * y y * y * const * + y const * + x const * const +
414      SymbolString targetSolution = new SymbolString(new[] {
415        xSymbol, xSymbol, mulSymbol, xSymbol, mulSymbol, constSymbol, mulSymbol,
416        ySymbol, ySymbol, mulSymbol, ySymbol, mulSymbol, constSymbol, mulSymbol, addSymbol,
417        ySymbol, constSymbol, mulSymbol, addSymbol,
418        xSymbol, constSymbol, mulSymbol, addSymbol,
419        constSymbol, addSymbol
420      });
421
422      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
423      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
424
425      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
426      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
427
428      // Evaluate
429      EvaluateGrammarEnumeration();
430    }
431
432    [TestMethod]
433    [TestProperty("Goal", "Poly-10 derivatives")]
434    public void MctsSymbReg_NoConstants_Poly10_Part1() {
435      alg.MaxComplexity = 12;
436      alg.OptimizeConstants = false;
437      var regProblem = new PolyTen(123).GenerateRegressionData();
438
439      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
440      //  Y' = X1*X2 + X3*X4 + X5*X6
441      // simplify problem by changing target
442      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
443      var ys = ds.GetDoubleValues("Y").ToArray();
444      var x1 = ds.GetDoubleValues("X1").ToArray();
445      var x2 = ds.GetDoubleValues("X2").ToArray();
446      var x3 = ds.GetDoubleValues("X3").ToArray();
447      var x4 = ds.GetDoubleValues("X4").ToArray();
448      var x5 = ds.GetDoubleValues("X5").ToArray();
449      var x6 = ds.GetDoubleValues("X6").ToArray();
450      var x7 = ds.GetDoubleValues("X7").ToArray();
451      var x8 = ds.GetDoubleValues("X8").ToArray();
452      var x9 = ds.GetDoubleValues("X9").ToArray();
453      var x10 = ds.GetDoubleValues("X10").ToArray();
454      for (int i = 0; i < ys.Length; i++) {
455        //ys[i] -= x1[i] * x7[i] * x9[i];
456        //ys[i] -= x3[i] * x6[i] * x10[i];
457      }
458      ds.ReplaceVariable("Y", ys.ToList());
459
460      alg.Problem.ProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
461
462      alg.Start();
463
464      EvaluateGrammarEnumeration();
465    }
466
467
468
469
470#if false
471
472    [TestMethod]
473    [TestProperty("Goal", "structure search")]
474    public void MctsSymbReg_NoConstants_15() {
475      alg.MaxTreeSize = 5;
476      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
477      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("15")));
478      alg.Problem.ProblemData = regProblem;
479
480      alg.Start();
481      EvaluateGrammarEnumeration();
482    }
483
484
485    [TestMethod]
486    [TestCategory("Algorithms.DataAnalysis")]
487    [TestProperty("Time", "short")]
488    public void MctsSymbReg_NoConstants_Nguyen7() {
489      // log(x + 1) + log(x² + 1)
490      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
491      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F7 ")));
492      TestGrammarEnumeration(regProblem);
493    }
494
495    [TestMethod]
496    [TestCategory("Algorithms.DataAnalysis")]
497    [TestProperty("Time", "short")]
498    public void MctsSymbReg_NoConstants_Poly10_Part1() {
499      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
500      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
501
502      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
503      //  Y' = X1*X2 + X3*X4 + X5*X6
504      // simplify problem by changing target
505      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
506      var ys = ds.GetDoubleValues("Y").ToArray();
507      var x1 = ds.GetDoubleValues("X1").ToArray();
508      var x2 = ds.GetDoubleValues("X2").ToArray();
509      var x3 = ds.GetDoubleValues("X3").ToArray();
510      var x4 = ds.GetDoubleValues("X4").ToArray();
511      var x5 = ds.GetDoubleValues("X5").ToArray();
512      var x6 = ds.GetDoubleValues("X6").ToArray();
513      var x7 = ds.GetDoubleValues("X7").ToArray();
514      var x8 = ds.GetDoubleValues("X8").ToArray();
515      var x9 = ds.GetDoubleValues("X9").ToArray();
516      var x10 = ds.GetDoubleValues("X10").ToArray();
517      for (int i = 0; i < ys.Length; i++) {
518        ys[i] -= x1[i] * x7[i] * x9[i];
519        ys[i] -= x3[i] * x6[i] * x10[i];
520      }
521      ds.ReplaceVariable("Y", ys.ToList());
522
523      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
524
525      TestGrammarEnumeration(modifiedProblemData);
526    }
527
528    [TestMethod]
529    [TestCategory("Algorithms.DataAnalysis")]
530    [TestProperty("Time", "short")]
531    public void MctsSymbReg_NoConstants_Poly10_Part2() {
532      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
533      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
534
535      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
536      //  Y' = X1*X7*X9 + X3*X6*X10
537      // simplify problem by changing target
538      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
539      var ys = ds.GetDoubleValues("Y").ToArray();
540      var x1 = ds.GetDoubleValues("X1").ToArray();
541      var x2 = ds.GetDoubleValues("X2").ToArray();                                           
542      var x3 = ds.GetDoubleValues("X3").ToArray();
543      var x4 = ds.GetDoubleValues("X4").ToArray();
544      var x5 = ds.GetDoubleValues("X5").ToArray();
545      var x6 = ds.GetDoubleValues("X6").ToArray();
546      var x7 = ds.GetDoubleValues("X7").ToArray();
547      var x8 = ds.GetDoubleValues("X8").ToArray();
548      var x9 = ds.GetDoubleValues("X9").ToArray();
549      var x10 = ds.GetDoubleValues("X10").ToArray();
550      for (int i = 0; i < ys.Length; i++) {
551        ys[i] -= x1[i] * x2[i];
552        ys[i] -= x3[i] * x4[i];
553        ys[i] -= x5[i] * x6[i];
554      }
555      ds.ReplaceVariable("Y", ys.ToList());
556
557      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
558
559      TestGrammarEnumeration(modifiedProblemData);
560    }
561
562    [TestMethod]
563    [TestCategory("Algorithms.DataAnalysis")]
564    [TestProperty("Time", "short")]
565    public void MctsSymbReg_NoConstants_Poly10_Part3() {
566      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
567      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
568
569      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
570      //  Y' = X1*X2 + X1*X7*X9
571      // simplify problem by changing target
572      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
573      var ys = ds.GetDoubleValues("Y").ToArray();
574      var x1 = ds.GetDoubleValues("X1").ToArray();
575      var x2 = ds.GetDoubleValues("X2").ToArray();
576      var x3 = ds.GetDoubleValues("X3").ToArray();
577      var x4 = ds.GetDoubleValues("X4").ToArray();
578      var x5 = ds.GetDoubleValues("X5").ToArray();
579      var x6 = ds.GetDoubleValues("X6").ToArray();
580      var x7 = ds.GetDoubleValues("X7").ToArray();
581      var x8 = ds.GetDoubleValues("X8").ToArray();
582      var x9 = ds.GetDoubleValues("X9").ToArray();
583      var x10 = ds.GetDoubleValues("X10").ToArray();
584      for (int i = 0; i < ys.Length; i++) {
585        ys[i] -= x3[i] * x4[i];
586        ys[i] -= x5[i] * x6[i];
587        ys[i] -= x3[i] * x6[i] * x10[i];
588      }
589      ds.ReplaceVariable("Y", ys.ToList());
590
591      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
592
593      TestGrammarEnumeration(modifiedProblemData);
594    }
595
596    [TestMethod]
597    [TestCategory("Algorithms.DataAnalysis")]
598    [TestProperty("Time", "short")]
599    public void MctsSymbReg_NoConstants_Poly10_Part4() {
600      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
601      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
602
603      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
604      //  Y' = X3*X4 + X5*X6 + X3*X6*X10
605      // simplify problem by changing target
606      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
607      var ys = ds.GetDoubleValues("Y").ToArray();
608      var x1 = ds.GetDoubleValues("X1").ToArray();
609      var x2 = ds.GetDoubleValues("X2").ToArray();
610      var x3 = ds.GetDoubleValues("X3").ToArray();
611      var x4 = ds.GetDoubleValues("X4").ToArray();
612      var x5 = ds.GetDoubleValues("X5").ToArray();
613      var x6 = ds.GetDoubleValues("X6").ToArray();
614      var x7 = ds.GetDoubleValues("X7").ToArray();
615      var x8 = ds.GetDoubleValues("X8").ToArray();
616      var x9 = ds.GetDoubleValues("X9").ToArray();
617      var x10 = ds.GetDoubleValues("X10").ToArray();
618      for (int i = 0; i < ys.Length; i++) {
619        ys[i] -= x1[i] * x2[i];
620        ys[i] -= x1[i] * x7[i] * x9[i];
621      }
622      ds.ReplaceVariable("Y", ys.ToList());
623      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
624
625
626      TestGrammarEnumeration(modifiedProblemData);
627    }
628
629    [TestMethod]
630    [TestCategory("Algorithms.DataAnalysis")]
631    [TestProperty("Time", "short")]
632    public void MctsSymbReg_NoConstants_Poly10_Part5() {
633      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
634      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
635
636      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
637      //  Y' = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9
638      // simplify problem by changing target
639      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
640      var ys = ds.GetDoubleValues("Y").ToArray();
641      var x1 = ds.GetDoubleValues("X1").ToArray();
642      var x2 = ds.GetDoubleValues("X2").ToArray();
643      var x3 = ds.GetDoubleValues("X3").ToArray();
644      var x4 = ds.GetDoubleValues("X4").ToArray();
645      var x5 = ds.GetDoubleValues("X5").ToArray();
646      var x6 = ds.GetDoubleValues("X6").ToArray();
647      var x7 = ds.GetDoubleValues("X7").ToArray();
648      var x8 = ds.GetDoubleValues("X8").ToArray();
649      var x9 = ds.GetDoubleValues("X9").ToArray();
650      var x10 = ds.GetDoubleValues("X10").ToArray();
651      for (int i = 0; i < ys.Length; i++) {
652        ys[i] -= x3[i] * x6[i] * x10[i];
653      }
654      ds.ReplaceVariable("Y", ys.ToList());
655      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
656
657
658      TestGrammarEnumeration(modifiedProblemData);
659    }
660
661    [TestMethod]
662    [TestCategory("Algorithms.DataAnalysis")]
663    [TestProperty("Time", "short")]
664    public void MctsSymbReg_NoConstants_Poly10_Part6() {
665      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
666      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
667
668      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
669      //  Y' = X1*X2 + X3*X4 + X5*X6 + X3*X6*X10
670      // simplify problem by changing target
671      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
672      var ys = ds.GetDoubleValues("Y").ToArray();
673      var x1 = ds.GetDoubleValues("X1").ToArray();
674      var x2 = ds.GetDoubleValues("X2").ToArray();
675      var x3 = ds.GetDoubleValues("X3").ToArray();
676      var x4 = ds.GetDoubleValues("X4").ToArray();
677      var x5 = ds.GetDoubleValues("X5").ToArray();
678      var x6 = ds.GetDoubleValues("X6").ToArray();
679      var x7 = ds.GetDoubleValues("X7").ToArray();
680      var x8 = ds.GetDoubleValues("X8").ToArray();
681      var x9 = ds.GetDoubleValues("X9").ToArray();
682      var x10 = ds.GetDoubleValues("X10").ToArray();
683      for (int i = 0; i < ys.Length; i++) {
684        ys[i] -= x1[i] * x7[i] * x9[i];
685      }
686      ds.ReplaceVariable("Y", ys.ToList());
687      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
688
689      TestGrammarEnumeration(modifiedProblemData);
690    }
691
692
693    [TestMethod]
694    [TestCategory("Algorithms.DataAnalysis")]
695    [TestProperty("Time", "long")]
696    public void MctsSymbReg_NoConstants_Poly10_250rows() {
697      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
698      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
699      regProblem.TrainingPartition.Start = 0;
700      regProblem.TrainingPartition.End = regProblem.Dataset.Rows;
701      regProblem.TestPartition.Start = 0;
702      regProblem.TestPartition.End = 2;
703      TestGrammarEnumeration(regProblem);
704    }
705
706    [TestMethod]
707    [TestCategory("Algorithms.DataAnalysis")]
708    [TestProperty("Time", "long")]
709    public void MctsSymbReg_NoConstants_Poly10_10000rows() {
710      // as poly-10 but more rows
711      var x1 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
712      var x2 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
713      var x3 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
714      var x4 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
715      var x5 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
716      var x6 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
717      var x7 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
718      var x8 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
719      var x9 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
720      var x10 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
721      var ys = new List<double>();
722      for (int i = 0; i < x1.Count; i++) {
723        ys.Add(x1[i] * x2[i] + x3[i] * x4[i] + x5[i] * x6[i] + x1[i] * x7[i] * x9[i] + x3[i] * x6[i] * x10[i]);
724      }
725
726      var ds = new Dataset(new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "y" },
727        new[] { x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, ys });
728
729
730      var problemData = new RegressionProblemData(ds, new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" }, "y");
731
732      problemData.TrainingPartition.Start = 0;
733      problemData.TrainingPartition.End = problemData.Dataset.Rows;
734      problemData.TestPartition.Start = 0;
735      problemData.TestPartition.End = 2; // must not be empty
736
737
738      TestGrammarEnumeration(problemData);
739    }
740
741    [TestMethod]
742    [TestCategory("Algorithms.DataAnalysis")]
743    [TestProperty("Time", "short")]
744    public void MctsSymbReg_NoConstants_TwoVars() {
745
746      // y = x1 + x2 + x1*x2 + x1*x2*x2 + x1*x1*x2
747      var x1 = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
748      var x2 = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
749      var ys = x1.Zip(x2, (x1i, x2i) => x1i + x2i + x1i * x2i + x1i * x2i * x2i + x1i * x1i * x2i).ToList();
750
751      var ds = new Dataset(new string[] { "a", "b", "y" }, new[] { x1, x2, ys });
752      var problemData = new RegressionProblemData(ds, new string[] { "a", "b" }, "y");
753
754      TestGrammarEnumeration(problemData);
755    }
756
757    [TestMethod]
758    [TestCategory("Algorithms.DataAnalysis")]
759    [TestProperty("Time", "short")]
760    public void MctsSymbReg_NoConstants_Misleading() {
761
762      // y = a + baaaaa (the effect of the second term should be very small)
763      // the alg will quickly find that a has big effect and will search below a
764      // since we prevent a + a... the algorithm must find the correct expression via a + b...
765      // however b has a small effect so the branch might not be identified as relevant
766      var @as = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
767      var bs = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
768      var cs = Enumerable.Range(0, 100).Select(_ => rand.NextDouble() * 1.0e-3).ToList();
769      var ds = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
770      var es = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
771      var ys = new double[@as.Count];
772      for (int i = 0; i < ys.Length; i++)
773        ys[i] = @as[i] + bs[i] + @as[i] * bs[i] * cs[i];
774
775      var dataset = new Dataset(new string[] { "a", "b", "c", "d", "e", "y" }, new[] { @as, bs, cs, ds, es, ys.ToList() });
776
777      var problemData = new RegressionProblemData(dataset, new string[] { "a", "b", "c", "d", "e" }, "y");
778
779      TestGrammarEnumeration(problemData);
780    }
781
782    [TestMethod]
783    [TestCategory("Algorithms.DataAnalysis")]
784    [TestProperty("Time", "short")]
785    public void MctsSymbRegKeijzer7() {
786      // ln(x)
787      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
788      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 7 f(")));
789      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
790      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
791      TestGrammarEnumeration(regProblem);
792    }
793
794   
795    [TestMethod]
796    [TestCategory("Algorithms.DataAnalysis")]
797    [TestProperty("Time", "short")]
798    public void MctsSymbRegBenchmarkNguyen5() {
799      // sin(x²)cos(x) - 1
800      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
801      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F5 ")));
802      TestGrammarEnumeration(regProblem);
803    }
804
805    [TestMethod]
806    [TestCategory("Algorithms.DataAnalysis")]
807    [TestProperty("Time", "short")]
808    public void MctsSymbRegBenchmarkNguyen6() {
809      // sin(x) + sin(x + x²)
810      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
811      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F6 ")));
812      TestGrammarEnumeration(regProblem);
813    }
814   
815    [TestMethod]
816    [TestCategory("Algorithms.DataAnalysis")]
817    [TestProperty("Time", "short")]
818    public void MctsSymbRegBenchmarkNguyen7() {
819      //  log(x + 1) + log(x² + 1)
820      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
821      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F7 ")));
822      TestGrammarEnumeration(regProblem);
823    }
824    [TestMethod]
825    [TestCategory("Algorithms.DataAnalysis")]
826    [TestProperty("Time", "short")]
827    public void MctsSymbRegBenchmarkNguyen8() {
828      // Sqrt(x)
829      // = x ^ 0.5
830      // = exp(0.5 * log(x))
831      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
832      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F8 ")));
833      TestGrammarEnumeration(regProblem);
834    }
835   
836    // [TestMethod]
837    [TestCategory("Algorithms.DataAnalysis")]
838    [TestProperty("Time", "short")]
839    public void MctsSymbRegBenchmarkNguyen9() {
840      //  sin(x) + sin(y²)
841      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
842      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F9 ")));
843      TestGrammarEnumeration(regProblem);
844    }
845
846    // [TestMethod]
847    [TestCategory("Algorithms.DataAnalysis")]
848    [TestProperty("Time", "short")]
849    public void MctsSymbRegBenchmarkNguyen10() {
850      // 2sin(x)cos(y)
851      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
852      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F10 ")));
853      TestGrammarEnumeration(regProblem);
854    }
855   
856    [TestMethod]
857    [TestCategory("Algorithms.DataAnalysis")]
858    [TestProperty("Time", "short")]
859    public void MctsSymbRegBenchmarkNguyen11() {
860      // x ^ y  , x > 0, y > 0   
861      // = exp(y * log(x))
862      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
863      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F11 ")));
864      TestGrammarEnumeration(regProblem);
865    }
866    [TestMethod]
867    [TestCategory("Algorithms.DataAnalysis")]
868    [TestProperty("Time", "short")]
869    public void MctsSymbRegBenchmarkNguyen12() {
870      // x^4 - x³ + y²/2 - y
871      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
872      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F12 ")));
873      TestGrammarEnumeration(regProblem);
874    }
875
876    [TestMethod]
877    [TestCategory("Algorithms.DataAnalysis")]
878    [TestProperty("Time", "long")]
879    public void MctsSymbRegBenchmarkKeijzer5() {
880      // (30 * x * z) / ((x - 10)  * y²)
881      // = 30 x z / (xy² - y²)
882      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
883      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 5 f(")));
884      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
885      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
886      TestGrammarEnumeration(regProblem);
887    }
888
889    [TestMethod]
890    [TestCategory("Algorithms.DataAnalysis")]
891    [TestProperty("Time", "short")]
892    public void MctsSymbRegBenchmarkKeijzer6() {
893      // Keijzer 6 f(x) = Sum(1 / i) From 1 to X  , x \in [0..120]
894      // we can only approximate this
895      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
896      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 6 f(")));
897      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
898      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
899      TestGrammarEnumeration(regProblem);
900    }
901
902    [TestMethod]
903    [TestCategory("Algorithms.DataAnalysis")]
904    [TestProperty("Time", "short")]
905    public void MctsSymbRegBenchmarkKeijzer8() {
906      // sqrt(x)
907      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
908      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 8 f(")));
909      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
910      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
911      TestGrammarEnumeration(regProblem);
912    }
913
914    [TestMethod]
915    [TestCategory("Algorithms.DataAnalysis")]
916    [TestProperty("Time", "short")]
917    public void MctsSymbRegBenchmarkKeijzer9() {
918      // arcsinh(x)  i.e. ln(x + sqrt(x² + 1))
919      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
920      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 9 f(")));
921      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
922      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
923      TestGrammarEnumeration(regProblem);
924    }
925
926    [TestMethod]
927    [TestCategory("Algorithms.DataAnalysis")]
928    [TestProperty("Time", "short")]
929    public void MctsSymbRegBenchmarkKeijzer11() {
930      // xy + sin( (x-1) (y-1) )
931      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider();
932      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 11 f(")));
933      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
934      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
935      TestGrammarEnumeration(regProblem);
936    }
937
938    [TestMethod]
939    [TestCategory("Algorithms.DataAnalysis")]
940    [TestProperty("Time", "short")]
941    public void MctsSymbRegBenchmarkKeijzer12() {
942      // x^4 - x³ + y² / 2 - y,  same as Nguyen 12             
943      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
944      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 12 f(")));
945      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
946      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
947      TestGrammarEnumeration(regProblem);
948    }
949
950    [TestMethod]
951    [TestCategory("Algorithms.DataAnalysis")]
952    [TestProperty("Time", "short")]
953    public void MctsSymbRegBenchmarkKeijzer14() {
954      // 8 / (2 + x² + y²)
955      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
956      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 14 f(")));
957      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
958      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
959      TestGrammarEnumeration(regProblem);
960    }
961
962    [TestMethod]
963    [TestCategory("Algorithms.DataAnalysis")]
964    [TestProperty("Time", "short")]
965    public void MctsSymbRegBenchmarkKeijzer15() {
966      // x³ / 5 + y³ / 2 - y - x
967      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
968      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 15 f(")));
969      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
970      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
971      TestGrammarEnumeration(regProblem);
972    }
973#endif
974  }
975}
Note: See TracBrowser for help on using the repository browser.