Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/16/21 14:23:48 (2 years ago)
Author:
mkommend
Message:

#3136: Merged trunk changes into branch.

Location:
branches/3136_Structural_GP
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/3136_Structural_GP

  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression

  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4

  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/NMSEMultiObjectiveConstraintsEvaluator.cs

    r17958 r18146  
    9090      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    9191
    92       if (UseConstantOptimization) {
    93         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows,
     92      if (UseParameterOptimization) {
     93        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows,
    9494          false,
    95           ConstantOptimizationIterations,
    96           ConstantOptimizationUpdateVariableWeights,
     95          ParameterOptimizationIterations,
     96          ParameterOptimizationUpdateVariableWeights,
    9797          estimationLimits.Lower,
    9898          estimationLimits.Upper);
     
    105105          var scaling = offset.GetSubtree(0);
    106106
    107           //Check if tree contains offset and scaling nodes
     107          // Check if tree contains offset and scaling nodes
    108108          if (!(offset.Symbol is Addition) || !(scaling.Symbol is Multiplication))
    109109            throw new ArgumentException($"{ItemName} can only be used with LinearScalingGrammar.");
     
    115115          var newTree = new SymbolicExpressionTree(rootNode);
    116116
    117           //calculate alpha and beta for scaling
     117          // calculate alpha and beta for scaling
    118118          var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(newTree, problemData.Dataset, rows);
    119119
     
    122122            out var errorState);
    123123          if (errorState == OnlineCalculatorError.None) {
    124             //Set alpha and beta to the scaling nodes from ia grammar
    125             var offsetParameter = offset.GetSubtree(1) as ConstantTreeNode;
     124            // Set alpha and beta to the scaling nodes from linear scaling grammar
     125            var offsetParameter = offset.GetSubtree(1) as NumberTreeNode;
    126126            offsetParameter.Value = alpha;
    127             var scalingParameter = scaling.GetSubtree(1) as ConstantTreeNode;
     127            var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode;
    128128            scalingParameter.Value = beta;
    129129          }
     
    162162      double upperEstimationLimit,
    163163      IRegressionProblemData problemData, IEnumerable<int> rows, IBoundsEstimator estimator, int decimalPlaces) {
    164       OnlineCalculatorError errorState;
    165164      var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
    166165      var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
     
    174173
    175174      var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    176       nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
     175      nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out OnlineCalculatorError errorState);
    177176
    178177      if (errorState != OnlineCalculatorError.None) nmse = 1.0;
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredAverageSimilarityEvaluator.cs

    r18103 r18146  
    7676      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    7777
    78       if (UseConstantOptimization) {
    79         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     78      if (UseParameterOptimization) {
     79        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    8080      }
    8181
     
    110110
    111111      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
    112         tree, problemData, rows, 
     112        tree, problemData, rows,
    113113        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
    114114        applyLinearScaling,
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs

    r18103 r18146  
    5454      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    5555
    56       if (UseConstantOptimization) {
    57         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights,lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     56      if (UseParameterOptimization) {
     57        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights,lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    5858      }
    5959
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs

    r18103 r18146  
    5454      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    5555
    56       if (UseConstantOptimization) {
    57         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     56      if (UseParameterOptimization) {
     57        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    5858      }
    5959      double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredTreeComplexityEvaluator.cs

    r18103 r18146  
    5353      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    5454
    55       if (UseConstantOptimization) {
    56         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     55      if (UseParameterOptimization) {
     56        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    5757      }
    5858      double[] qualities = Calculate(interpreter, solution, estimationLimits.Lower, estimationLimits.Upper, problemData, rows, applyLinearScaling, DecimalPlaces);
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveEvaluator.cs

    r17180 r18146  
    3131  public abstract class SymbolicRegressionMultiObjectiveEvaluator : SymbolicDataAnalysisMultiObjectiveEvaluator<IRegressionProblemData>, ISymbolicRegressionMultiObjectiveEvaluator {
    3232    private const string DecimalPlacesParameterName = "Decimal Places";
    33     private const string UseConstantOptimizationParameterName = "Use constant optimization";
    34     private const string ConstantOptimizationIterationsParameterName = "Constant optimization iterations";
     33    private const string UseParameterOptimizationParameterName = "Use parameter optimization";
     34    private const string ParameterOptimizationIterationsParameterName = "Parameter optimization iterations";
    3535
    36     private const string ConstantOptimizationUpdateVariableWeightsParameterName =
    37       "Constant optimization update variable weights";
     36    private const string ParameterOptimizationUpdateVariableWeightsParameterName =
     37      "Parameter optimization update variable weights";
    3838
    3939    public IFixedValueParameter<IntValue> DecimalPlacesParameter {
    4040      get { return (IFixedValueParameter<IntValue>)Parameters[DecimalPlacesParameterName]; }
    4141    }
    42     public IFixedValueParameter<BoolValue> UseConstantOptimizationParameter {
    43       get { return (IFixedValueParameter<BoolValue>)Parameters[UseConstantOptimizationParameterName]; }
     42    public IFixedValueParameter<BoolValue> UseParameterOptimizationParameter {
     43      get { return (IFixedValueParameter<BoolValue>)Parameters[UseParameterOptimizationParameterName]; }
    4444    }
    4545
    46     public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter {
    47       get { return (IFixedValueParameter<IntValue>)Parameters[ConstantOptimizationIterationsParameterName]; }
     46    public IFixedValueParameter<IntValue> ParameterOptimizationIterationsParameter {
     47      get { return (IFixedValueParameter<IntValue>)Parameters[ParameterOptimizationIterationsParameterName]; }
    4848    }
    4949
    50     public IFixedValueParameter<BoolValue> ConstantOptimizationUpdateVariableWeightsParameter {
    51       get { return (IFixedValueParameter<BoolValue>)Parameters[ConstantOptimizationUpdateVariableWeightsParameterName]; }
     50    public IFixedValueParameter<BoolValue> ParameterOptimizationUpdateVariableWeightsParameter {
     51      get { return (IFixedValueParameter<BoolValue>)Parameters[ParameterOptimizationUpdateVariableWeightsParameterName]; }
    5252    }
    5353
     
    5656      set { DecimalPlacesParameter.Value.Value = value; }
    5757    }
    58     public bool UseConstantOptimization {
    59       get { return UseConstantOptimizationParameter.Value.Value; }
    60       set { UseConstantOptimizationParameter.Value.Value = value; }
     58    public bool UseParameterOptimization {
     59      get { return UseParameterOptimizationParameter.Value.Value; }
     60      set { UseParameterOptimizationParameter.Value.Value = value; }
    6161    }
    62     public int ConstantOptimizationIterations {
    63       get { return ConstantOptimizationIterationsParameter.Value.Value; }
    64       set { ConstantOptimizationIterationsParameter.Value.Value = value; }
     62    public int ParameterOptimizationIterations {
     63      get { return ParameterOptimizationIterationsParameter.Value.Value; }
     64      set { ParameterOptimizationIterationsParameter.Value.Value = value; }
    6565    }
    66     public bool ConstantOptimizationUpdateVariableWeights {
    67       get { return ConstantOptimizationUpdateVariableWeightsParameter.Value.Value; }
    68       set { ConstantOptimizationUpdateVariableWeightsParameter.Value.Value = value; }
     66    public bool ParameterOptimizationUpdateVariableWeights {
     67      get { return ParameterOptimizationUpdateVariableWeightsParameter.Value.Value; }
     68      set { ParameterOptimizationUpdateVariableWeightsParameter.Value.Value = value; }
    6969    }
    7070
     
    7878      : base() {
    7979      Parameters.Add(new FixedValueParameter<IntValue>(DecimalPlacesParameterName, "The number of decimal places used for rounding the quality values.", new IntValue(5)) { Hidden = true });
    80       Parameters.Add(new FixedValueParameter<BoolValue>(UseConstantOptimizationParameterName, "", new BoolValue(false)));
    81       Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsParameterName, "The number of iterations constant optimization should be applied.", new IntValue(5)));
    82       Parameters.Add(new FixedValueParameter<BoolValue>(ConstantOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during constant optimization.", new BoolValue(true)) { Hidden = true });
     80      Parameters.Add(new FixedValueParameter<BoolValue>(UseParameterOptimizationParameterName, "", new BoolValue(false)));
     81      Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, "The number of iterations parameter optimization should be applied.", new IntValue(5)));
     82      Parameters.Add(new FixedValueParameter<BoolValue>(ParameterOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during parameter optimization.", new BoolValue(true)) { Hidden = true });
    8383    }
    8484
    8585    [StorableHook(HookType.AfterDeserialization)]
    8686    private void AfterDeserialization() {
    87       if (!Parameters.ContainsKey(UseConstantOptimizationParameterName)) {
    88         Parameters.Add(new FixedValueParameter<BoolValue>(UseConstantOptimizationParameterName, "", new BoolValue(false)));
     87      if (!Parameters.ContainsKey(UseParameterOptimizationParameterName)) {
     88        if (Parameters.ContainsKey("Use constant optimization")) {
     89          Parameters.Add(new FixedValueParameter<BoolValue>(UseParameterOptimizationParameterName, "", (BoolValue)Parameters["Use constant optimization"].ActualValue));
     90          Parameters.Remove("Use constant optimization");
     91        } else {
     92          Parameters.Add(new FixedValueParameter<BoolValue>(UseParameterOptimizationParameterName, "", new BoolValue(false)));
     93        }
    8994      }
     95
    9096      if (!Parameters.ContainsKey(DecimalPlacesParameterName)) {
    9197        Parameters.Add(new FixedValueParameter<IntValue>(DecimalPlacesParameterName, "The number of decimal places used for rounding the quality values.", new IntValue(-1)) { Hidden = true });
    9298      }
    93       if (!Parameters.ContainsKey(ConstantOptimizationIterationsParameterName)) {
    94         Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsParameterName, "The number of iterations constant optimization should be applied.", new IntValue(5)));
     99      if (!Parameters.ContainsKey(ParameterOptimizationIterationsParameterName)) {
     100        if (Parameters.ContainsKey("Constant optimization iterations")) {
     101          Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, "The number of iterations parameter optimization should be applied.", (IntValue)Parameters["Constant optimization iterations"].ActualValue));
     102          Parameters.Remove("Constant optimization iterations");
     103        } else {
     104          Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, "The number of iterations parameter optimization should be applied.", new IntValue(5)));
     105        }
    95106      }
    96       if (!Parameters.ContainsKey(ConstantOptimizationUpdateVariableWeightsParameterName)) {
    97         Parameters.Add(new FixedValueParameter<BoolValue>(ConstantOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during constant optimization.", new BoolValue(true)));
     107      if (!Parameters.ContainsKey(ParameterOptimizationUpdateVariableWeightsParameterName)) {
     108        if (Parameters.ContainsKey("Constant optimization update variable weights")) {
     109          Parameters.Add(new FixedValueParameter<BoolValue>(ParameterOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during parameter optimization.",
     110            (BoolValue)Parameters["Constant optimization update variable weights"].ActualValue));
     111          Parameters.Remove("Constant optimization update variable weights");
     112        } else {
     113          Parameters.Add(new FixedValueParameter<BoolValue>(ParameterOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during parameter optimization.", new BoolValue(true)));
     114        }
    98115      }
    99116    }
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r18103 r18146  
    2222using System;
    2323using System.Collections.Generic;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     
    5353      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    5454
    55       if (UseConstantOptimization) {
    56         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     55      if (UseParameterOptimization) {
     56        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    5757      }
    5858
    5959      double[] qualities = Calculate(
    60         tree, ProblemDataParameter.ActualValue, 
    61         rows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, 
    62         ApplyLinearScalingParameter.ActualValue.Value, 
    63         EstimationLimitsParameter.ActualValue.Lower, 
    64         EstimationLimitsParameter.ActualValue.Upper, 
     60        tree, ProblemDataParameter.ActualValue,
     61        rows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     62        ApplyLinearScalingParameter.ActualValue.Value,
     63        EstimationLimitsParameter.ActualValue.Lower,
     64        EstimationLimitsParameter.ActualValue.Upper,
    6565        DecimalPlaces);
    6666      QualitiesParameter.ActualValue = new DoubleArray(qualities);
     
    7070    public static double[] Calculate(
    7171      ISymbolicExpressionTree tree,
    72       IRegressionProblemData problemData, 
     72      IRegressionProblemData problemData,
    7373      IEnumerable<int> rows,
    7474      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     
    7777      int decimalPlaces) {
    7878      var mse = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate(
    79         tree, problemData, rows, 
    80         interpreter, applyLinearScaling, 
     79        tree, problemData, rows,
     80        interpreter, applyLinearScaling,
    8181        lowerEstimationLimit,
    8282        upperEstimationLimit);
     
    9494
    9595      double[] quality = Calculate(
    96         tree, problemData, rows, 
    97         SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, 
    98         ApplyLinearScalingParameter.ActualValue.Value, 
    99         EstimationLimitsParameter.ActualValue.Lower, 
     96        tree, problemData, rows,
     97        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     98        ApplyLinearScalingParameter.ActualValue.Value,
     99        EstimationLimitsParameter.ActualValue.Lower,
    100100        EstimationLimitsParameter.ActualValue.Upper, DecimalPlaces);
    101101
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r18103 r18146  
    5353      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    5454
    55       if (UseConstantOptimization) {
    56         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     55      if (UseParameterOptimization) {
     56        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    5757      }
    5858      double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
Note: See TracChangeset for help on using the changeset viewer.