Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/26/19 11:37:29 (6 years ago)
Author:
bburlacu
Message:

#2971: Make IntervalConstraintsParser class static, adapt code. Add SymbolicRegressionConstraintSatisfactionEvaluator.

Location:
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj

    r16685 r16713  
    204204    <Compile Include="Plugin.cs" />
    205205    <Compile Include="SingleObjective\ConstantOptimizationAnalyzer.cs" />
     206    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionConstraintSatisfactionEvaluator.cs" />
    206207    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" />
    207208    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveConstraintConstOptEvaluator.cs" />
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintConstOptEvaluator.cs

    r16645 r16713  
    2222using System;
    2323using System.Collections.Generic;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     
    5959      OnlineCalculatorError errorState = OnlineCalculatorError.None;
    6060
    61       IntervalConstraintsParser parser = new IntervalConstraintsParser();
    62       var constraints = parser.Parse(((RegressionProblemData)problemData).IntervalConstraintsParameter.Value.Value);
     61      var constraints = IntervalConstraintsParser.Parse(((RegressionProblemData)problemData).IntervalConstraintsParameter.Value.Value);
    6362      var intervalInterpreter = new IntervalInterpreter();
    6463      var variableRanges = ((RegressionProblemData)problemData).VariableRangesParameter.Value.VariableIntervals;
     
    9089    }
    9190
    92     private static bool HasConstraintVioluations(List<IntervalConstraint> constraints, IntervalInterpreter intervalInterpreter,
     91    private static bool HasConstraintVioluations(IEnumerable<IntervalConstraint> constraints, IntervalInterpreter intervalInterpreter,
    9392      Dictionary<string, Interval> variableRanges, ISymbolicExpressionTree solution) {
    9493      foreach (var constraint in constraints) {
     
    9695          throw new ArgumentException($"The given variable {constraint.Variable} in the constraint does not exists in the model.", nameof(IntervalConstraintsParser));
    9796        if (!constraint.IsDerivation) {
    98           var res = intervalInterpreter.GetSymbolicExressionTreeInterval(solution, variableRanges);
     97          var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(solution, variableRanges);
    9998          if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    10099            constraint.InclusiveUpperBound)) {
     
    106105            tree = DerivativeCalculator.Derive(tree, constraint.Variable);
    107106          }
    108           var res = intervalInterpreter.GetSymbolicExressionTreeInterval(tree, variableRanges);
     107          var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(tree, variableRanges);
    109108          if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    110109            constraint.InclusiveUpperBound)) {
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintPearsonRSquaredEvaluator.cs

    r16644 r16713  
    2222using System;
    2323using System.Collections.Generic;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     
    5959      OnlineCalculatorError errorState = OnlineCalculatorError.None;
    6060
    61       IntervalConstraintsParser parser = new IntervalConstraintsParser();
    62       var constraints = parser.Parse(((RegressionProblemData) problemData).IntervalConstraintsParameter.Value.Value);
     61      var constraints = IntervalConstraintsParser.Parse(((RegressionProblemData)problemData).IntervalConstraintsParameter.Value.Value);
    6362      var intervalInterpreter = new IntervalInterpreter();
    64       var variableRanges = ((RegressionProblemData) problemData).VariableRangesParameter.Value.VariableIntervals;
     63      var variableRanges = ((RegressionProblemData)problemData).VariableRangesParameter.Value.VariableIntervals;
    6564
    6665
     
    9291      // var e = m.GetEstimatedValues (TRAINING)
    9392      // OnlinePearsonCalc.Calculate(e, TARGET_TRAIING)
    94      
     93
    9594      // scaledTree = model.Tree;
    9695
     
    120119      }
    121120      if (errorState != OnlineCalculatorError.None) return double.NaN;
    122       return r*r;
     121      return r * r;
    123122    }
    124123
     
    141140    }
    142141
    143     private static bool CheckConstraintsViolations(List<IntervalConstraint> constraints, IntervalInterpreter intervalInterpreter,
     142    private static bool CheckConstraintsViolations(IEnumerable<IntervalConstraint> constraints, IntervalInterpreter intervalInterpreter,
    144143      Dictionary<string, Interval> variableRanges, ISymbolicExpressionTree solution, out double r) {
    145144      foreach (var constraint in constraints) {
     
    147146          throw new ArgumentException($"The given variable {constraint.Variable} in the constraint does not exists in the model.", nameof(IntervalConstraintsParser));
    148147        if (!constraint.IsDerivation) {
    149           var res = intervalInterpreter.GetSymbolicExressionTreeInterval(solution, variableRanges);
     148          var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(solution, variableRanges);
    150149          if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    151150            constraint.InclusiveUpperBound)) {
     
    158157            tree = DerivativeCalculator.Derive(tree, constraint.Variable);
    159158          }
    160           var res = intervalInterpreter.GetSymbolicExressionTreeInterval(tree, variableRanges);
     159          var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(tree, variableRanges);
    161160          if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    162161            constraint.InclusiveUpperBound)) {
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionConstraintAnalyzer.cs

    r16644 r16713  
    2424using System;
    2525using System.Collections.Generic;
     26using HEAL.Attic;
    2627using HeuristicLab.Analysis;
    2728using HeuristicLab.Common;
     
    3031using HeuristicLab.Optimization;
    3132using HeuristicLab.Parameters;
    32 using HEAL.Attic;
    3333
    3434namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     
    8686    public override IOperation Apply() {
    8787      var results = ResultCollectionParameter.ActualValue;
    88       IntervalConstraintsParser parser = new IntervalConstraintsParser();
    8988      var intervalInterpreter = new IntervalInterpreter();
    9089      if (!results.ContainsKey(ConstraintViolationsResultName)) {
     
    9998      var constraintViolations = new Dictionary<string, int>();
    10099
    101       var constraints =
    102         parser.Parse(problemData.IntervalConstraints.Value);
     100      var constraints = IntervalConstraintsParser.Parse(problemData.IntervalConstraints.Value);
    103101      var variableRanges = problemData.VariableRanges.VariableIntervals;
    104102
     
    122120              nameof(IntervalConstraintsParser));
    123121          if (!constraint.IsDerivation) {
    124             var res = intervalInterpreter.GetSymbolicExressionTreeInterval(tree,
     122            var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(tree,
    125123              variableRanges);
    126124            if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
     
    134132            }
    135133
    136             var res = intervalInterpreter.GetSymbolicExressionTreeInterval(dTree,
     134            var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(dTree,
    137135              variableRanges);
    138136            if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs

    r16644 r16713  
    2121
    2222using System.Linq;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2627using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2728using HeuristicLab.Optimization;
    28 using HEAL.Attic;
    2929using HeuristicLab.Problems.DataAnalysis.Implementation;
    3030
     
    168168      if (variableRanges != null) {
    169169        intervalEvaluation.Add($"Target {ProblemData.TargetVariable}", new Interval(variableRanges[ProblemData.TargetVariable].LowerBound, variableRanges[ProblemData.TargetVariable].UpperBound));
    170         intervalEvaluation.Add("Modell Interval", interpreter.GetSymbolicExressionTreeInterval(Model.SymbolicExpressionTree, variableRanges));
     170        intervalEvaluation.Add("Modell Interval", interpreter.GetSymbolicExpressionTreeInterval(Model.SymbolicExpressionTree, variableRanges));
    171171
    172172        foreach (var derivate in variableRanges) {
    173173          if (derivate.Key != ProblemData.TargetVariable) {
    174174            var derived = DerivativeCalculator.Derive(Model.SymbolicExpressionTree, derivate.Key);
    175             var derivedResultInterval = interpreter.GetSymbolicExressionTreeInterval(derived, variableRanges);
     175            var derivedResultInterval = interpreter.GetSymbolicExpressionTreeInterval(derived, variableRanges);
    176176            intervalEvaluation.Add(" ?f/?" + derivate.Key,
    177177              new Interval(derivedResultInterval.LowerBound, derivedResultInterval.UpperBound));
Note: See TracChangeset for help on using the changeset viewer.