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/SingleObjective/Evaluators
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • 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)) {
Note: See TracChangeset for help on using the changeset viewer.