Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13652


Ignore:
Timestamp:
03/05/16 19:41:24 (8 years ago)
Author:
gkronber
Message:

#2581:

  • removed simplification of trees (temporarily for better debugging)
  • renamed MaxSize parameter
  • fixed a small bug in MCTS
  • changed SymbolicExpressionGenerator to produce trees in the correct order
Location:
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/ExpressionEvaluator.cs

    r13651 r13652  
    183183
    184184                var f = 1.0 / (maxFx * consts[curParamIdx]);
    185                 // adjust c so that maxFx*c = 1 TODO: this is not ideal as enforce positive argument to exp()
     185                // adjust c so that maxFx*c = 1 TODO: this is not ideal as it enforces positive arguments to exp()
    186186                consts[curParamIdx] *= f;
    187187
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionAlgorithm.cs

    r13651 r13652  
    7070      get { return (IFixedValueParameter<IntValue>)Parameters[IterationsParameterName]; }
    7171    }
    72     public IFixedValueParameter<IntValue> MaxSizeParameter {
     72    public IFixedValueParameter<IntValue> MaxVariableReferencesParameter {
    7373      get { return (IFixedValueParameter<IntValue>)Parameters[MaxVariablesParameterName]; }
    7474    }
     
    115115      set { SetSeedRandomlyParameter.Value.Value = value; }
    116116    }
    117     public int MaxSize {
    118       get { return MaxSizeParameter.Value.Value; }
    119       set { MaxSizeParameter.Value.Value = value; }
     117    public int MaxVariableReferences {
     118      get { return MaxVariableReferencesParameter.Value.Value; }
     119      set { MaxVariableReferencesParameter.Value.Value = value; }
    120120    }
    121121    public double C {
     
    244244      var problemData = (IRegressionProblemData)Problem.ProblemData.Clone();
    245245      if (!AllowedFactors.CheckedItems.Any()) throw new ArgumentException("At least on type of factor must be allowed");
    246       var state = MctsSymbolicRegressionStatic.CreateState(problemData, (uint)Seed, MaxSize, C, ScaleVariables, ConstantOptimizationIterations,
     246      var state = MctsSymbolicRegressionStatic.CreateState(problemData, (uint)Seed, MaxVariableReferences, C, ScaleVariables, ConstantOptimizationIterations,
    247247        lowerLimit, upperLimit,
    248248        allowProdOfVars: AllowedFactors.CheckedItems.Any(s => s.Value.Value == VariableProductFactorName),
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/MctsSymbolicRegressionStatic.cs

    r13651 r13652  
    175175          var treeGen = new SymbolicExpressionTreeGenerator(problemData.AllowedInputVariables.ToArray());
    176176          var interpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter();
    177           var simplifier = new SymbolicDataAnalysisExpressionTreeSimplifier();
    178177
    179178          var t = new SymbolicExpressionTree(treeGen.Exec(bestCode, bestConsts, bestNParams, scalingFactor, scalingOffset));
    180           var simpleT = simplifier.Simplify(t);
    181           var model = new SymbolicRegressionModel(simpleT, interpreter, lowerEstimationLimit, upperEstimationLimit);
     179          var model = new SymbolicRegressionModel(t, interpreter, lowerEstimationLimit, upperEstimationLimit);
    182180
    183181          // model has already been scaled linearly in Eval
     
    264262        alglib.minlmstate state;
    265263        alglib.minlmreport rep = null;
    266         alglib.minlmcreatevj(y.Length, optConsts, out state);
     264        alglib.minlmcreatevj(y.Length, optConsts, out state);       
    267265        alglib.minlmsetcond(state, 0.0, epsF, 0.0, nIters);
    268266        //alglib.minlmsetgradientcheck(state, 0.000001);
     
    281279
    282280      private void Func(double[] arg, double[] fi, object obj) {
    283         // 0.5 * MSE and gradient
    284281        var code = (byte[])obj;
    285282        evaluator.Exec(code, x, arg, predBuf); // gradients are nParams x vLen
     
    376373            tree.done = true;
    377374            tree.children = null;
     375            tree.visits = 1;
    378376            return false;
    379377          }
     
    436434        }
    437435      }
    438       return bestChildrenBuf.Count > 0 ? bestChildrenBuf[rand.Next(bestChildrenBuf.Count)] : bestChildrenBuf[0];
     436      return bestChildrenBuf[rand.Next(bestChildrenBuf.Count)];
    439437    }
    440438
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/SymbolicExpressionGenerator.cs

    r13650 r13652  
    113113            break;
    114114          case OpCodes.Add: {
    115               var t1 = stack[topOfStack];
    116               var t2 = stack[topOfStack - 1];
     115              var t1 = stack[topOfStack - 1];
     116              var t2 = stack[topOfStack];
    117117              topOfStack--;
    118               if (t2.Symbol is Addition) {
    119                 t2.AddSubtree(t1);
     118              if (t1.Symbol is Addition) {
     119                t1.AddSubtree(t2);
    120120              } else {
    121121                var addNode = addSy.CreateTreeNode();
     
    127127            }
    128128          case OpCodes.Mul: {
    129               var t1 = stack[topOfStack];
    130               var t2 = stack[topOfStack - 1];
     129              var t1 = stack[topOfStack - 1];
     130              var t2 = stack[topOfStack];
    131131              topOfStack--;
    132               if (t2.Symbol is Multiplication) {
    133                 t2.AddSubtree(t1);
     132              if (t1.Symbol is Multiplication) {
     133                t1.AddSubtree(t2);
    134134              } else {
    135135                var mulNode = mulSy.CreateTreeNode();
Note: See TracChangeset for help on using the changeset viewer.