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

Last change on this file since 15883 was 15883, checked in by lkammere, 3 years ago

#2886: Priorize phrases whose (fully expanded) terms result in high R².

File size: 41.7 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
428
429
430#if false
431
432    [TestMethod]
433    [TestProperty("Goal", "structure search")]
434    public void MctsSymbReg_NoConstants_15() {
435      alg.MaxTreeSize = 5;
436      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
437      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("15")));
438      alg.Problem.ProblemData = regProblem;
439
440      alg.Start();
441      EvaluateGrammarEnumeration();
442    }
443
444
445    [TestMethod]
446    [TestCategory("Algorithms.DataAnalysis")]
447    [TestProperty("Time", "short")]
448    public void MctsSymbReg_NoConstants_Nguyen7() {
449      // log(x + 1) + log(x² + 1)
450      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
451      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F7 ")));
452      TestGrammarEnumeration(regProblem);
453    }
454
455    [TestMethod]
456    [TestCategory("Algorithms.DataAnalysis")]
457    [TestProperty("Time", "short")]
458    public void MctsSymbReg_NoConstants_Poly10_Part1() {
459      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
460      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
461
462      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
463      //  Y' = X1*X2 + X3*X4 + X5*X6
464      // simplify problem by changing target
465      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
466      var ys = ds.GetDoubleValues("Y").ToArray();
467      var x1 = ds.GetDoubleValues("X1").ToArray();
468      var x2 = ds.GetDoubleValues("X2").ToArray();
469      var x3 = ds.GetDoubleValues("X3").ToArray();
470      var x4 = ds.GetDoubleValues("X4").ToArray();
471      var x5 = ds.GetDoubleValues("X5").ToArray();
472      var x6 = ds.GetDoubleValues("X6").ToArray();
473      var x7 = ds.GetDoubleValues("X7").ToArray();
474      var x8 = ds.GetDoubleValues("X8").ToArray();
475      var x9 = ds.GetDoubleValues("X9").ToArray();
476      var x10 = ds.GetDoubleValues("X10").ToArray();
477      for (int i = 0; i < ys.Length; i++) {
478        ys[i] -= x1[i] * x7[i] * x9[i];
479        ys[i] -= x3[i] * x6[i] * x10[i];
480      }
481      ds.ReplaceVariable("Y", ys.ToList());
482
483      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
484
485      TestGrammarEnumeration(modifiedProblemData);
486    }
487
488    [TestMethod]
489    [TestCategory("Algorithms.DataAnalysis")]
490    [TestProperty("Time", "short")]
491    public void MctsSymbReg_NoConstants_Poly10_Part2() {
492      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
493      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
494
495      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
496      //  Y' = X1*X7*X9 + X3*X6*X10
497      // simplify problem by changing target
498      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
499      var ys = ds.GetDoubleValues("Y").ToArray();
500      var x1 = ds.GetDoubleValues("X1").ToArray();
501      var x2 = ds.GetDoubleValues("X2").ToArray();                                           
502      var x3 = ds.GetDoubleValues("X3").ToArray();
503      var x4 = ds.GetDoubleValues("X4").ToArray();
504      var x5 = ds.GetDoubleValues("X5").ToArray();
505      var x6 = ds.GetDoubleValues("X6").ToArray();
506      var x7 = ds.GetDoubleValues("X7").ToArray();
507      var x8 = ds.GetDoubleValues("X8").ToArray();
508      var x9 = ds.GetDoubleValues("X9").ToArray();
509      var x10 = ds.GetDoubleValues("X10").ToArray();
510      for (int i = 0; i < ys.Length; i++) {
511        ys[i] -= x1[i] * x2[i];
512        ys[i] -= x3[i] * x4[i];
513        ys[i] -= x5[i] * x6[i];
514      }
515      ds.ReplaceVariable("Y", ys.ToList());
516
517      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
518
519      TestGrammarEnumeration(modifiedProblemData);
520    }
521
522    [TestMethod]
523    [TestCategory("Algorithms.DataAnalysis")]
524    [TestProperty("Time", "short")]
525    public void MctsSymbReg_NoConstants_Poly10_Part3() {
526      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
527      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
528
529      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
530      //  Y' = X1*X2 + X1*X7*X9
531      // simplify problem by changing target
532      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
533      var ys = ds.GetDoubleValues("Y").ToArray();
534      var x1 = ds.GetDoubleValues("X1").ToArray();
535      var x2 = ds.GetDoubleValues("X2").ToArray();
536      var x3 = ds.GetDoubleValues("X3").ToArray();
537      var x4 = ds.GetDoubleValues("X4").ToArray();
538      var x5 = ds.GetDoubleValues("X5").ToArray();
539      var x6 = ds.GetDoubleValues("X6").ToArray();
540      var x7 = ds.GetDoubleValues("X7").ToArray();
541      var x8 = ds.GetDoubleValues("X8").ToArray();
542      var x9 = ds.GetDoubleValues("X9").ToArray();
543      var x10 = ds.GetDoubleValues("X10").ToArray();
544      for (int i = 0; i < ys.Length; i++) {
545        ys[i] -= x3[i] * x4[i];
546        ys[i] -= x5[i] * x6[i];
547        ys[i] -= x3[i] * x6[i] * x10[i];
548      }
549      ds.ReplaceVariable("Y", ys.ToList());
550
551      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
552
553      TestGrammarEnumeration(modifiedProblemData);
554    }
555
556    [TestMethod]
557    [TestCategory("Algorithms.DataAnalysis")]
558    [TestProperty("Time", "short")]
559    public void MctsSymbReg_NoConstants_Poly10_Part4() {
560      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
561      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
562
563      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
564      //  Y' = X3*X4 + X5*X6 + X3*X6*X10
565      // simplify problem by changing target
566      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
567      var ys = ds.GetDoubleValues("Y").ToArray();
568      var x1 = ds.GetDoubleValues("X1").ToArray();
569      var x2 = ds.GetDoubleValues("X2").ToArray();
570      var x3 = ds.GetDoubleValues("X3").ToArray();
571      var x4 = ds.GetDoubleValues("X4").ToArray();
572      var x5 = ds.GetDoubleValues("X5").ToArray();
573      var x6 = ds.GetDoubleValues("X6").ToArray();
574      var x7 = ds.GetDoubleValues("X7").ToArray();
575      var x8 = ds.GetDoubleValues("X8").ToArray();
576      var x9 = ds.GetDoubleValues("X9").ToArray();
577      var x10 = ds.GetDoubleValues("X10").ToArray();
578      for (int i = 0; i < ys.Length; i++) {
579        ys[i] -= x1[i] * x2[i];
580        ys[i] -= x1[i] * x7[i] * x9[i];
581      }
582      ds.ReplaceVariable("Y", ys.ToList());
583      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
584
585
586      TestGrammarEnumeration(modifiedProblemData);
587    }
588
589    [TestMethod]
590    [TestCategory("Algorithms.DataAnalysis")]
591    [TestProperty("Time", "short")]
592    public void MctsSymbReg_NoConstants_Poly10_Part5() {
593      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
594      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
595
596      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
597      //  Y' = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9
598      // simplify problem by changing target
599      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
600      var ys = ds.GetDoubleValues("Y").ToArray();
601      var x1 = ds.GetDoubleValues("X1").ToArray();
602      var x2 = ds.GetDoubleValues("X2").ToArray();
603      var x3 = ds.GetDoubleValues("X3").ToArray();
604      var x4 = ds.GetDoubleValues("X4").ToArray();
605      var x5 = ds.GetDoubleValues("X5").ToArray();
606      var x6 = ds.GetDoubleValues("X6").ToArray();
607      var x7 = ds.GetDoubleValues("X7").ToArray();
608      var x8 = ds.GetDoubleValues("X8").ToArray();
609      var x9 = ds.GetDoubleValues("X9").ToArray();
610      var x10 = ds.GetDoubleValues("X10").ToArray();
611      for (int i = 0; i < ys.Length; i++) {
612        ys[i] -= x3[i] * x6[i] * x10[i];
613      }
614      ds.ReplaceVariable("Y", ys.ToList());
615      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
616
617
618      TestGrammarEnumeration(modifiedProblemData);
619    }
620
621    [TestMethod]
622    [TestCategory("Algorithms.DataAnalysis")]
623    [TestProperty("Time", "short")]
624    public void MctsSymbReg_NoConstants_Poly10_Part6() {
625      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
626      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
627
628      //  Y = X1*X2 + X3*X4 + X5*X6 + X1*X7*X9 + X3*X6*X10
629      //  Y' = X1*X2 + X3*X4 + X5*X6 + X3*X6*X10
630      // simplify problem by changing target
631      var ds = ((Dataset)regProblem.Dataset).ToModifiable();
632      var ys = ds.GetDoubleValues("Y").ToArray();
633      var x1 = ds.GetDoubleValues("X1").ToArray();
634      var x2 = ds.GetDoubleValues("X2").ToArray();
635      var x3 = ds.GetDoubleValues("X3").ToArray();
636      var x4 = ds.GetDoubleValues("X4").ToArray();
637      var x5 = ds.GetDoubleValues("X5").ToArray();
638      var x6 = ds.GetDoubleValues("X6").ToArray();
639      var x7 = ds.GetDoubleValues("X7").ToArray();
640      var x8 = ds.GetDoubleValues("X8").ToArray();
641      var x9 = ds.GetDoubleValues("X9").ToArray();
642      var x10 = ds.GetDoubleValues("X10").ToArray();
643      for (int i = 0; i < ys.Length; i++) {
644        ys[i] -= x1[i] * x7[i] * x9[i];
645      }
646      ds.ReplaceVariable("Y", ys.ToList());
647      var modifiedProblemData = new RegressionProblemData(ds, regProblem.AllowedInputVariables, regProblem.TargetVariable);
648
649      TestGrammarEnumeration(modifiedProblemData);
650    }
651
652
653    [TestMethod]
654    [TestCategory("Algorithms.DataAnalysis")]
655    [TestProperty("Time", "long")]
656    public void MctsSymbReg_NoConstants_Poly10_250rows() {
657      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider(Seed);
658      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Poly-10")));
659      regProblem.TrainingPartition.Start = 0;
660      regProblem.TrainingPartition.End = regProblem.Dataset.Rows;
661      regProblem.TestPartition.Start = 0;
662      regProblem.TestPartition.End = 2;
663      TestGrammarEnumeration(regProblem);
664    }
665
666    [TestMethod]
667    [TestCategory("Algorithms.DataAnalysis")]
668    [TestProperty("Time", "long")]
669    public void MctsSymbReg_NoConstants_Poly10_10000rows() {
670      // as poly-10 but more rows
671      var x1 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
672      var x2 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
673      var x3 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
674      var x4 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
675      var x5 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
676      var x6 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
677      var x7 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
678      var x8 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
679      var x9 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
680      var x10 = Enumerable.Range(0, 10000).Select(_ => rand.NextDouble()).ToList();
681      var ys = new List<double>();
682      for (int i = 0; i < x1.Count; i++) {
683        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]);
684      }
685
686      var ds = new Dataset(new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "y" },
687        new[] { x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, ys });
688
689
690      var problemData = new RegressionProblemData(ds, new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" }, "y");
691
692      problemData.TrainingPartition.Start = 0;
693      problemData.TrainingPartition.End = problemData.Dataset.Rows;
694      problemData.TestPartition.Start = 0;
695      problemData.TestPartition.End = 2; // must not be empty
696
697
698      TestGrammarEnumeration(problemData);
699    }
700
701    [TestMethod]
702    [TestCategory("Algorithms.DataAnalysis")]
703    [TestProperty("Time", "short")]
704    public void MctsSymbReg_NoConstants_TwoVars() {
705
706      // y = x1 + x2 + x1*x2 + x1*x2*x2 + x1*x1*x2
707      var x1 = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
708      var x2 = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
709      var ys = x1.Zip(x2, (x1i, x2i) => x1i + x2i + x1i * x2i + x1i * x2i * x2i + x1i * x1i * x2i).ToList();
710
711      var ds = new Dataset(new string[] { "a", "b", "y" }, new[] { x1, x2, ys });
712      var problemData = new RegressionProblemData(ds, new string[] { "a", "b" }, "y");
713
714      TestGrammarEnumeration(problemData);
715    }
716
717    [TestMethod]
718    [TestCategory("Algorithms.DataAnalysis")]
719    [TestProperty("Time", "short")]
720    public void MctsSymbReg_NoConstants_Misleading() {
721
722      // y = a + baaaaa (the effect of the second term should be very small)
723      // the alg will quickly find that a has big effect and will search below a
724      // since we prevent a + a... the algorithm must find the correct expression via a + b...
725      // however b has a small effect so the branch might not be identified as relevant
726      var @as = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
727      var bs = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
728      var cs = Enumerable.Range(0, 100).Select(_ => rand.NextDouble() * 1.0e-3).ToList();
729      var ds = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
730      var es = Enumerable.Range(0, 100).Select(_ => rand.NextDouble()).ToList();
731      var ys = new double[@as.Count];
732      for (int i = 0; i < ys.Length; i++)
733        ys[i] = @as[i] + bs[i] + @as[i] * bs[i] * cs[i];
734
735      var dataset = new Dataset(new string[] { "a", "b", "c", "d", "e", "y" }, new[] { @as, bs, cs, ds, es, ys.ToList() });
736
737      var problemData = new RegressionProblemData(dataset, new string[] { "a", "b", "c", "d", "e" }, "y");
738
739      TestGrammarEnumeration(problemData);
740    }
741
742    [TestMethod]
743    [TestCategory("Algorithms.DataAnalysis")]
744    [TestProperty("Time", "short")]
745    public void MctsSymbRegKeijzer7() {
746      // ln(x)
747      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
748      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 7 f(")));
749      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
750      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
751      TestGrammarEnumeration(regProblem);
752    }
753
754   
755    [TestMethod]
756    [TestCategory("Algorithms.DataAnalysis")]
757    [TestProperty("Time", "short")]
758    public void MctsSymbRegBenchmarkNguyen5() {
759      // sin(x²)cos(x) - 1
760      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
761      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F5 ")));
762      TestGrammarEnumeration(regProblem);
763    }
764
765    [TestMethod]
766    [TestCategory("Algorithms.DataAnalysis")]
767    [TestProperty("Time", "short")]
768    public void MctsSymbRegBenchmarkNguyen6() {
769      // sin(x) + sin(x + x²)
770      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
771      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F6 ")));
772      TestGrammarEnumeration(regProblem);
773    }
774   
775    [TestMethod]
776    [TestCategory("Algorithms.DataAnalysis")]
777    [TestProperty("Time", "short")]
778    public void MctsSymbRegBenchmarkNguyen7() {
779      //  log(x + 1) + log(x² + 1)
780      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
781      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F7 ")));
782      TestGrammarEnumeration(regProblem);
783    }
784    [TestMethod]
785    [TestCategory("Algorithms.DataAnalysis")]
786    [TestProperty("Time", "short")]
787    public void MctsSymbRegBenchmarkNguyen8() {
788      // Sqrt(x)
789      // = x ^ 0.5
790      // = exp(0.5 * log(x))
791      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
792      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F8 ")));
793      TestGrammarEnumeration(regProblem);
794    }
795   
796    // [TestMethod]
797    [TestCategory("Algorithms.DataAnalysis")]
798    [TestProperty("Time", "short")]
799    public void MctsSymbRegBenchmarkNguyen9() {
800      //  sin(x) + sin(y²)
801      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
802      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F9 ")));
803      TestGrammarEnumeration(regProblem);
804    }
805
806    // [TestMethod]
807    [TestCategory("Algorithms.DataAnalysis")]
808    [TestProperty("Time", "short")]
809    public void MctsSymbRegBenchmarkNguyen10() {
810      // 2sin(x)cos(y)
811      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider();
812      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F10 ")));
813      TestGrammarEnumeration(regProblem);
814    }
815   
816    [TestMethod]
817    [TestCategory("Algorithms.DataAnalysis")]
818    [TestProperty("Time", "short")]
819    public void MctsSymbRegBenchmarkNguyen11() {
820      // x ^ y  , x > 0, y > 0   
821      // = exp(y * log(x))
822      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
823      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F11 ")));
824      TestGrammarEnumeration(regProblem);
825    }
826    [TestMethod]
827    [TestCategory("Algorithms.DataAnalysis")]
828    [TestProperty("Time", "short")]
829    public void MctsSymbRegBenchmarkNguyen12() {
830      // x^4 - x³ + y²/2 - y
831      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.NguyenInstanceProvider(Seed);
832      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F12 ")));
833      TestGrammarEnumeration(regProblem);
834    }
835
836    [TestMethod]
837    [TestCategory("Algorithms.DataAnalysis")]
838    [TestProperty("Time", "long")]
839    public void MctsSymbRegBenchmarkKeijzer5() {
840      // (30 * x * z) / ((x - 10)  * y²)
841      // = 30 x z / (xy² - y²)
842      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
843      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 5 f(")));
844      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
845      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
846      TestGrammarEnumeration(regProblem);
847    }
848
849    [TestMethod]
850    [TestCategory("Algorithms.DataAnalysis")]
851    [TestProperty("Time", "short")]
852    public void MctsSymbRegBenchmarkKeijzer6() {
853      // Keijzer 6 f(x) = Sum(1 / i) From 1 to X  , x \in [0..120]
854      // we can only approximate this
855      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
856      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 6 f(")));
857      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
858      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
859      TestGrammarEnumeration(regProblem);
860    }
861
862    [TestMethod]
863    [TestCategory("Algorithms.DataAnalysis")]
864    [TestProperty("Time", "short")]
865    public void MctsSymbRegBenchmarkKeijzer8() {
866      // sqrt(x)
867      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
868      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 8 f(")));
869      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
870      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
871      TestGrammarEnumeration(regProblem);
872    }
873
874    [TestMethod]
875    [TestCategory("Algorithms.DataAnalysis")]
876    [TestProperty("Time", "short")]
877    public void MctsSymbRegBenchmarkKeijzer9() {
878      // arcsinh(x)  i.e. ln(x + sqrt(x² + 1))
879      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
880      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 9 f(")));
881      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
882      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
883      TestGrammarEnumeration(regProblem);
884    }
885
886    [TestMethod]
887    [TestCategory("Algorithms.DataAnalysis")]
888    [TestProperty("Time", "short")]
889    public void MctsSymbRegBenchmarkKeijzer11() {
890      // xy + sin( (x-1) (y-1) )
891      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider();
892      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 11 f(")));
893      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
894      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
895      TestGrammarEnumeration(regProblem);
896    }
897
898    [TestMethod]
899    [TestCategory("Algorithms.DataAnalysis")]
900    [TestProperty("Time", "short")]
901    public void MctsSymbRegBenchmarkKeijzer12() {
902      // x^4 - x³ + y² / 2 - y,  same as Nguyen 12             
903      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
904      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 12 f(")));
905      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
906      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
907      TestGrammarEnumeration(regProblem);
908    }
909
910    [TestMethod]
911    [TestCategory("Algorithms.DataAnalysis")]
912    [TestProperty("Time", "short")]
913    public void MctsSymbRegBenchmarkKeijzer14() {
914      // 8 / (2 + x² + y²)
915      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
916      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 14 f(")));
917      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
918      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
919      TestGrammarEnumeration(regProblem);
920    }
921
922    [TestMethod]
923    [TestCategory("Algorithms.DataAnalysis")]
924    [TestProperty("Time", "short")]
925    public void MctsSymbRegBenchmarkKeijzer15() {
926      // x³ / 5 + y³ / 2 - y - x
927      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(Seed);
928      var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 15 f(")));
929      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
930      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
931      TestGrammarEnumeration(regProblem);
932    }
933#endif
934  }
935}
Note: See TracBrowser for help on using the repository browser.