Changeset 16592 for branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators
- Timestamp:
- 02/06/19 16:16:50 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintPearsonRSquaredEvaluator.cs
r16591 r16592 70 70 if (!constraint.IsDerivation) { 71 71 var res = intervalInterpreter.GetSymbolicExressionTreeInterval(solution, variableRanges); 72 if (! IntervalInBoundaries(constraint.Interval,res, constraint.InclusiveLowerBound,72 if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound, 73 73 constraint.InclusiveUpperBound)) { 74 74 return 0; … … 80 80 } 81 81 var res = intervalInterpreter.GetSymbolicExressionTreeInterval(tree, variableRanges); 82 if (! IntervalInBoundaries(constraint.Interval,res, constraint.InclusiveLowerBound,82 if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound, 83 83 constraint.InclusiveUpperBound)) { 84 84 return 0; … … 86 86 } 87 87 } 88 // TODO 89 // m = new SymbolicRegressionModel(...) 90 // m.Scale(); 91 92 // var e = m.GetEstimatedValues (TRAINING) 93 // OnlinePearsonCalc.Calculate(e, TARGET_TRAIING) 94 95 // scaledTree = model.Tree; 96 97 // constraints mit scaledTree berechnen (auch die Ableitungen) 98 88 99 89 100 … … 102 113 } 103 114 104 public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows) { 115 public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, 116 IRegressionProblemData problemData, IEnumerable<int> rows) { 105 117 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context; 106 118 EstimationLimitsParameter.ExecutionContext = context; 107 119 ApplyLinearScalingParameter.ExecutionContext = context; 108 120 109 double r2 = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value); 121 double r2 = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, 122 EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, 123 ApplyLinearScalingParameter.ActualValue.Value); 110 124 111 125 SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null; … … 115 129 return r2; 116 130 } 117 118 private static bool IntervalInBoundaries(Interval i1, Interval i2, bool inclusiveLower, bool inclusiveUpper) {119 if (double.IsNegativeInfinity(i1.LowerBound) && double.IsPositiveInfinity(i1.UpperBound))120 return true;121 //Left-unbounded and right-bounded:122 if (double.IsNegativeInfinity(i1.LowerBound)) {123 if (inclusiveUpper)124 return i2.LowerBound <= i1.UpperBound && i2.UpperBound <= i1.UpperBound;125 return i2.LowerBound < i1.UpperBound && i2.UpperBound < i1.UpperBound;126 }127 128 //Left-bounded and right-unbounded:129 if (double.IsPositiveInfinity(i1.UpperBound)) {130 if (inclusiveLower)131 return i2.LowerBound >= i1.LowerBound && i2.UpperBound >= i1.LowerBound;132 return i2.LowerBound > i1.LowerBound && i2.UpperBound > i1.LowerBound;133 }134 135 //Proper and bounded:136 //Closed:137 if (inclusiveLower && inclusiveUpper) {138 return i1.LowerBound <= i2.LowerBound && i2.UpperBound <= i1.UpperBound;139 }140 //Open:141 if (!inclusiveLower && !inclusiveUpper) {142 return i1.LowerBound < i2.LowerBound && i2.UpperBound < i1.UpperBound;143 }144 //Left-closed, right-open:145 if (inclusiveLower) {146 return i1.LowerBound <= i2.LowerBound && i2.UpperBound < i1.UpperBound;147 }148 //Left-open, right-closed:149 return i1.LowerBound < i2.LowerBound && i2.UpperBound <= i1.UpperBound;150 }151 131 } 152 132 }
Note: See TracChangeset
for help on using the changeset viewer.