Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13645,13648,13650-13652,13654,13657-13659,13661-13662,13669,13708,14142
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Tests
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Tests merged: 13648,13651,13654,13661,13708
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/MctsSymbolicRegressionTest.cs
r13648 r15060 1 1 using System; 2 using System.Diagnostics.Contracts; 2 3 using System.Linq; 3 4 using System.Threading; 4 5 using HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression; 6 using HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression.Policies; 5 7 using HeuristicLab.Data; 6 8 using HeuristicLab.Optimization; … … 31 33 { 32 34 // possible solutions with max two variable references: 35 // TODO: equal terms should not be allowed (see ConstraintHandler) 33 36 // x 34 37 // log(x) … … 40 43 // x * exp(x) 41 44 // x * 1/x 42 // x + x 45 // x + x ? 43 46 // x + log(x) 44 47 // x + exp(x) … … 48 51 // log(x) * exp(x) 49 52 // log(x) * 1/x 50 // log(x) + log(x) 51 // log(x) + exp(x) 53 // log(x) + log(x) ? 54 // log(x) + exp(x) ? 52 55 // log(x) + 1/x 53 56 // -- 6 54 57 // exp(x) * exp(x) 55 58 // exp(x) * 1/x 56 // exp(x) + exp(x) 59 // exp(x) + exp(x) ? 57 60 // exp(x) + 1/x 58 61 // -- 4 59 62 // 1/x * 1/x 60 // 1/x + 1/x 63 // 1/x + 1/x ? 61 64 // -- 2 62 // log(x+x) 65 // log(x+x) ? 63 66 // log(x*x) 64 67 // exp(x*x) 65 // 1/(x+x) 68 // 1/(x+x) ? 66 69 // 1/(x*x) 67 70 // -- 5 71 72 68 73 TestMctsNumberOfSolutions(regProblem, 2, 29); 69 74 } … … 75 80 // -- 2 76 81 // x * x 77 // x + x 82 // x + x ? 78 83 // x * exp(x) 79 84 // x + exp(x) 80 85 // exp(x) * exp(x) 81 // exp(x) + exp(x) 86 // exp(x) + exp(x) ? 82 87 // exp(x*x) 83 88 // -- 7 84 89 // x * x * x 85 // x + x * x 86 // x * x + x !! 87 // x + x + x 90 // x + x * x 91 // x + x + x ? 88 92 // x * x * exp(x) 89 // x + x * exp(x) 90 // x * x + exp(x) 91 // x + x + exp(x) 92 // x * exp(x) + x !! 93 // x * exp(x) + exp(x) 94 // x + exp(x) * exp(x) 95 // x + exp(x) + exp(x) 93 // x + x * exp(x) 94 // x + x + exp(x) ? 95 // exp(x) + x*x 96 // exp(x) + x*exp(x) 97 // x + exp(x) * exp(x) 98 // x + exp(x) + exp(x) ? 96 99 // x * exp(x) * exp(x) 97 100 // x * exp(x*x) 98 101 // x + exp(x*x) 99 // -- 1 5102 // -- 13 100 103 101 104 // exp(x) * exp(x) * exp(x) 102 // exp(x) + exp(x) * exp(x) 103 // exp(x) * exp(x) + exp(x) !! 104 // exp(x) + exp(x) + exp(x) 105 // -- 4 105 // exp(x) + exp(x) * exp(x) 106 // exp(x) + exp(x) + exp(x) ? 107 // -- 3 106 108 107 109 // exp(x) * exp(x*x) 108 110 // exp(x) + exp(x*x) 109 // exp(x*x) * exp(x) !! 110 // exp(x*x) + exp(x) !! 111 // -- 4 111 // -- 2 112 112 // exp(x*x*x) 113 113 // -- 1 114 115 TestMctsNumberOfSolutions(regProblem, 3, 2 + 7 + 15 + 4 + 4 + 1, allowLog: false, allowInv: false); 114 TestMctsNumberOfSolutions(regProblem, 3, 2 + 7 + 13 + 3 + 2 + 1, allowLog: false, allowInv: false); 115 } 116 { 117 // possible solutions with max 4 variable references: 118 // without exp, log and inv 119 // x 120 // x*x 121 // x+x ? 122 // x*x*x 123 // x+x*x 124 // x+x+x ? 125 // x*x*x*x 126 // x+x*x*x 127 // x*x+x*x ? 128 // x+x+x*x ? 129 // x+x+x+x ? 130 131 TestMctsNumberOfSolutions(regProblem, 4, 11, allowLog: false, allowInv: false, allowExp: false); 132 } 133 { 134 // possible solutions with max 5 variable references: 135 // without exp, log and inv 136 // x 137 // xx 138 // x+x ? 139 // xxx 140 // x+xx 141 // x+x+x ? 142 // xxxx 143 // x+xxx 144 // xx+xx ? 145 // x+x+xx ? 146 // x+x+x+x ? 147 // xxxxx 148 // x+xxxx 149 // xx+xxx 150 // x+x+xxx ? 151 // x+xx+xx ? 152 // x+x+x+xx ? 153 // x+x+x+x+x ? 154 TestMctsNumberOfSolutions(regProblem, 5, 18, allowLog: false, allowInv: false, allowExp: false); 116 155 } 117 156 } … … 236 275 #endregion 237 276 277 238 278 #region Nguyen 239 [TestMethod]279 // [TestMethod] 240 280 [TestCategory("Algorithms.DataAnalysis")] 241 281 [TestProperty("Time", "short")] … … 245 285 TestMcts(regProblem); 246 286 } 247 [TestMethod]287 // [TestMethod] 248 288 [TestCategory("Algorithms.DataAnalysis")] 249 289 [TestProperty("Time", "short")] … … 253 293 TestMcts(regProblem); 254 294 } 255 [TestMethod]295 // [TestMethod] 256 296 [TestCategory("Algorithms.DataAnalysis")] 257 297 [TestProperty("Time", "short")] … … 261 301 TestMcts(regProblem, successThreshold: 0.99); 262 302 } 263 [TestMethod]303 // [TestMethod] 264 304 [TestCategory("Algorithms.DataAnalysis")] 265 305 [TestProperty("Time", "short")] … … 269 309 TestMcts(regProblem); 270 310 } 271 [TestMethod]311 // [TestMethod] 272 312 [TestCategory("Algorithms.DataAnalysis")] 273 313 [TestProperty("Time", "short")] … … 277 317 TestMcts(regProblem); 278 318 } 279 [TestMethod]319 // [TestMethod] 280 320 [TestCategory("Algorithms.DataAnalysis")] 281 321 [TestProperty("Time", "short")] … … 285 325 TestMcts(regProblem); 286 326 } 287 [TestMethod]327 // [TestMethod] 288 328 [TestCategory("Algorithms.DataAnalysis")] 289 329 [TestProperty("Time", "short")] … … 293 333 TestMcts(regProblem); 294 334 } 295 [TestMethod]335 // [TestMethod] 296 336 [TestCategory("Algorithms.DataAnalysis")] 297 337 [TestProperty("Time", "short")] … … 301 341 TestMcts(regProblem, successThreshold: 0.99); 302 342 } 303 [TestMethod]343 // [TestMethod] 304 344 [TestCategory("Algorithms.DataAnalysis")] 305 345 [TestProperty("Time", "short")] … … 309 349 TestMcts(regProblem, iterations: 10000); 310 350 } 311 [TestMethod]351 // [TestMethod] 312 352 [TestCategory("Algorithms.DataAnalysis")] 313 353 [TestProperty("Time", "short")] … … 317 357 TestMcts(regProblem); 318 358 } 319 [TestMethod]359 // [TestMethod] 320 360 [TestCategory("Algorithms.DataAnalysis")] 321 361 [TestProperty("Time", "short")] … … 325 365 TestMcts(regProblem, 10000, 0.95); // cannot solve exactly in 10000 iterations 326 366 } 327 [TestMethod]367 // [TestMethod] 328 368 [TestCategory("Algorithms.DataAnalysis")] 329 369 [TestProperty("Time", "short")] … … 337 377 338 378 #region keijzer 339 [TestMethod]379 // [TestMethod] 340 380 [TestCategory("Algorithms.DataAnalysis")] 341 381 [TestProperty("Time", "long")] … … 348 388 } 349 389 350 [TestMethod]390 // [TestMethod] 351 391 [TestCategory("Algorithms.DataAnalysis")] 352 392 [TestProperty("Time", "short")] … … 360 400 } 361 401 402 // [TestMethod] 403 [TestCategory("Algorithms.DataAnalysis")] 404 [TestProperty("Time", "short")] 405 public void MctsSymbRegBenchmarkKeijzer7() { 406 var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(); 407 var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 7 f("))); 408 // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance) 409 if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000; 410 TestMcts(regProblem); 411 } 412 362 413 [TestMethod] 363 [TestCategory("Algorithms.DataAnalysis")]364 [TestProperty("Time", "short")] 365 public void MctsSymbRegBenchmarkKeijzer 7() {366 var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(); 367 var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 7f(")));414 // [TestCategory("Algorithms.DataAnalysis")] 415 [TestProperty("Time", "short")] 416 public void MctsSymbRegBenchmarkKeijzer8() { 417 var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(); 418 var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 8 f("))); 368 419 // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance) 369 420 if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000; … … 372 423 373 424 [TestMethod] 374 [TestCategory("Algorithms.DataAnalysis")] 375 [TestProperty("Time", "short")] 376 public void MctsSymbRegBenchmarkKeijzer8() { 377 var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider(); 378 var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 8 f("))); 379 // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance) 380 if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000; 381 TestMcts(regProblem); 382 } 383 384 [TestMethod] 385 [TestCategory("Algorithms.DataAnalysis")] 425 // [TestCategory("Algorithms.DataAnalysis")] 386 426 [TestProperty("Time", "short")] 387 427 public void MctsSymbRegBenchmarkKeijzer9() { … … 420 460 } 421 461 */ 422 [TestMethod]462 // [TestMethod] 423 463 [TestCategory("Algorithms.DataAnalysis")] 424 464 [TestProperty("Time", "short")] … … 431 471 TestMcts(regProblem, iterations: 10000, allowLog: false, allowExp: false, allowInv: false, successThreshold: 0.99); // cannot solve exactly in 10000 iterations 432 472 } 433 [TestMethod]473 // [TestMethod] 434 474 [TestCategory("Algorithms.DataAnalysis")] 435 475 [TestProperty("Time", "short")] … … 441 481 TestMcts(regProblem); 442 482 } 443 [TestMethod]483 // [TestMethod] 444 484 [TestCategory("Algorithms.DataAnalysis")] 445 485 [TestProperty("Time", "short")] … … 465 505 mctsSymbReg.Problem = regProblem; 466 506 mctsSymbReg.Iterations = iterations; 467 mctsSymbReg.MaxSize = 10; 468 mctsSymbReg.C = 2; // less greedy 507 mctsSymbReg.MaxVariableReferences = 10; 508 var ucbPolicy = new Ucb(); 509 ucbPolicy.C = 2; 510 mctsSymbReg.Policy = ucbPolicy; 469 511 mctsSymbReg.SetSeedRandomly = false; 470 512 mctsSymbReg.Seed = 1234; … … 485 527 486 528 private void TestMctsNumberOfSolutions(IRegressionProblemData problemData, int maxNumberOfVariables, int expectedNumberOfSolutions, 529 bool allowProd = true, 487 530 bool allowExp = true, 488 531 bool allowLog = true, … … 494 537 regProblem.ProblemDataParameter.Value = problemData; 495 538 #region Algorithm Configuration 539 540 mctsSymbReg.SetSeedRandomly = false; 541 mctsSymbReg.Seed = 1234; 496 542 mctsSymbReg.Problem = regProblem; 497 543 mctsSymbReg.Iterations = int.MaxValue; // stopping when all solutions have been enumerated 498 mctsSymbReg.MaxSize = maxNumberOfVariables; 499 mctsSymbReg.C = 1000; // essentially breath first seach 544 mctsSymbReg.MaxVariableReferences = maxNumberOfVariables; 545 var ucbPolicy = new Ucb(); 546 ucbPolicy.C = 1000; // essentially breadth first search 547 mctsSymbReg.Policy = ucbPolicy; 548 mctsSymbReg.AllowedFactors.SetItemCheckedState(mctsSymbReg.AllowedFactors.Single(s => s.Value.StartsWith("prod")), allowProd); 500 549 mctsSymbReg.AllowedFactors.SetItemCheckedState(mctsSymbReg.AllowedFactors.Single(s => s.Value.Contains("exp")), allowExp); 501 550 mctsSymbReg.AllowedFactors.SetItemCheckedState(mctsSymbReg.AllowedFactors.Single(s => s.Value.Contains("log")), allowLog);
Note: See TracChangeset
for help on using the changeset viewer.