Changeset 17764
- Timestamp:
- 09/27/20 22:22:54 (4 years ago)
- Location:
- branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintConstOptNmseEvaluator.cs
r17751 r17764 16 16 private const string ConstOptIterationsParameterName = "ConstOpt Iterations"; 17 17 private const string PenalityMultiplierParameterName = "ConstraintsPenalityMultiplier"; 18 private const string BoundsEstimatorParameterName = "Bounds estimator"; 18 19 19 20 public IFixedValueParameter<BoolValue> UseConstOptParamerter => … … 26 27 (ILookupParameter<DoubleValue>)Parameters[PenalityMultiplierParameterName]; 27 28 29 public IValueParameter<IBoundsEstimator> BoundsEstimatorParameter => 30 (IValueParameter<IBoundsEstimator>) Parameters[BoundsEstimatorParameterName]; 31 28 32 public bool UseConstOpt { 29 33 get => UseConstOptParamerter.Value.Value; … … 34 38 get => ConstOpterIterationsParameter.Value.Value; 35 39 set => ConstOpterIterationsParameter.Value.Value = value; 40 } 41 42 public IBoundsEstimator BoundsEstimator { 43 get => BoundsEstimatorParameter.Value; 44 set => BoundsEstimatorParameter.Value = value; 36 45 } 37 46 … … 54 63 Parameters.Add(new LookupParameter<DoubleValue>(PenalityMultiplierParameterName, 55 64 "Lookup parameter for the penality multiplier.", "PenalityMultiplier")); 65 Parameters.Add(new ValueParameter<IBoundsEstimator>(BoundsEstimatorParameterName, "Select the Boundsestimator.", new IABoundsEstimator())); 56 66 } 57 67 … … 73 83 Parameters.Add(new LookupParameter<DoubleValue>(PenalityMultiplierParameterName, 74 84 "Lookup parameter for the penality multiplier.", "PenalityMultiplier")); 85 86 if (!Parameters.ContainsKey(BoundsEstimatorParameterName)) 87 Parameters.Add(new ValueParameter<IBoundsEstimator>(BoundsEstimatorParameterName, "Select the Boundsestimator.", new IABoundsEstimator())); 75 88 } 76 89 77 90 public override IOperation InstrumentedApply() { 78 var rows 79 var solution 91 var rows = GenerateRowsToEvaluate(); 92 var solution = SymbolicExpressionTreeParameter.ActualValue; 80 93 var problemData = ProblemDataParameter.ActualValue; 81 94 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 82 var estimationLimits 95 var estimationLimits = EstimationLimitsParameter.ActualValue; 83 96 var applyLinearScaling = false; 84 var constantOptimizationIterations 97 var constantOptimizationIterations = ConstOptIterations; 85 98 var constantOptimizationUpdateVariableWeights = true; 86 99 … … 115 128 var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit); 116 129 var nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out var errorState); 117 if (!SymbolicRegressionConstraintAnalyzer.ConstraintsSatisfied(constraints, variableRanges, solution, false,out double error))130 if (!SymbolicRegressionConstraintAnalyzer.ConstraintsSatisfied(constraints, variableRanges, solution, out double error)) 118 131 { 119 132 if (double.IsNaN(error) || double.IsInfinity(error)) -
branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintEvaluator.cs
r17751 r17764 27 27 private const string PenaltyMultiplierParameterName = "Constraints Penalty Multiplier"; 28 28 29 private const string UseIntervalSplittingParameterName = "Use Interval Splitting"; 29 private const string BoundsEstimatorParameterName = "Bounds estimator"; 30 30 31 31 32 public IFixedValueParameter<BoolValue> UseConstantOptimizationParameter => … … 41 42 (IFixedValueParameter<DoubleValue>) Parameters[PenaltyMultiplierParameterName]; 42 43 43 public I FixedValueParameter<BoolValue> UseIntervalSplittingParameter =>44 (I FixedValueParameter<BoolValue>) Parameters[UseIntervalSplittingParameterName];44 public IValueParameter<IBoundsEstimator> BoundsEstimatorParameter => 45 (IValueParameter<IBoundsEstimator>)Parameters[BoundsEstimatorParameterName]; 45 46 46 47 public bool UseConstantOptimization { … … 64 65 } 65 66 66 public bool UseIntervalSplitting { 67 get => UseIntervalSplittingParameter.Value.Value; 68 set => UseIntervalSplittingParameter.Value.Value = value; 69 } 67 public IBoundsEstimator BoundsEstimator { 68 get => BoundsEstimatorParameter.Value; 69 set => BoundsEstimatorParameter.Value = value; 70 } 71 70 72 71 73 //Use false for maximization, because we try to minimize the NMSE … … 91 93 Parameters.Add(new FixedValueParameter<DoubleValue>(PenaltyMultiplierParameterName, 92 94 "Specify how hard constraints violations should be punished", new DoubleValue(1.0))); 93 Parameters.Add(new FixedValueParameter<BoolValue>(UseIntervalSplittingParameterName,94 " Define whether interval splitting is used or not.", new BoolValue(false)));95 Parameters.Add(new ValueParameter<IBoundsEstimator>(BoundsEstimatorParameterName, 96 "Select the Boundsestimator.", new IABoundsEstimator())); 95 97 } 96 98 … … 117 119 } 118 120 119 if (!Parameters.ContainsKey( UseIntervalSplittingParameterName)) {120 Parameters.Add(new FixedValueParameter<BoolValue>(UseIntervalSplittingParameterName,121 " Define whether interval splitting is used or not.", new BoolValue(false)));122 } 121 if (!Parameters.ContainsKey(BoundsEstimatorParameterName)) 122 Parameters.Add(new ValueParameter<IBoundsEstimator>(BoundsEstimatorParameterName, 123 "Select the Boundsestimator.", new IABoundsEstimator())); 124 123 125 } 124 126 … … 176 178 177 179 var quality = Calculate(interpreter, solution, estimationLimits.Lower, estimationLimits.Upper, problemData, rows, 178 UseSoftConstraints, 179 PenaltyMultiplier, UseIntervalSplitting); 180 UseSoftConstraints, PenaltyMultiplier); 180 181 QualityParameter.ActualValue = new DoubleValue(quality); 181 182 … … 188 189 double upperEstimationLimit, 189 190 IRegressionProblemData problemData, IEnumerable<int> rows, bool useSoftConstraints, 190 double penaltyMultiplier , bool useSplitting) {191 double penaltyMultiplier) { 191 192 var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows); 192 193 var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows); … … 198 199 out var errorState); 199 200 200 if (!SymbolicRegressionConstraintAnalyzer.ConstraintsSatisfied(constraints, variableRanges, solution, useSplitting,201 if (!SymbolicRegressionConstraintAnalyzer.ConstraintsSatisfied(constraints, variableRanges, solution, 201 202 out var error)) { 202 203 if (useSoftConstraints) { … … 229 230 var nmse = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, 230 231 EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, 231 problemData, rows, UseSoftConstraints, PenaltyMultiplier , UseIntervalSplitting);232 problemData, rows, UseSoftConstraints, PenaltyMultiplier); 232 233 233 234 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null; -
branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintScalingNmseEvaluator.cs
r17751 r17764 85 85 var variableRanges = problemData.VariableRanges.GetReadonlyDictionary(); 86 86 87 if (!SymbolicRegressionConstraintAnalyzer.ConstraintsSatisfied(constraints, variableRanges, solution, false,out double error))87 if (!SymbolicRegressionConstraintAnalyzer.ConstraintsSatisfied(constraints, variableRanges, solution, out double error)) 88 88 return 1.0; 89 89 -
branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionConstraintAnalyzer.cs
r17761 r17764 226 226 public static bool ConstraintsSatisfied(IEnumerable<IntervalConstraint> constraints, 227 227 IReadOnlyDictionary<string, Interval> variableRanges, 228 ISymbolicExpressionTree solution, bool useSplitting,228 ISymbolicExpressionTree solution, 229 229 out double error) { 230 var intervalInterpreter = new IntervalInterpreter() {UseIntervalSplitting = useSplitting};230 var intervalInterpreter = new IntervalInterpreter(); 231 231 error = 0.0; 232 232 var satisfied = true;
Note: See TracChangeset
for help on using the changeset viewer.