Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/19/19 14:35:08 (6 years ago)
Author:
chaider
Message:

#2791 Refactored Constraint Evaluator and Analyzer

File:
1 edited

Legend:

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

    r16830 r16851  
    9898    }
    9999
    100 
    101100    public NamedIntervals IntervalEvaluationCollection {
    102101      get { return (NamedIntervals)this[IntervalEvaluationResultName].Value; }
     
    128127      estimationLimitResults.Add(new Result(TestNaNEvaluationsResultName, "", new IntValue()));
    129128      Add(new Result(EstimationLimitsResultsResultName, "Results concerning the estimation limits of symbolic regression solution", estimationLimitResults));
    130       Add(new Result(IntervalEvaluationResultName, "Results concerning the derivation of symbolic regression solution", GetIntervalEvaluations()));
     129      Add(new Result(IntervalEvaluationResultName, "Results concerning the derivation of symbolic regression solution", new NamedIntervals()));
    131130      RecalculateResults();
    132131    }
     
    148147        estimationLimitResults.Add(new Result(TestNaNEvaluationsResultName, "", new IntValue()));
    149148        Add(new Result(EstimationLimitsResultsResultName, "Results concerning the estimation limits of symbolic regression solution", estimationLimitResults));
    150         Add(new Result(IntervalEvaluationResultName, "Results concerning the derivation of symbolic regression solution", GetIntervalEvaluations()));
     149        Add(new Result(IntervalEvaluationResultName, "Results concerning the derivation of symbolic regression solution", new NamedIntervals()));
    151150        CalculateResults();
    152151      }
     
    156155      base.RecalculateResults();
    157156      CalculateResults();
    158     }
    159 
    160     private NamedIntervals GetIntervalEvaluations() {
    161       var intervalEvaluation = new NamedIntervals();
    162       var interpreter = new IntervalInterpreter();
    163       var variableRanges = ProblemData.VariableRanges.VariableIntervals;
    164 
    165       if (variableRanges != null) {
    166         intervalEvaluation.VariableIntervals.Add($"Target {ProblemData.TargetVariable}", new Interval(variableRanges[ProblemData.TargetVariable].LowerBound, variableRanges[ProblemData.TargetVariable].UpperBound));
    167         intervalEvaluation.VariableIntervals.Add("Modell Interval", interpreter.GetSymbolicExpressionTreeInterval(Model.SymbolicExpressionTree, variableRanges));
    168      
    169         foreach (var derivate in variableRanges) {
    170           if (derivate.Key != ProblemData.TargetVariable) {
    171             var derived = DerivativeCalculator.Derive(Model.SymbolicExpressionTree, derivate.Key);
    172             var derivedResultInterval = interpreter.GetSymbolicExpressionTreeInterval(derived, variableRanges);
    173 
    174             intervalEvaluation.VariableIntervals.Add(" \u2202f/\u2202" + derivate.Key,
    175               new Interval(derivedResultInterval.LowerBound, derivedResultInterval.UpperBound));
    176           }
    177         }
    178       }
    179       return intervalEvaluation;
    180157    }
    181158
     
    194171      TestNaNEvaluations = Model.Interpreter.GetSymbolicExpressionTreeValues(Model.SymbolicExpressionTree, ProblemData.Dataset, ProblemData.TestIndices).Count(double.IsNaN);
    195172
    196       IntervalEvaluationCollection = GetIntervalEvaluations();
     173      IntervalEvaluationCollection = CalculateModelIntervals(this);
     174    }
     175
     176    private static NamedIntervals CalculateModelIntervals(ISymbolicRegressionSolution solution) {
     177      var intervalEvaluation = new NamedIntervals();
     178      var interpreter = new IntervalInterpreter();
     179      var problemData = solution.ProblemData;
     180      var model = solution.Model;
     181      var variableRanges = problemData.VariableRanges.VariableIntervals;
     182
     183      intervalEvaluation.VariableIntervals.Add($"Target {problemData.TargetVariable}", new Interval(variableRanges[problemData.TargetVariable].LowerBound, variableRanges[problemData.TargetVariable].UpperBound));
     184      intervalEvaluation.VariableIntervals.Add("Model Interval", interpreter.GetSymbolicExpressionTreeInterval(model.SymbolicExpressionTree, variableRanges));
     185
     186      foreach (var inputVariable in model.VariablesUsedForPrediction.OrderBy(v => v, new NaturalStringComparer())) {
     187        var derivedModel = DerivativeCalculator.Derive(model.SymbolicExpressionTree, inputVariable);
     188        var derivedResultInterval = interpreter.GetSymbolicExpressionTreeInterval(derivedModel, variableRanges);
     189
     190        intervalEvaluation.VariableIntervals.Add(" \u2202f/\u2202" + inputVariable,
     191          new Interval(derivedResultInterval.LowerBound, derivedResultInterval.UpperBound));
     192      }
     193
     194      return intervalEvaluation;
    197195    }
    198196  }
Note: See TracChangeset for help on using the changeset viewer.