Changeset 18180 for branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Timestamp:
- 01/10/22 10:15:25 (3 years ago)
- Location:
- branches/3138_Shape_Constraints_Transformations
- Files:
-
- 2 deleted
- 16 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3138_Shape_Constraints_Transformations
- Property svn:mergeinfo changed
-
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Property svn:mergeinfo changed
-
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Property svn:mergeinfo changed
-
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj
r18053 r18180 129 129 <Compile Include="Plugin.cs" /> 130 130 <Compile Include="ShapeConstraintsAnalyzer.cs" /> 131 <Compile Include="SingleObjective\ ConstantOptimizationAnalyzer.cs" />131 <Compile Include="SingleObjective\ParameterOptimizationAnalyzer.cs" /> 132 132 <Compile Include="SingleObjective\Evaluators\NMSESingleObjectiveConstraintsEvaluator.cs" /> 133 133 <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" /> … … 142 142 <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs" /> 143 143 <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs" /> 144 <Compile Include="SingleObjective\Evaluators\SymbolicRegression ConstantOptimizationEvaluator.cs" />144 <Compile Include="SingleObjective\Evaluators\SymbolicRegressionParameterOptimizationEvaluator.cs" /> 145 145 <Compile Include="SingleObjective\SymbolicRegressionSingleObjectiveOverfittingAnalyzer.cs" /> 146 146 <Compile Include="SymbolicRegressionModel.cs" /> -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/IMultiObjectiveConstraintsEvaluator.cs
r17959 r18180 27 27 [StorableType("F96C5253-5A78-491C-95AE-78F64BD1F3B1")] 28 28 public interface IMultiObjectiveConstraintsEvaluator : ISymbolicRegressionMultiObjectiveEvaluator { 29 30 29 IFixedValueParameter<IntValue> NumConstraintsParameter { get; } 31 30 } -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/NMSEMultiObjectiveConstraintsEvaluator.cs
r17958 r18180 90 90 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 91 91 92 if (Use ConstantOptimization) {93 SymbolicRegression ConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows,92 if (UseParameterOptimization) { 93 SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows, 94 94 false, 95 ConstantOptimizationIterations,96 ConstantOptimizationUpdateVariableWeights,95 ParameterOptimizationIterations, 96 ParameterOptimizationUpdateVariableWeights, 97 97 estimationLimits.Lower, 98 98 estimationLimits.Upper); … … 105 105 var scaling = offset.GetSubtree(0); 106 106 107 // Check if tree contains offset and scaling nodes107 // Check if tree contains offset and scaling nodes 108 108 if (!(offset.Symbol is Addition) || !(scaling.Symbol is Multiplication)) 109 109 throw new ArgumentException($"{ItemName} can only be used with LinearScalingGrammar."); … … 115 115 var newTree = new SymbolicExpressionTree(rootNode); 116 116 117 // calculate alpha and beta for scaling117 // calculate alpha and beta for scaling 118 118 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(newTree, problemData.Dataset, rows); 119 119 … … 122 122 out var errorState); 123 123 if (errorState == OnlineCalculatorError.None) { 124 // Set alpha and beta to the scaling nodes from iagrammar125 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; 126 126 offsetParameter.Value = alpha; 127 var scalingParameter = scaling.GetSubtree(1) as ConstantTreeNode;127 var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode; 128 128 scalingParameter.Value = beta; 129 129 } … … 162 162 double upperEstimationLimit, 163 163 IRegressionProblemData problemData, IEnumerable<int> rows, IBoundsEstimator estimator, int decimalPlaces) { 164 OnlineCalculatorError errorState;165 164 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 166 165 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); … … 174 173 175 174 var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 176 nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);175 nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out OnlineCalculatorError errorState); 177 176 178 177 if (errorState != OnlineCalculatorError.None) nmse = 1.0; -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredAverageSimilarityEvaluator.cs
r17180 r18180 76 76 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 77 77 78 if (Use ConstantOptimization) {79 SymbolicRegression ConstantOptimizationEvaluator.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); 80 80 } 81 81 -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs
r17180 r18180 54 54 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 55 55 56 if (Use ConstantOptimization) {57 SymbolicRegression ConstantOptimizationEvaluator.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); 58 58 } 59 59 -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs
r17180 r18180 54 54 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 55 55 56 if (Use ConstantOptimization) {57 SymbolicRegression ConstantOptimizationEvaluator.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); 58 58 } 59 59 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 53 53 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 54 54 55 if (Use ConstantOptimization) {56 SymbolicRegression ConstantOptimizationEvaluator.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); 57 57 } 58 58 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 31 31 public abstract class SymbolicRegressionMultiObjectiveEvaluator : SymbolicDataAnalysisMultiObjectiveEvaluator<IRegressionProblemData>, ISymbolicRegressionMultiObjectiveEvaluator { 32 32 private const string DecimalPlacesParameterName = "Decimal Places"; 33 private const string Use ConstantOptimizationParameterName = "Use constantoptimization";34 private const string ConstantOptimizationIterationsParameterName = "Constantoptimization iterations";33 private const string UseParameterOptimizationParameterName = "Use parameter optimization"; 34 private const string ParameterOptimizationIterationsParameterName = "Parameter optimization iterations"; 35 35 36 private const string ConstantOptimizationUpdateVariableWeightsParameterName =37 " Constantoptimization update variable weights";36 private const string ParameterOptimizationUpdateVariableWeightsParameterName = 37 "Parameter optimization update variable weights"; 38 38 39 39 public IFixedValueParameter<IntValue> DecimalPlacesParameter { 40 40 get { return (IFixedValueParameter<IntValue>)Parameters[DecimalPlacesParameterName]; } 41 41 } 42 public IFixedValueParameter<BoolValue> Use ConstantOptimizationParameter {43 get { return (IFixedValueParameter<BoolValue>)Parameters[Use ConstantOptimizationParameterName]; }42 public IFixedValueParameter<BoolValue> UseParameterOptimizationParameter { 43 get { return (IFixedValueParameter<BoolValue>)Parameters[UseParameterOptimizationParameterName]; } 44 44 } 45 45 46 public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter {47 get { return (IFixedValueParameter<IntValue>)Parameters[ ConstantOptimizationIterationsParameterName]; }46 public IFixedValueParameter<IntValue> ParameterOptimizationIterationsParameter { 47 get { return (IFixedValueParameter<IntValue>)Parameters[ParameterOptimizationIterationsParameterName]; } 48 48 } 49 49 50 public IFixedValueParameter<BoolValue> ConstantOptimizationUpdateVariableWeightsParameter {51 get { return (IFixedValueParameter<BoolValue>)Parameters[ ConstantOptimizationUpdateVariableWeightsParameterName]; }50 public IFixedValueParameter<BoolValue> ParameterOptimizationUpdateVariableWeightsParameter { 51 get { return (IFixedValueParameter<BoolValue>)Parameters[ParameterOptimizationUpdateVariableWeightsParameterName]; } 52 52 } 53 53 … … 56 56 set { DecimalPlacesParameter.Value.Value = value; } 57 57 } 58 public bool Use ConstantOptimization {59 get { return Use ConstantOptimizationParameter.Value.Value; }60 set { Use ConstantOptimizationParameter.Value.Value = value; }58 public bool UseParameterOptimization { 59 get { return UseParameterOptimizationParameter.Value.Value; } 60 set { UseParameterOptimizationParameter.Value.Value = value; } 61 61 } 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; } 65 65 } 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; } 69 69 } 70 70 … … 78 78 : base() { 79 79 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>(Use ConstantOptimizationParameterName, "", new BoolValue(false)));81 Parameters.Add(new FixedValueParameter<IntValue>( ConstantOptimizationIterationsParameterName, "The number of iterations constantoptimization 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 constantoptimization.", 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 }); 83 83 } 84 84 85 85 [StorableHook(HookType.AfterDeserialization)] 86 86 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 } 89 94 } 95 90 96 if (!Parameters.ContainsKey(DecimalPlacesParameterName)) { 91 97 Parameters.Add(new FixedValueParameter<IntValue>(DecimalPlacesParameterName, "The number of decimal places used for rounding the quality values.", new IntValue(-1)) { Hidden = true }); 92 98 } 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 } 95 106 } 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 } 98 115 } 99 116 } -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs
r17180 r18180 53 53 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 54 54 55 if (Use ConstantOptimization) {56 SymbolicRegression ConstantOptimizationEvaluator.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); 57 57 } 58 58 -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs
r17180 r18180 53 53 var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value; 54 54 55 if (Use ConstantOptimization) {56 SymbolicRegression ConstantOptimizationEvaluator.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); 57 57 } 58 58 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 46 46 (IFixedValueParameter<BoolValue>)Parameters[OptimizeParametersParameterName]; 47 47 48 public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter =>48 public IFixedValueParameter<IntValue> ParameterOptimizationIterationsParameter => 49 49 (IFixedValueParameter<IntValue>)Parameters[ParameterOptimizationIterationsParameterName]; 50 50 … … 62 62 } 63 63 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; 67 67 } 68 68 … … 97 97 public NMSESingleObjectiveConstraintsEvaluator() { 98 98 Parameters.Add(new FixedValueParameter<BoolValue>(OptimizeParametersParameterName, 99 "Define whether optimization of numericparameters is active or not (default: false).", new BoolValue(false)));99 "Define whether optimization of parameters is active or not (default: false).", new BoolValue(false))); 100 100 Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, 101 101 "Define how many parameter optimization steps should be performed (default: 10).", new IntValue(10))); … … 126 126 127 127 if (OptimizeParameters) { 128 SymbolicRegression ConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows,129 false, ConstantOptimizationIterations, true,128 SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows, 129 false, ParameterOptimizationIterations, true, 130 130 estimationLimits.Lower, estimationLimits.Upper); 131 131 } else { … … 155 155 if (errorState == OnlineCalculatorError.None) { 156 156 //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; 158 158 offsetParameter.Value = alpha; 159 var scalingParameter = scaling.GetSubtree(1) as ConstantTreeNode;159 var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode; 160 160 scalingParameter.Value = beta; 161 161 } -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ShapeConstrainedRegressionSingleObjectiveProblem.cs
r17964 r18180 28 28 [StorableType("B35ADCA7-E902-4BEE-9DDE-DF8BBC1E27FE")] 29 29 [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 150)] 30 public class ShapeConstrainedRegressionSingleObjectiveProblem : SymbolicRegressionSingleObjectiveProblem {30 public class ShapeConstrainedRegressionSingleObjectiveProblem : SymbolicRegressionSingleObjectiveProblem, IShapeConstrainedRegressionProblem { 31 31 [StorableConstructor] 32 32 protected ShapeConstrainedRegressionSingleObjectiveProblem(StorableConstructorFlag _) : base(_) { } … … 34 34 public override IDeepCloneable Clone(Cloner cloner) { return new ShapeConstrainedRegressionSingleObjectiveProblem(this, cloner); } 35 35 36 public ShapeConstrainedRegressionProblemData ShapeConstrainedRegressionProblemData { 37 get => (ShapeConstrainedRegressionProblemData)ProblemData; 38 set => ProblemData = value; 39 } 36 40 public ShapeConstrainedRegressionSingleObjectiveProblem() 37 41 : base(new ShapeConstrainedRegressionProblemData(), new NMSESingleObjectiveConstraintsEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { … … 51 55 52 56 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 } 58 65 59 66 base.Load(scProblemData); -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs
r17180 r18180 91 91 for (int i = 0; i < nodes.Count; ++i) { 92 92 var node = nodes[i]; 93 if (node is ConstantTreeNode) continue;93 if (node is INumericTreeNode) continue; // skip constants and numbers 94 94 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); 98 97 99 98 if (pruneOnlyZeroImpactNodes && !impactValue.IsAlmost(0.0)) continue; 100 99 if (!pruneOnlyZeroImpactNodes && impactValue > nodeImpactThreshold) continue; 101 100 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; 104 103 105 ReplaceWith Constant(node, constantNode);104 ReplaceWithNumber(node, numNode); 106 105 i += node.GetLength() - 1; // skip subtrees under the node that was folded 107 106
Note: See TracChangeset
for help on using the changeset viewer.