Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/25/17 15:59:39 (7 years ago)
Author:
gkronber
Message:

#2581: merged r13645,r13648,r13650,r13651,r13652,r13654,r13657,r13658,r13659,r13661,r13662,r13669,r13708,r14142 from trunk to stable (to be deleted in the next commit)

Location:
stable
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Tests

  • stable/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/MctsSymbolicRegressionTest.cs

    r13648 r15060  
    11using System;
     2using System.Diagnostics.Contracts;
    23using System.Linq;
    34using System.Threading;
    45using HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression;
     6using HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression.Policies;
    57using HeuristicLab.Data;
    68using HeuristicLab.Optimization;
     
    3133      {
    3234        // possible solutions with max two variable references:
     35        // TODO: equal terms should not be allowed (see ConstraintHandler)
    3336        // x
    3437        // log(x)
     
    4043        // x * exp(x)
    4144        // x * 1/x
    42         // x + x
     45        // x + x                                        ?
    4346        // x + log(x)
    4447        // x + exp(x)
     
    4851        // log(x) * exp(x)
    4952        // log(x) * 1/x
    50         // log(x) + log(x)
    51         // log(x) + exp(x)
     53        // log(x) + log(x)                              ?
     54        // log(x) + exp(x)                              ?
    5255        // log(x) + 1/x
    5356        //              -- 6
    5457        // exp(x) * exp(x)
    5558        // exp(x) * 1/x
    56         // exp(x) + exp(x)
     59        // exp(x) + exp(x)                              ?
    5760        // exp(x) + 1/x
    5861        //              -- 4
    5962        // 1/x * 1/x
    60         // 1/x + 1/x
     63        // 1/x + 1/x                                    ?
    6164        //              -- 2
    62         // log(x+x)
     65        // log(x+x)                                     ?
    6366        // log(x*x)
    6467        // exp(x*x)
    65         // 1/(x+x)
     68        // 1/(x+x)                                      ?
    6669        // 1/(x*x)
    6770        //              -- 5
     71
     72
    6873        TestMctsNumberOfSolutions(regProblem, 2, 29);
    6974      }
     
    7580        //              -- 2
    7681        // x * x
    77         // x + x
     82        // x + x                                            ?
    7883        // x * exp(x)
    7984        // x + exp(x)
    8085        // exp(x) * exp(x)
    81         // exp(x) + exp(x)
     86        // exp(x) + exp(x)                                  ?
    8287        // exp(x*x)
    8388        //              -- 7
    8489        // x * x * x
    85         // x + x * x
    86         // x * x + x                                        !!
    87         // x + x + x
     90        // x + x * x                                       
     91        // x + x + x                                        ?
    8892        // 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)                              ?
    9699        // x * exp(x) * exp(x)
    97100        // x * exp(x*x)
    98101        // x + exp(x*x)
    99         //              -- 15
     102        //              -- 13
    100103
    101104        // 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
    106108
    107109        // exp(x)   * exp(x*x)
    108110        // exp(x)   + exp(x*x)
    109         // exp(x*x) * exp(x)                                !!
    110         // exp(x*x) + exp(x)                                !!
    111         //              -- 4
     111        //              -- 2
    112112        // exp(x*x*x)
    113113        //              -- 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);
    116155      }
    117156    }
     
    236275    #endregion
    237276
     277
    238278    #region Nguyen
    239     [TestMethod]
     279    // [TestMethod]
    240280    [TestCategory("Algorithms.DataAnalysis")]
    241281    [TestProperty("Time", "short")]
     
    245285      TestMcts(regProblem);
    246286    }
    247     [TestMethod]
     287    // [TestMethod]
    248288    [TestCategory("Algorithms.DataAnalysis")]
    249289    [TestProperty("Time", "short")]
     
    253293      TestMcts(regProblem);
    254294    }
    255     [TestMethod]
     295    // [TestMethod]
    256296    [TestCategory("Algorithms.DataAnalysis")]
    257297    [TestProperty("Time", "short")]
     
    261301      TestMcts(regProblem, successThreshold: 0.99);
    262302    }
    263     [TestMethod]
     303    // [TestMethod]
    264304    [TestCategory("Algorithms.DataAnalysis")]
    265305    [TestProperty("Time", "short")]
     
    269309      TestMcts(regProblem);
    270310    }
    271     [TestMethod]
     311    // [TestMethod]
    272312    [TestCategory("Algorithms.DataAnalysis")]
    273313    [TestProperty("Time", "short")]
     
    277317      TestMcts(regProblem);
    278318    }
    279     [TestMethod]
     319    // [TestMethod]
    280320    [TestCategory("Algorithms.DataAnalysis")]
    281321    [TestProperty("Time", "short")]
     
    285325      TestMcts(regProblem);
    286326    }
    287     [TestMethod]
     327    // [TestMethod]
    288328    [TestCategory("Algorithms.DataAnalysis")]
    289329    [TestProperty("Time", "short")]
     
    293333      TestMcts(regProblem);
    294334    }
    295     [TestMethod]
     335    // [TestMethod]
    296336    [TestCategory("Algorithms.DataAnalysis")]
    297337    [TestProperty("Time", "short")]
     
    301341      TestMcts(regProblem, successThreshold: 0.99);
    302342    }
    303     [TestMethod]
     343    // [TestMethod]
    304344    [TestCategory("Algorithms.DataAnalysis")]
    305345    [TestProperty("Time", "short")]
     
    309349      TestMcts(regProblem, iterations: 10000);
    310350    }
    311     [TestMethod]
     351    // [TestMethod]
    312352    [TestCategory("Algorithms.DataAnalysis")]
    313353    [TestProperty("Time", "short")]
     
    317357      TestMcts(regProblem);
    318358    }
    319     [TestMethod]
     359    // [TestMethod]
    320360    [TestCategory("Algorithms.DataAnalysis")]
    321361    [TestProperty("Time", "short")]
     
    325365      TestMcts(regProblem, 10000, 0.95); // cannot solve exactly in 10000 iterations
    326366    }
    327     [TestMethod]
     367    // [TestMethod]
    328368    [TestCategory("Algorithms.DataAnalysis")]
    329369    [TestProperty("Time", "short")]
     
    337377
    338378    #region keijzer
    339     [TestMethod]
     379    // [TestMethod]
    340380    [TestCategory("Algorithms.DataAnalysis")]
    341381    [TestProperty("Time", "long")]
     
    348388    }
    349389
    350     [TestMethod]
     390    // [TestMethod]
    351391    [TestCategory("Algorithms.DataAnalysis")]
    352392    [TestProperty("Time", "short")]
     
    360400    }
    361401
     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
    362413    [TestMethod]
    363     [TestCategory("Algorithms.DataAnalysis")]
    364     [TestProperty("Time", "short")]
    365     public void MctsSymbRegBenchmarkKeijzer7() {
    366       var provider = new HeuristicLab.Problems.Instances.DataAnalysis.KeijzerInstanceProvider();
    367       var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("Keijzer 7 f(")));
     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(")));
    368419      // some Keijzer problem instances have very large test partitions (here we are not concerened about test performance)
    369420      if (regProblem.TestPartition.End - regProblem.TestPartition.Start > 1000) regProblem.TestPartition.End = regProblem.TestPartition.Start + 1000;
     
    372423
    373424    [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")]
    386426    [TestProperty("Time", "short")]
    387427    public void MctsSymbRegBenchmarkKeijzer9() {
     
    420460    }
    421461     */
    422     [TestMethod]
     462    // [TestMethod]
    423463    [TestCategory("Algorithms.DataAnalysis")]
    424464    [TestProperty("Time", "short")]
     
    431471      TestMcts(regProblem, iterations: 10000, allowLog: false, allowExp: false, allowInv: false, successThreshold: 0.99); // cannot solve exactly in 10000 iterations
    432472    }
    433     [TestMethod]
     473    // [TestMethod]
    434474    [TestCategory("Algorithms.DataAnalysis")]
    435475    [TestProperty("Time", "short")]
     
    441481      TestMcts(regProblem);
    442482    }
    443     [TestMethod]
     483    // [TestMethod]
    444484    [TestCategory("Algorithms.DataAnalysis")]
    445485    [TestProperty("Time", "short")]
     
    465505      mctsSymbReg.Problem = regProblem;
    466506      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;
    469511      mctsSymbReg.SetSeedRandomly = false;
    470512      mctsSymbReg.Seed = 1234;
     
    485527
    486528    private void TestMctsNumberOfSolutions(IRegressionProblemData problemData, int maxNumberOfVariables, int expectedNumberOfSolutions,
     529      bool allowProd = true,
    487530      bool allowExp = true,
    488531      bool allowLog = true,
     
    494537      regProblem.ProblemDataParameter.Value = problemData;
    495538      #region Algorithm Configuration
     539
     540      mctsSymbReg.SetSeedRandomly = false;
     541      mctsSymbReg.Seed = 1234;
    496542      mctsSymbReg.Problem = regProblem;
    497543      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);
    500549      mctsSymbReg.AllowedFactors.SetItemCheckedState(mctsSymbReg.AllowedFactors.Single(s => s.Value.Contains("exp")), allowExp);
    501550      mctsSymbReg.AllowedFactors.SetItemCheckedState(mctsSymbReg.AllowedFactors.Single(s => s.Value.Contains("log")), allowLog);
  • stable/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r14967 r15060  
    478478    <Compile Include="HeuristicLab-3.3\ThreadSafeLogTest.cs" />
    479479    <Compile Include="HeuristicLab-3.3\ToStringTest.cs" />
     480    <Compile Include="HeuristicLab.Algorithms.DataAnalysis-3.4\MctsSymbolicRegressionTest.cs" />
    480481    <Compile Include="HeuristicLab.Algorithms.DataAnalysis-3.4\GradientBoostingTest.cs" />
    481482    <Compile Include="HeuristicLab.Algorithms.DataAnalysis-3.4\SupportVectorMachineTest.cs" />
Note: See TracChangeset for help on using the changeset viewer.