Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/05/16 08:25:08 (8 years ago)
Author:
gkronber
Message:

#2581:

  • added unit tests for the number of different expressions
  • fixed problems in Automaton and constraintHandler that lead to duplicate expressions
  • added possibility for MCTS to handle dead-ends in the search tree (when it is not possible to construct a valid new expression)
  • added statistics on function and gradient evaluations
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/MctsSymbolicRegressionTest.cs

    r13648 r13651  
    11using System;
     2using System.Diagnostics.Contracts;
    23using System.Linq;
    34using System.Threading;
     
    3132      {
    3233        // possible solutions with max two variable references:
     34        // TODO: equal terms should not be allowed (see ConstraintHandler)
    3335        // x
    3436        // log(x)
     
    4042        // x * exp(x)
    4143        // x * 1/x
    42         // x + x
     44        // x + x                                        ?
    4345        // x + log(x)
    4446        // x + exp(x)
     
    4850        // log(x) * exp(x)
    4951        // log(x) * 1/x
    50         // log(x) + log(x)
    51         // log(x) + exp(x)
     52        // log(x) + log(x)                              ?
     53        // log(x) + exp(x)                              ?
    5254        // log(x) + 1/x
    5355        //              -- 6
    5456        // exp(x) * exp(x)
    5557        // exp(x) * 1/x
    56         // exp(x) + exp(x)
     58        // exp(x) + exp(x)                              ?
    5759        // exp(x) + 1/x
    5860        //              -- 4
    5961        // 1/x * 1/x
    60         // 1/x + 1/x
     62        // 1/x + 1/x                                    ?
    6163        //              -- 2
    62         // log(x+x)
     64        // log(x+x)                                     ?
    6365        // log(x*x)
    6466        // exp(x*x)
    65         // 1/(x+x)
     67        // 1/(x+x)                                      ?
    6668        // 1/(x*x)
    6769        //              -- 5
     70
     71
    6872        TestMctsNumberOfSolutions(regProblem, 2, 29);
    6973      }
     
    7579        //              -- 2
    7680        // x * x
    77         // x + x
     81        // x + x                                            ?
    7882        // x * exp(x)
    7983        // x + exp(x)
    8084        // exp(x) * exp(x)
    81         // exp(x) + exp(x)
     85        // exp(x) + exp(x)                                  ?
    8286        // exp(x*x)
    8387        //              -- 7
    8488        // x * x * x
    85         // x + x * x
    86         // x * x + x                                        !!
    87         // x + x + x
     89        // x + x * x                                       
     90        // x + x + x                                        ?
    8891        // 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)
     92        // x + x * exp(x)                                   
     93        // x + x + exp(x)                                   ?
     94        // exp(x) + x*x
     95        // exp(x) + x*exp(x)                               
     96        // x + exp(x) * exp(x)                             
     97        // x + exp(x) + exp(x)                              ?
    9698        // x * exp(x) * exp(x)
    9799        // x * exp(x*x)
    98100        // x + exp(x*x)
    99         //              -- 15
     101        //              -- 13
    100102
    101103        // 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
     104        // exp(x) + exp(x) * exp(x)                         
     105        // exp(x) + exp(x) + exp(x)                         ?
     106        //              -- 3
    106107
    107108        // exp(x)   * exp(x*x)
    108109        // exp(x)   + exp(x*x)
    109         // exp(x*x) * exp(x)                                !!
    110         // exp(x*x) + exp(x)                                !!
    111         //              -- 4
     110        //              -- 2
    112111        // exp(x*x*x)
    113112        //              -- 1
    114 
    115         TestMctsNumberOfSolutions(regProblem, 3, 2 + 7 + 15 + 4 + 4 + 1, allowLog: false, allowInv: false);
     113        TestMctsNumberOfSolutions(regProblem, 3, 2 + 7 + 13 + 3 + 2 + 1, allowLog: false, allowInv: false);
     114      }
     115      {
     116        // possible solutions with max 4 variable references:
     117        // without exp, log and inv
     118        // x       
     119        // x*x
     120        // x+x                                             ?
     121        // x*x*x
     122        // x+x*x
     123        // x+x+x                                           ?
     124        // x*x*x*x
     125        // x+x*x*x
     126        // x*x+x*x                                         ?
     127        // x+x+x*x                                         ?
     128        // x+x+x+x                                         ?
     129
     130        TestMctsNumberOfSolutions(regProblem, 4, 11, allowLog: false, allowInv: false, allowExp: false);
     131      }
     132      {
     133        // possible solutions with max 5 variable references:
     134        // without exp, log and inv
     135        // x       
     136        // xx
     137        // x+x                                             ?
     138        // xxx
     139        // x+xx
     140        // x+x+x                                           ?
     141        // xxxx
     142        // x+xxx
     143        // xx+xx                                           ?
     144        // x+x+xx                                          ?
     145        // x+x+x+x                                         ?
     146        // xxxxx
     147        // x+xxxx
     148        // xx+xxx
     149        // x+x+xxx                                         ?
     150        // x+xx+xx                                         ?
     151        // x+x+x+xx                                        ?
     152        // x+x+x+x+x                                       ?
     153        TestMctsNumberOfSolutions(regProblem, 5, 18, allowLog: false, allowInv: false, allowExp: false);
    116154      }
    117155    }
     
    236274    #endregion
    237275
     276 
    238277    #region Nguyen
    239278    [TestMethod]
     
    485524
    486525    private void TestMctsNumberOfSolutions(IRegressionProblemData problemData, int maxNumberOfVariables, int expectedNumberOfSolutions,
     526      bool allowProd = true,
    487527      bool allowExp = true,
    488528      bool allowLog = true,
     
    494534      regProblem.ProblemDataParameter.Value = problemData;
    495535      #region Algorithm Configuration
     536
     537      mctsSymbReg.SetSeedRandomly = false;
     538      mctsSymbReg.Seed = 1234;
    496539      mctsSymbReg.Problem = regProblem;
    497540      mctsSymbReg.Iterations = int.MaxValue; // stopping when all solutions have been enumerated
    498541      mctsSymbReg.MaxSize = maxNumberOfVariables;
    499542      mctsSymbReg.C = 1000; // essentially breath first seach
     543      mctsSymbReg.AllowedFactors.SetItemCheckedState(mctsSymbReg.AllowedFactors.Single(s => s.Value.StartsWith("prod")), allowProd);
    500544      mctsSymbReg.AllowedFactors.SetItemCheckedState(mctsSymbReg.AllowedFactors.Single(s => s.Value.Contains("exp")), allowExp);
    501545      mctsSymbReg.AllowedFactors.SetItemCheckedState(mctsSymbReg.AllowedFactors.Single(s => s.Value.Contains("log")), allowLog);
Note: See TracChangeset for help on using the changeset viewer.