Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/06/19 16:16:50 (5 years ago)
Author:
chaider
Message:

#2971

  • Added ContainsInterval method in Interval
  • Some renaming
  • Added ConstraintAnalyzer to SymbolicRegressionProblem
  • Added Counter for constraint violations in analyzer
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintPearsonRSquaredEvaluator.cs

    r16591 r16592  
    7070        if (!constraint.IsDerivation) {
    7171          var res = intervalInterpreter.GetSymbolicExressionTreeInterval(solution, variableRanges);
    72           if (!IntervalInBoundaries(constraint.Interval, res, constraint.InclusiveLowerBound,
     72          if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    7373            constraint.InclusiveUpperBound)) {
    7474            return 0;
     
    8080          }
    8181          var res = intervalInterpreter.GetSymbolicExressionTreeInterval(tree, variableRanges);
    82           if (!IntervalInBoundaries(constraint.Interval, res, constraint.InclusiveLowerBound,
     82          if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    8383            constraint.InclusiveUpperBound)) {
    8484            return 0;
     
    8686        }
    8787      }
     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
    8899
    89100
     
    102113    }
    103114
    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) {
    105117      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context;
    106118      EstimationLimitsParameter.ExecutionContext = context;
    107119      ApplyLinearScalingParameter.ExecutionContext = context;
    108120
    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);
    110124
    111125      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    115129      return r2;
    116130    }
    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     }
    151131  }
    152132}
Note: See TracChangeset for help on using the changeset viewer.