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

Last change on this file since 15907 was 15907, checked in by lkammere, 4 years ago

#2886: Changes in search heuristic for solving Poly-10 problem. Adapt tree evaluation to cover non-terminal symbols.

File size: 43.1 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 = 3;
213      alg.Problem.ProblemData = new NguyenFunctionSeven().GenerateRegressionData();
214
215      alg.Start();
216
217      TerminalSymbol constSymbol = alg.Grammar.Const;
218      TerminalSymbol varSymbol = alg.Grammar.VarTerminals.First();
219      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
220      TerminalSymbol addSymbol = alg.Grammar.Addition;
221      TerminalSymbol logSymbol = alg.Grammar.Log;
222
223      SymbolString targetSolution = new SymbolString(new[] {
224        varSymbol, constSymbol, mulSymbol, constSymbol, addSymbol, logSymbol, constSymbol, mulSymbol,
225        varSymbol, varSymbol, mulSymbol, constSymbol, mulSymbol, constSymbol, addSymbol, logSymbol, constSymbol, mulSymbol, addSymbol,
226        constSymbol, addSymbol
227      });
228
229      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
230      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
231
232      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
233      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
234
235      // Evaluate
236      EvaluateGrammarEnumeration();
237    }
238
239    [TestMethod]
240    [TestProperty("Goal", "structure search + const op")]
241    public void Constants_Nguyen12() {
242      // x*x*x*x - x*x*x + y*y/2 -y
243      alg.MaxComplexity = 10;
244      alg.Problem.ProblemData = new NguyenFunctionTwelve().GenerateRegressionData();
245
246      alg.Start();
247
248      // Evaluate
249      EvaluateGrammarEnumeration();
250    }
251
252    [TestMethod]
253    [TestProperty("Goal", "sinnus const op")]
254    public void Constants_Keijzer3() {
255      // 0.3*x*sin(2*pi*x)
256      alg.MaxComplexity = 2;
257      alg.Problem.ProblemData = new KeijzerFunctionThree().GenerateRegressionData();
258
259      alg.Start();
260
261      TerminalSymbol constSymbol = alg.Grammar.Const;
262      TerminalSymbol varSymbol = alg.Grammar.VarTerminals.First();
263      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
264      TerminalSymbol addSymbol = alg.Grammar.Addition;
265
266      SymbolString targetSolution = new SymbolString(new[] {
267        constSymbol, varSymbol, mulSymbol, constSymbol, addSymbol, alg.Grammar.Sin,
268        varSymbol, mulSymbol,
269        constSymbol, mulSymbol,
270        constSymbol, addSymbol
271      });
272
273      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
274      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
275
276      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
277      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
278
279      // Evaluate
280      EvaluateGrammarEnumeration();
281    }
282
283    [TestMethod]
284    [TestProperty("Goal", "structure search + const op")]
285    public void Constants_Keijzer5() {
286      // (30*x*z) / ((x - 10)*y*y)
287      alg.MaxComplexity = 5;
288      alg.Problem.ProblemData = new KeijzerFunctionFive().GenerateRegressionData();
289
290      alg.Start();
291
292      TerminalSymbol constSymbol = alg.Grammar.Const;
293      TerminalSymbol xSymbol = alg.Grammar.VarTerminals.First(s => s.StringRepresentation == "X");
294      TerminalSymbol ySymbol = alg.Grammar.VarTerminals.First(s => s.StringRepresentation == "Y");
295      TerminalSymbol zSymbol = alg.Grammar.VarTerminals.First(s => s.StringRepresentation == "Z");
296      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
297      TerminalSymbol addSymbol = alg.Grammar.Addition;
298      TerminalSymbol invSymbol = alg.Grammar.Inv;
299
300      // 30 * x * z * 1/(x*y*y - 10*y*y)
301      // --> x z * c *     x y * y * c *  y y * c * + c + inv c +
302      SymbolString targetSolution = new SymbolString(new[] {
303        xSymbol, zSymbol, mulSymbol, constSymbol, mulSymbol,
304        xSymbol, ySymbol, mulSymbol, ySymbol, mulSymbol, constSymbol, mulSymbol,
305        ySymbol, ySymbol, mulSymbol, constSymbol, mulSymbol, addSymbol, constSymbol, addSymbol, invSymbol,
306        constSymbol, addSymbol
307      });
308
309      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
310      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
311
312      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
313
314      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
315
316      // Evaluate
317      EvaluateGrammarEnumeration();
318    }
319
320
321    [TestMethod]
322    [TestProperty("Goal", "structure search + const op")]
323    public void Constants_Keijzer12() {
324      // x*x*x*x - x*x*x + y*y/2 - y
325      alg.MaxComplexity = 10;
326      alg.Problem.ProblemData = new KeijzerFunctionTwelve().GenerateRegressionData();
327
328      alg.Start();
329
330      TerminalSymbol constSymbol = alg.Grammar.Const;
331      TerminalSymbol xSymbol = alg.Grammar.VarTerminals.First();
332      TerminalSymbol ySymbol = alg.Grammar.VarTerminals.Last();
333      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
334      TerminalSymbol addSymbol = alg.Grammar.Addition;
335
336      SymbolString targetSolution = new SymbolString(new[] {
337        xSymbol, xSymbol, mulSymbol, xSymbol, mulSymbol, xSymbol, mulSymbol, constSymbol, mulSymbol,
338        xSymbol, xSymbol, mulSymbol, xSymbol, mulSymbol, constSymbol, mulSymbol, addSymbol,
339        ySymbol, ySymbol, mulSymbol, constSymbol, mulSymbol, addSymbol,
340        ySymbol, constSymbol, mulSymbol, addSymbol,
341        constSymbol, addSymbol
342      });
343
344      var x = alg.Grammar.ToInfixString(targetSolution);
345
346      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
347      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
348
349      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
350      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
351
352      // Evaluate
353      EvaluateGrammarEnumeration();
354    }
355
356    [TestMethod]
357    [TestProperty("Goal", "structure search + const op")]
358    public void Constants_Keijzer14() {
359      // 8 / (2 + x*x + y*y
360      alg.MaxComplexity = 4;
361      alg.Problem.ProblemData = new KeijzerFunctionFourteen().GenerateRegressionData();
362
363      alg.Start();
364
365      TerminalSymbol constSymbol = alg.Grammar.Const;
366      TerminalSymbol xSymbol = alg.Grammar.VarTerminals.First();
367      TerminalSymbol ySymbol = alg.Grammar.VarTerminals.Last();
368      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
369      TerminalSymbol addSymbol = alg.Grammar.Addition;
370      TerminalSymbol divSymbol = alg.Grammar.Inv;
371
372
373      // x x mul c mul y y mul c mul add const add inv const mul const add
374      SymbolString targetSolution = new SymbolString(new[] {
375        xSymbol, xSymbol, mulSymbol, constSymbol, mulSymbol,
376        ySymbol, ySymbol, mulSymbol, constSymbol, mulSymbol, addSymbol,
377        constSymbol, addSymbol, divSymbol,
378        constSymbol, mulSymbol,
379        constSymbol, addSymbol
380      });
381
382      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
383      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
384
385      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
386      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
387
388      // Evaluate
389      EvaluateGrammarEnumeration();
390    }
391
392
393    [TestMethod]
394    [TestProperty("Goal", "structure search + const op")]
395    public void Constants_Keijzer15() {
396      // x*x*x / 5 + y*y*y / 2 - y - x
397      alg.MaxComplexity = 8;
398      alg.Problem.ProblemData = new KeijzerFunctionFifteen().GenerateRegressionData();
399
400      alg.Start();
401
402      TerminalSymbol constSymbol = alg.Grammar.Const;
403      TerminalSymbol xSymbol = alg.Grammar.VarTerminals.First();
404      TerminalSymbol ySymbol = alg.Grammar.VarTerminals.Last();
405      TerminalSymbol mulSymbol = alg.Grammar.Multiplication;
406      TerminalSymbol addSymbol = alg.Grammar.Addition;
407
408      // x x * x * const * y y * y * const * + y const * + x const * const +
409      SymbolString targetSolution = new SymbolString(new[] {
410        xSymbol, xSymbol, mulSymbol, xSymbol, mulSymbol, constSymbol, mulSymbol,
411        ySymbol, ySymbol, mulSymbol, ySymbol, mulSymbol, constSymbol, mulSymbol, addSymbol,
412        ySymbol, constSymbol, mulSymbol, addSymbol,
413        xSymbol, constSymbol, mulSymbol, addSymbol,
414        constSymbol, addSymbol
415      });
416
417      int targetSolutionHash = alg.Grammar.Hasher.CalcHashCode(targetSolution);
418      int actualSolutionHash = alg.Grammar.Hasher.CalcHashCode(alg.BestTrainingSentence);
419
420      Assert.IsTrue(alg.DistinctSentencesComplexity.ContainsKey(targetSolutionHash), "Actual solution was not generated!");
421      Assert.AreEqual(targetSolutionHash, actualSolutionHash, "Actual solution was not recognized as best one.");
422
423      // Evaluate
424      EvaluateGrammarEnumeration();
425    }
426
427    [TestMethod]
428    [TestProperty("Goal", "Poly-10 derivatives")]
429    public void MctsSymbReg_NoConstants_Poly10_Part1() {
430      alg.MaxComplexity = 12;
431      alg.OptimizeConstants = false;
432      var regProblem = new PolyTen(123).GenerateRegressionData();
433
434      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
435      //  Y' = X1*X2 + X3*X4 + X5*X6
436      // simplify problem by changing target
437      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
438      var ys = ds.GetDoubleValues("Y").ToArray();
439      var x1 = ds.GetDoubleValues("X1").ToArray();
440      var x2 = ds.GetDoubleValues("X2").ToArray();
441      var x3 = ds.GetDoubleValues("X3").ToArray();
442      var x4 = ds.GetDoubleValues("X4").ToArray();
443      var x5 = ds.GetDoubleValues("X5").ToArray();
444      var x6 = ds.GetDoubleValues("X6").ToArray();
445      var x7 = ds.GetDoubleValues("X7").ToArray();
446      var x8 = ds.GetDoubleValues("X8").ToArray();
447      var x9 = ds.GetDoubleValues("X9").ToArray();
448      var x10 = ds.GetDoubleValues("X10").ToArray();
449      for (int i = 0; i < ys.Length; i++) {
450        //ys[i] -= x1[i] * x7[i] * x9[i];
451        //ys[i] -= x3[i] * x6[i] * x10[i];
452      }
453      ds.ReplaceVariable("Y", ys.ToList());
454
455      alg.Problem.ProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
456
457      alg.Start();
458
459      EvaluateGrammarEnumeration();
460    }
461
462
463
464
465#if false
466
467    [TestMethod]
468    [TestProperty("Goal", "structure search")]
469    public void MctsSymbReg_NoConstants_15() {
470      alg.MaxTreeSize = 5;
471      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
472      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("15")));
473      alg.Problem.ProblemData = regProblem;
474
475      alg.Start();
476      EvaluateGrammarEnumeration();
477    }
478
479
480    [TestMethod]
481    [TestCategory("Algorithms.DataAnalysis")]
482    [TestProperty("Time", "short")]
483    public void MctsSymbReg_NoConstants_Nguyen7() {
484      // log(x + 1) + log(x² + 1)
485      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
486      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F7 ")));
487      TestGrammarEnumeration(regProblem);
488    }
489
490    [TestMethod]
491    [TestCategory("Algorithms.DataAnalysis")]
492    [TestProperty("Time", "short")]
493    public void MctsSymbReg_NoConstants_Poly10_Part1() {
494      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
495      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
496
497      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
498      //  Y' = X1*X2 + X3*X4 + X5*X6
499      // simplify problem by changing target
500      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
501      var ys = ds.GetDoubleValues("Y").ToArray();
502      var x1 = ds.GetDoubleValues("X1").ToArray();
503      var x2 = ds.GetDoubleValues("X2").ToArray();
504      var x3 = ds.GetDoubleValues("X3").ToArray();
505      var x4 = ds.GetDoubleValues("X4").ToArray();
506      var x5 = ds.GetDoubleValues("X5").ToArray();
507      var x6 = ds.GetDoubleValues("X6").ToArray();
508      var x7 = ds.GetDoubleValues("X7").ToArray();
509      var x8 = ds.GetDoubleValues("X8").ToArray();
510      var x9 = ds.GetDoubleValues("X9").ToArray();
511      var x10 = ds.GetDoubleValues("X10").ToArray();
512      for (int i = 0; i < ys.Length; i++) {
513        ys[i] -= x1[i] * x7[i] * x9[i];
514        ys[i] -= x3[i] * x6[i] * x10[i];
515      }
516      ds.ReplaceVariable("Y", ys.ToList());
517
518      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
519
520      TestGrammarEnumeration(modifiedProblemData);
521    }
522
523    [TestMethod]
524    [TestCategory("Algorithms.DataAnalysis")]
525    [TestProperty("Time", "short")]
526    public void MctsSymbReg_NoConstants_Poly10_Part2() {
527      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
528      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
529
530      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
531      //  Y' = X1*X7*X9 + X3*X6*X10
532      // simplify problem by changing target
533      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
534      var ys = ds.GetDoubleValues("Y").ToArray();
535      var x1 = ds.GetDoubleValues("X1").ToArray();
536      var x2 = ds.GetDoubleValues("X2").ToArray();                                           
537      var x3 = ds.GetDoubleValues("X3").ToArray();
538      var x4 = ds.GetDoubleValues("X4").ToArray();
539      var x5 = ds.GetDoubleValues("X5").ToArray();
540      var x6 = ds.GetDoubleValues("X6").ToArray();
541      var x7 = ds.GetDoubleValues("X7").ToArray();
542      var x8 = ds.GetDoubleValues("X8").ToArray();
543      var x9 = ds.GetDoubleValues("X9").ToArray();
544      var x10 = ds.GetDoubleValues("X10").ToArray();
545      for (int i = 0; i < ys.Length; i++) {
546        ys[i] -= x1[i] * x2[i];
547        ys[i] -= x3[i] * x4[i];
548        ys[i] -= x5[i] * x6[i];
549      }
550      ds.ReplaceVariable("Y", ys.ToList());
551
552      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
553
554      TestGrammarEnumeration(modifiedProblemData);
555    }
556
557    [TestMethod]
558    [TestCategory("Algorithms.DataAnalysis")]
559    [TestProperty("Time", "short")]
560    public void MctsSymbReg_NoConstants_Poly10_Part3() {
561      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
562      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
563
564      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
565      //  Y' = X1*X2 + X1*X7*X9
566      // simplify problem by changing target
567      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
568      var ys = ds.GetDoubleValues("Y").ToArray();
569      var x1 = ds.GetDoubleValues("X1").ToArray();
570      var x2 = ds.GetDoubleValues("X2").ToArray();
571      var x3 = ds.GetDoubleValues("X3").ToArray();
572      var x4 = ds.GetDoubleValues("X4").ToArray();
573      var x5 = ds.GetDoubleValues("X5").ToArray();
574      var x6 = ds.GetDoubleValues("X6").ToArray();
575      var x7 = ds.GetDoubleValues("X7").ToArray();
576      var x8 = ds.GetDoubleValues("X8").ToArray();
577      var x9 = ds.GetDoubleValues("X9").ToArray();
578      var x10 = ds.GetDoubleValues("X10").ToArray();
579      for (int i = 0; i < ys.Length; i++) {
580        ys[i] -= x3[i] * x4[i];
581        ys[i] -= x5[i] * x6[i];
582        ys[i] -= x3[i] * x6[i] * x10[i];
583      }
584      ds.ReplaceVariable("Y", ys.ToList());
585
586      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
587
588      TestGrammarEnumeration(modifiedProblemData);
589    }
590
591    [TestMethod]
592    [TestCategory("Algorithms.DataAnalysis")]
593    [TestProperty("Time", "short")]
594    public void MctsSymbReg_NoConstants_Poly10_Part4() {
595      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
596      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
597
598      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
599      //  Y' = X3*X4 + X5*X6 + X3*X6*X10
600      // simplify problem by changing target
601      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
602      var ys = ds.GetDoubleValues("Y").ToArray();
603      var x1 = ds.GetDoubleValues("X1").ToArray();
604      var x2 = ds.GetDoubleValues("X2").ToArray();
605      var x3 = ds.GetDoubleValues("X3").ToArray();
606      var x4 = ds.GetDoubleValues("X4").ToArray();
607      var x5 = ds.GetDoubleValues("X5").ToArray();
608      var x6 = ds.GetDoubleValues("X6").ToArray();
609      var x7 = ds.GetDoubleValues("X7").ToArray();
610      var x8 = ds.GetDoubleValues("X8").ToArray();
611      var x9 = ds.GetDoubleValues("X9").ToArray();
612      var x10 = ds.GetDoubleValues("X10").ToArray();
613      for (int i = 0; i < ys.Length; i++) {
614        ys[i] -= x1[i] * x2[i];
615        ys[i] -= x1[i] * x7[i] * x9[i];
616      }
617      ds.ReplaceVariable("Y", ys.ToList());
618      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
619
620
621      TestGrammarEnumeration(modifiedProblemData);
622    }
623
624    [TestMethod]
625    [TestCategory("Algorithms.DataAnalysis")]
626    [TestProperty("Time", "short")]
627    public void MctsSymbReg_NoConstants_Poly10_Part5() {
628      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
629      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
630
631      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
632      //  Y' = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9
633      // simplify problem by changing target
634      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
635      var ys = ds.GetDoubleValues("Y").ToArray();
636      var x1 = ds.GetDoubleValues("X1").ToArray();
637      var x2 = ds.GetDoubleValues("X2").ToArray();
638      var x3 = ds.GetDoubleValues("X3").ToArray();
639      var x4 = ds.GetDoubleValues("X4").ToArray();
640      var x5 = ds.GetDoubleValues("X5").ToArray();
641      var x6 = ds.GetDoubleValues("X6").ToArray();
642      var x7 = ds.GetDoubleValues("X7").ToArray();
643      var x8 = ds.GetDoubleValues("X8").ToArray();
644      var x9 = ds.GetDoubleValues("X9").ToArray();
645      var x10 = ds.GetDoubleValues("X10").ToArray();
646      for (int i = 0; i < ys.Length; i++) {
647        ys[i] -= x3[i] * x6[i] * x10[i];
648      }
649      ds.ReplaceVariable("Y", ys.ToList());
650      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
651
652
653      TestGrammarEnumeration(modifiedProblemData);
654    }
655
656    [TestMethod]
657    [TestCategory("Algorithms.DataAnalysis")]
658    [TestProperty("Time", "short")]
659    public void MctsSymbReg_NoConstants_Poly10_Part6() {
660      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
661      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
662
663      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
664      //  Y' = X1*X2 + X3*X4 + X5*X6 + X3*X6*X10
665      // simplify problem by changing target
666      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
667      var ys = ds.GetDoubleValues("Y").ToArray();
668      var x1 = ds.GetDoubleValues("X1").ToArray();
669      var x2 = ds.GetDoubleValues("X2").ToArray();
670      var x3 = ds.GetDoubleValues("X3").ToArray();
671      var x4 = ds.GetDoubleValues("X4").ToArray();
672      var x5 = ds.GetDoubleValues("X5").ToArray();
673      var x6 = ds.GetDoubleValues("X6").ToArray();
674      var x7 = ds.GetDoubleValues("X7").ToArray();
675      var x8 = ds.GetDoubleValues("X8").ToArray();
676      var x9 = ds.GetDoubleValues("X9").ToArray();
677      var x10 = ds.GetDoubleValues("X10").ToArray();
678      for (int i = 0; i < ys.Length; i++) {
679        ys[i] -= x1[i] * x7[i] * x9[i];
680      }
681      ds.ReplaceVariable("Y", ys.ToList());
682      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
683
684      TestGrammarEnumeration(modifiedProblemData);
685    }
686
687
688    [TestMethod]
689    [TestCategory("Algorithms.DataAnalysis")]
690    [TestProperty("Time", "long")]
691    public void MctsSymbReg_NoConstants_Poly10_250rows() {
692      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
693      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
694      regProblem.TrainingPartition.Start = 0;
695      regProblem.TrainingPartition.End = regProblem.Dataset.Rows;
696      regProblem.TestPartition.Start = 0;
697      regProblem.TestPartition.End = 2;
698      TestGrammarEnumeration(regProblem);
699    }
700
701    [TestMethod]
702    [TestCategory("Algorithms.DataAnalysis")]
703    [TestProperty("Time", "long")]
704    public void MctsSymbReg_NoConstants_Poly10_10000rows() {
705      // as poly-10 but more rows
706      var x1 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
707      var x2 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
708      var x3 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
709      var x4 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
710      var x5 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
711      var x6 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
712      var x7 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
713      var x8 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
714      var x9 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
715      var x10 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
716      var ys = new List<double>();
717      for (int i = 0; i < x1.Count; i++) {
718        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]);
719      }
720
721      var ds = new Dataset(new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "y" },
722        new[] { x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, ys });
723
724
725      var problemData = new RegressionProblemData(ds, new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" }, "y");
726
727      problemData.TrainingPartition.Start = 0;
728      problemData.TrainingPartition.End = problemData.Dataset.Rows;
729      problemData.TestPartition.Start = 0;
730      problemData.TestPartition.End = 2; // must not be empty
731
732
733      TestGrammarEnumeration(problemData);
734    }
735
736    [TestMethod]
737    [TestCategory("Algorithms.DataAnalysis")]
738    [TestProperty("Time", "short")]
739    public void MctsSymbReg_NoConstants_TwoVars() {
740
741      // y = x1 + x2 + x1*x2 + x1*x2*x2 + x1*x1*x2
742      var x1 = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
743      var x2 = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
744      var ys = x1.Zip(x2, (x1i, x2i) => x1i + x2i + x1i * x2i + x1i * x2i * x2i + x1i * x1i * x2i).ToList();
745
746      var ds = new Dataset(new string[] { "a", "b", "y" }, new[] { x1, x2, ys });
747      var problemData = new RegressionProblemData(ds, new string[] { "a", "b" }, "y");
748
749      TestGrammarEnumeration(problemData);
750    }
751
752    [TestMethod]
753    [TestCategory("Algorithms.DataAnalysis")]
754    [TestProperty("Time", "short")]
755    public void MctsSymbReg_NoConstants_Misleading() {
756
757      // y = a + baaaaa (the effect of the second term should be very small)
758      // the alg will quickly find that a has big effect and will search below a
759      // since we prevent a + a... the algorithm must find the correct expression via a + b...
760      // however b has a small effect so the branch might not be identified as relevant
761      var @as = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
762      var bs = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
763      var cs = Enumerable.Range(0, 100).Select(_ => rand.NextDouble() * 1.0e-3).ToList();
764      var ds = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
765      var es = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
766      var ys = new double[@as.Count];
767      for (int i = 0; i < ys.Length; i++)
768        ys[i] = @as[i] + bs[i] + @as[i] * bs[i] * cs[i];
769
770      var dataset = new Dataset(new string[] { "a", "b", "c", "d", "e", "y" }, new[] { @as, bs, cs, ds, es, ys.ToList() });
771
772      var problemData = new RegressionProblemData(dataset, new string[] { "a", "b", "c", "d", "e" }, "y");
773
774      TestGrammarEnumeration(problemData);
775    }
776
777    [TestMethod]
778    [TestCategory("Algorithms.DataAnalysis")]
779    [TestProperty("Time", "short")]
780    public void MctsSymbRegKeijzer7() {
781      // ln(x)
782      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
783      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 7 f(")));
784      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
785      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
786      TestGrammarEnumeration(regProblem);
787    }
788
789   
790    [TestMethod]
791    [TestCategory("Algorithms.DataAnalysis")]
792    [TestProperty("Time", "short")]
793    public void MctsSymbRegBenchmarkNguyen5() {
794      // sin(x²)cos(x) - 1
795      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
796      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F5 ")));
797      TestGrammarEnumeration(regProblem);
798    }
799
800    [TestMethod]
801    [TestCategory("Algorithms.DataAnalysis")]
802    [TestProperty("Time", "short")]
803    public void MctsSymbRegBenchmarkNguyen6() {
804      // sin(x) + sin(x + x²)
805      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
806      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F6 ")));
807      TestGrammarEnumeration(regProblem);
808    }
809   
810    [TestMethod]
811    [TestCategory("Algorithms.DataAnalysis")]
812    [TestProperty("Time", "short")]
813    public void MctsSymbRegBenchmarkNguyen7() {
814      //  log(x + 1) + log(x² + 1)
815      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
816      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F7 ")));
817      TestGrammarEnumeration(regProblem);
818    }
819    [TestMethod]
820    [TestCategory("Algorithms.DataAnalysis")]
821    [TestProperty("Time", "short")]
822    public void MctsSymbRegBenchmarkNguyen8() {
823      // Sqrt(x)
824      // = x ^ 0.5
825      // = exp(0.5 * log(x))
826      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
827      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F8 ")));
828      TestGrammarEnumeration(regProblem);
829    }
830   
831    // [TestMethod]
832    [TestCategory("Algorithms.DataAnalysis")]
833    [TestProperty("Time", "short")]
834    public void MctsSymbRegBenchmarkNguyen9() {
835      //  sin(x) + sin(y²)
836      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
837      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F9 ")));
838      TestGrammarEnumeration(regProblem);
839    }
840
841    // [TestMethod]
842    [TestCategory("Algorithms.DataAnalysis")]
843    [TestProperty("Time", "short")]
844    public void MctsSymbRegBenchmarkNguyen10() {
845      // 2sin(x)cos(y)
846      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
847      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F10 ")));
848      TestGrammarEnumeration(regProblem);
849    }
850   
851    [TestMethod]
852    [TestCategory("Algorithms.DataAnalysis")]
853    [TestProperty("Time", "short")]
854    public void MctsSymbRegBenchmarkNguyen11() {
855      // x ^ y  , x > 0, y > 0   
856      // = exp(y * log(x))
857      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
858      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F11 ")));
859      TestGrammarEnumeration(regProblem);
860    }
861    [TestMethod]
862    [TestCategory("Algorithms.DataAnalysis")]
863    [TestProperty("Time", "short")]
864    public void MctsSymbRegBenchmarkNguyen12() {
865      // x^4 - x³ + y²/2 - y
866      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
867      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F12 ")));
868      TestGrammarEnumeration(regProblem);
869    }
870
871    [TestMethod]
872    [TestCategory("Algorithms.DataAnalysis")]
873    [TestProperty("Time", "long")]
874    public void MctsSymbRegBenchmarkKeijzer5() {
875      // (30 * x * z) / ((x - 10)  * y²)
876      // = 30 x z / (xy² - y²)
877      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
878      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 5 f(")));
879      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
880      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
881      TestGrammarEnumeration(regProblem);
882    }
883
884    [TestMethod]
885    [TestCategory("Algorithms.DataAnalysis")]
886    [TestProperty("Time", "short")]
887    public void MctsSymbRegBenchmarkKeijzer6() {
888      // Keijzer 6 f(x) = Sum(1 / i) From 1 to X  , x \in [0..120]
889      // we can only approximate this
890      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
891      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 6 f(")));
892      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
893      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
894      TestGrammarEnumeration(regProblem);
895    }
896
897    [TestMethod]
898    [TestCategory("Algorithms.DataAnalysis")]
899    [TestProperty("Time", "short")]
900    public void MctsSymbRegBenchmarkKeijzer8() {
901      // sqrt(x)
902      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
903      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 8 f(")));
904      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
905      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
906      TestGrammarEnumeration(regProblem);
907    }
908
909    [TestMethod]
910    [TestCategory("Algorithms.DataAnalysis")]
911    [TestProperty("Time", "short")]
912    public void MctsSymbRegBenchmarkKeijzer9() {
913      // arcsinh(x)  i.e. ln(x + sqrt(x² + 1))
914      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
915      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 9 f(")));
916      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
917      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
918      TestGrammarEnumeration(regProblem);
919    }
920
921    [TestMethod]
922    [TestCategory("Algorithms.DataAnalysis")]
923    [TestProperty("Time", "short")]
924    public void MctsSymbRegBenchmarkKeijzer11() {
925      // xy + sin( (x-1) (y-1) )
926      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider();
927      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 11 f(")));
928      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
929      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
930      TestGrammarEnumeration(regProblem);
931    }
932
933    [TestMethod]
934    [TestCategory("Algorithms.DataAnalysis")]
935    [TestProperty("Time", "short")]
936    public void MctsSymbRegBenchmarkKeijzer12() {
937      // x^4 - x³ + y² / 2 - y,  same as Nguyen 12             
938      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
939      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 12 f(")));
940      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
941      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
942      TestGrammarEnumeration(regProblem);
943    }
944
945    [TestMethod]
946    [TestCategory("Algorithms.DataAnalysis")]
947    [TestProperty("Time", "short")]
948    public void MctsSymbRegBenchmarkKeijzer14() {
949      // 8 / (2 + x² + y²)
950      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
951      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 14 f(")));
952      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
953      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
954      TestGrammarEnumeration(regProblem);
955    }
956
957    [TestMethod]
958    [TestCategory("Algorithms.DataAnalysis")]
959    [TestProperty("Time", "short")]
960    public void MctsSymbRegBenchmarkKeijzer15() {
961      // x³ / 5 + y³ / 2 - y - x
962      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
963      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 15 f(")));
964      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
965      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
966      TestGrammarEnumeration(regProblem);
967    }
968#endif
969  }
970}
Note: See TracBrowser for help on using the repository browser.