Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13300


Ignore:
Timestamp:
11/19/15 14:15:19 (9 years ago)
Author:
gkronber
Message:

#2175 made some changes while reviewing the code

Location:
trunk/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs

    r13241 r13300  
    4444    public PearsonRSquaredNestedTreeSizeEvaluator() : base() { }
    4545
    46     public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } }
     46    public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } } // maximize R² & minimize nested tree size
    4747
    4848    public override IOperation InstrumentedApply() {
     
    6767      if (decimalPlaces >= 0)
    6868        r2 = Math.Round(r2, decimalPlaces);
    69       return new double[2] { r2, solution.IterateNodesPostfix().Sum(n => n.GetLength()) };
     69      return new double[2] { r2, solution.IterateNodesPostfix().Sum(n => n.GetLength()) }; // sum of the length of the whole sub-tree for each node
    7070    }
    7171
     
    7474      EstimationLimitsParameter.ExecutionContext = context;
    7575      ApplyLinearScalingParameter.ExecutionContext = context;
     76      // DecimalPlaces parameter is a FixedValueParameter and doesn't need the context.
    7677
    77       double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
     78      double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces); 
    7879
    7980      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs

    r13241 r13300  
    4444    public PearsonRSquaredNumberOfVariablesEvaluator() : base() { }
    4545
    46     public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } }
     46    public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } } // maximize R² and minimize the number of variables
    4747
    4848    public override IOperation InstrumentedApply() {
     
    6666      if (decimalPlaces >= 0)
    6767        r2 = Math.Round(r2, decimalPlaces);
    68       return new double[2] { r2, solution.IterateNodesPostfix().OfType<VariableTreeNode>().Count() };
     68      return new double[2] { r2, solution.IterateNodesPostfix().OfType<VariableTreeNode>().Count() }; // count the number of variables
    6969    }
    7070
     
    7373      EstimationLimitsParameter.ExecutionContext = context;
    7474      ApplyLinearScalingParameter.ExecutionContext = context;
     75      // DecimalPlaces parameter is a FixedValueParameter and doesn't need the context.
    7576
    7677      double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredTreeComplexityEvaluator.cs

    r13241 r13300  
    4343    public PearsonRSquaredTreeComplexityEvaluator() : base() { }
    4444
    45     public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } }
     45    public override IEnumerable<bool> Maximization { get { return new bool[2] { true, false }; } } // maximize R² and minimize model complexity
    4646
    4747    public override IOperation InstrumentedApply() {
     
    7272      EstimationLimitsParameter.ExecutionContext = context;
    7373      ApplyLinearScalingParameter.ExecutionContext = context;
     74      // DecimalPlaces parameter is a FixedValueParameter and doesn't need the context.
    7475
    7576      double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs

    r12509 r13300  
    164164
    165165
     166    // TODO: swap positions of lowerEstimationLimit and upperEstimationLimit parameters
    166167    public static double OptimizeConstants(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, IRegressionProblemData problemData,
    167168      IEnumerable<int> rows, bool applyLinearScaling, int maxIterations, double upperEstimationLimit = double.MaxValue, double lowerEstimationLimit = double.MinValue, bool updateConstantsInTree = true) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplificationOperator.cs

    r13241 r13300  
    2828
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    30   [Item("SymbolicExpressionTreeSimplificationOperator", "Simplfies symbolic expression trees encoding a mathematical formula.")]
     30  [Item("SymbolicExpressionTreeSimplificationOperator", "Simplifies symbolic expression trees encoding a mathematical formula.")]
    3131  [StorableClass]
    3232  public class SymbolicDataAnalysisExpressionTreeSimplificationOperator : SingleSuccessorOperator, ISymbolicExpressionTreeOperator {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModelComplexityCalculator.cs

    r13241 r13300  
    4242            return 2;
    4343          }
    44         case OpCodes.Add: {
    45             double complexity = 0;
    46             for (int i = 0; i < node.SubtreeCount; i++) {
    47               complexity += CalculateComplexity(node.GetSubtree(i));
    48             }
    49             return complexity;
    50           }
     44        case OpCodes.Add:
    5145        case OpCodes.Sub: {
    5246            double complexity = 0;
     
    5650            return complexity;
    5751          }
    58         case OpCodes.Mul: {
    59             double complexity = 1;
    60             for (int i = 0; i < node.SubtreeCount; i++) {
    61               var nodeComplexity = CalculateComplexity(node.GetSubtree(i));
    62               complexity *= nodeComplexity + 1;
    63             }
    64             return complexity;
    65           }
     52        case OpCodes.Mul:
    6653        case OpCodes.Div: {
    6754            double complexity = 1;
     
    7259            return complexity;
    7360          }
    74         case OpCodes.Sin: {
    75             double complexity = CalculateComplexity(node.GetSubtree(0));
    76             return Math.Pow(2.0, complexity);
    77           }
    78         case OpCodes.Cos: {
    79             double complexity = CalculateComplexity(node.GetSubtree(0));
    80             return Math.Pow(2.0, complexity);
    81           }
    82         case OpCodes.Tan: {
    83             double complexity = CalculateComplexity(node.GetSubtree(0));
    84             return Math.Pow(2.0, complexity);
    85           }
    86         case OpCodes.Exp: {
    87             double complexity = CalculateComplexity(node.GetSubtree(0));
    88             return Math.Pow(2.0, complexity);
    89           }
     61        case OpCodes.Sin:
     62        case OpCodes.Cos:
     63        case OpCodes.Tan:
     64        case OpCodes.Exp:
    9065        case OpCodes.Log: {
    9166            double complexity = CalculateComplexity(node.GetSubtree(0));
     
    10075            return complexity * complexity * complexity;
    10176          }
    102         case OpCodes.Power: {
     77        case OpCodes.Power:         
     78        case OpCodes.Root: {
    10379            double complexity = CalculateComplexity(node.GetSubtree(0));
    104             var exponentNode = node.GetSubtree(1) as ConstantTreeNode;
    105             if (exponentNode != null) {
    106               double exponent = exponentNode.Value;
    107               if (exponent < 0) exponent = Math.Abs(exponent);
    108               if (exponent < 1) exponent = 1 / exponent;
    109               return Math.Pow(complexity, Math.Round(exponent));
     80            var exponent = node.GetSubtree(1) as ConstantTreeNode;
     81            if (exponent != null) {
     82              double expVal = exponent.Value;
     83              if (expVal < 0) expVal = Math.Abs(expVal);
     84              if (expVal < 1) expVal = 1 / expVal;
     85              return Math.Pow(complexity, Math.Round(expVal));
    11086            }
    11187
    112             double exponentComplexity = CalculateComplexity(node.GetSubtree(1));
    113             return Math.Pow(complexity, 2 * exponentComplexity);
    114           }
    115         case OpCodes.Root: {
    116             double complexity = CalculateComplexity(node.GetSubtree(0));
    117             var rootNode = node.GetSubtree(1) as ConstantTreeNode;
    118             if (rootNode != null) {
    119               double root = rootNode.Value;
    120               if (root < 0) root = Math.Abs(root);
    121               if (root < 1) root = 1 / root;
    122               return Math.Pow(complexity, Math.Round(root));
    123             }
    124 
    125             double rootComplexity = CalculateComplexity(node.GetSubtree(1));
    126             return Math.Pow(complexity, 2 * rootComplexity);
     88            double expComplexity = CalculateComplexity(node.GetSubtree(1));
     89            return Math.Pow(complexity, 2 * expComplexity);
    12790          }
    12891
Note: See TracChangeset for help on using the changeset viewer.