Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/10/22 10:15:25 (3 years ago)
Author:
dpiringe
Message:

#3138

  • merged trunk into branch
Location:
branches/3138_Shape_Constraints_Transformations
Files:
2 deleted
16 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/3138_Shape_Constraints_Transformations

  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression

  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4

  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj

    r18053 r18180  
    129129    <Compile Include="Plugin.cs" />
    130130    <Compile Include="ShapeConstraintsAnalyzer.cs" />
    131     <Compile Include="SingleObjective\ConstantOptimizationAnalyzer.cs" />
     131    <Compile Include="SingleObjective\ParameterOptimizationAnalyzer.cs" />
    132132    <Compile Include="SingleObjective\Evaluators\NMSESingleObjectiveConstraintsEvaluator.cs" />
    133133    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" />
     
    142142    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs" />
    143143    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs" />
    144     <Compile Include="SingleObjective\Evaluators\SymbolicRegressionConstantOptimizationEvaluator.cs" />
     144    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionParameterOptimizationEvaluator.cs" />
    145145    <Compile Include="SingleObjective\SymbolicRegressionSingleObjectiveOverfittingAnalyzer.cs" />
    146146    <Compile Include="SymbolicRegressionModel.cs" />
  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/IMultiObjectiveConstraintsEvaluator.cs

    r17959 r18180  
    2727  [StorableType("F96C5253-5A78-491C-95AE-78F64BD1F3B1")]
    2828  public interface IMultiObjectiveConstraintsEvaluator : ISymbolicRegressionMultiObjectiveEvaluator {
    29 
    3029    IFixedValueParameter<IntValue> NumConstraintsParameter { get; }
    3130  }
  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/NMSEMultiObjectiveConstraintsEvaluator.cs

    r17958 r18180  
    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/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredAverageSimilarityEvaluator.cs

    r17180 r18180  
    7676      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    7777
    78       if (UseConstantOptimization) {
    79         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     78      if (UseParameterOptimization) {
     79        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    8080      }
    8181
  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs

    r17180 r18180  
    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/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs

    r17180 r18180  
    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/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredTreeComplexityEvaluator.cs

    r17180 r18180  
    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/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveEvaluator.cs

    r17180 r18180  
    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/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r17180 r18180  
    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
  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r17180 r18180  
    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);
  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs

    r17958 r18180  
    4646      (IFixedValueParameter<BoolValue>)Parameters[OptimizeParametersParameterName];
    4747
    48     public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter =>
     48    public IFixedValueParameter<IntValue> ParameterOptimizationIterationsParameter =>
    4949      (IFixedValueParameter<IntValue>)Parameters[ParameterOptimizationIterationsParameterName];
    5050
     
    6262    }
    6363
    64     public int ConstantOptimizationIterations {
    65       get => ConstantOptimizationIterationsParameter.Value.Value;
    66       set => ConstantOptimizationIterationsParameter.Value.Value = value;
     64    public int ParameterOptimizationIterations {
     65      get => ParameterOptimizationIterationsParameter.Value.Value;
     66      set => ParameterOptimizationIterationsParameter.Value.Value = value;
    6767    }
    6868
     
    9797    public NMSESingleObjectiveConstraintsEvaluator() {
    9898      Parameters.Add(new FixedValueParameter<BoolValue>(OptimizeParametersParameterName,
    99         "Define whether optimization of numeric parameters is active or not (default: false).", new BoolValue(false)));
     99        "Define whether optimization of parameters is active or not (default: false).", new BoolValue(false)));
    100100      Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName,
    101101        "Define how many parameter optimization steps should be performed (default: 10).", new IntValue(10)));
     
    126126
    127127      if (OptimizeParameters) {
    128         SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows,
    129           false, ConstantOptimizationIterations, true,
     128        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows,
     129          false, ParameterOptimizationIterations, true,
    130130          estimationLimits.Lower, estimationLimits.Upper);
    131131      } else {
     
    155155          if (errorState == OnlineCalculatorError.None) {
    156156            //Set alpha and beta to the scaling nodes from ia grammar
    157             var offsetParameter = offset.GetSubtree(1) as ConstantTreeNode;
     157            var offsetParameter = offset.GetSubtree(1) as NumberTreeNode;
    158158            offsetParameter.Value = alpha;
    159             var scalingParameter = scaling.GetSubtree(1) as ConstantTreeNode;
     159            var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode;
    160160            scalingParameter.Value = beta;
    161161          }
  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ShapeConstrainedRegressionSingleObjectiveProblem.cs

    r17964 r18180  
    2828  [StorableType("B35ADCA7-E902-4BEE-9DDE-DF8BBC1E27FE")]
    2929  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 150)]
    30   public class ShapeConstrainedRegressionSingleObjectiveProblem : SymbolicRegressionSingleObjectiveProblem {
     30  public class ShapeConstrainedRegressionSingleObjectiveProblem : SymbolicRegressionSingleObjectiveProblem, IShapeConstrainedRegressionProblem {
    3131    [StorableConstructor]
    3232    protected ShapeConstrainedRegressionSingleObjectiveProblem(StorableConstructorFlag _) : base(_) { }
     
    3434    public override IDeepCloneable Clone(Cloner cloner) { return new ShapeConstrainedRegressionSingleObjectiveProblem(this, cloner); }
    3535
     36    public ShapeConstrainedRegressionProblemData ShapeConstrainedRegressionProblemData {
     37      get => (ShapeConstrainedRegressionProblemData)ProblemData;
     38      set => ProblemData = value;
     39    }
    3640    public ShapeConstrainedRegressionSingleObjectiveProblem()
    3741      : base(new ShapeConstrainedRegressionProblemData(), new NMSESingleObjectiveConstraintsEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
     
    5155
    5256    public override void Load(IRegressionProblemData data) {
    53       var scProblemData = new ShapeConstrainedRegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable,
    54                                                                     data.TrainingPartition, data.TestPartition) {
    55         Name = data.Name,
    56         Description = data.Description
    57       };
     57      if (data is ShapeConstrainedRegressionProblemData scProblemData) {
     58      } else {
     59        scProblemData = new ShapeConstrainedRegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable,
     60                                                                  data.TrainingPartition, data.TestPartition) {
     61          Name = data.Name,
     62          Description = data.Description
     63        };
     64      }
    5865
    5966      base.Load(scProblemData);
  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs

    r17180 r18180  
    9191      for (int i = 0; i < nodes.Count; ++i) {
    9292        var node = nodes[i];
    93         if (node is ConstantTreeNode) continue;
     93        if (node is INumericTreeNode) continue; // skip constants and numbers
    9494
    95         double impactValue, replacementValue;
    96         double newQualityForImpactsCalculation;
    97         impactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, out newQualityForImpactsCalculation, qualityForImpactsCalculation);
     95        impactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows,
     96          out double impactValue, out double replacementValue, out double newQualityForImpactsCalculation, qualityForImpactsCalculation);
    9897
    9998        if (pruneOnlyZeroImpactNodes && !impactValue.IsAlmost(0.0)) continue;
    10099        if (!pruneOnlyZeroImpactNodes && impactValue > nodeImpactThreshold) continue;
    101100
    102         var constantNode = (ConstantTreeNode)node.Grammar.GetSymbol("Constant").CreateTreeNode();
    103         constantNode.Value = replacementValue;
     101        var numNode = (NumberTreeNode)node.Grammar.GetSymbol("Number").CreateTreeNode();
     102        numNode.Value = replacementValue;
    104103
    105         ReplaceWithConstant(node, constantNode);
     104        ReplaceWithNumber(node, numNode);
    106105        i += node.GetLength() - 1; // skip subtrees under the node that was folded
    107106
Note: See TracChangeset for help on using the changeset viewer.