Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/22/21 18:28:36 (3 years ago)
Author:
dpiringe
Message:

#3119

  • added additional parameters to enable different evaluation options
  • added additive restrictions
  • added additional implementations for dynamic restrictions:
    • dynamic intervalls
    • exponatial smoothing
    • rising multiplier
  • adapted IntervalUtil to get model bounds and refactored some sections
  • adapted ShapeConstraintsParser for added features
  • added a ResultCollection in SymbolicRegressionSolution for shape constraint violations
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3119_AdditionalShapeConstraintFeatures/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/IntervalUtil.cs

    r17906 r17995  
    2828namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2929  public static class IntervalUtil {
     30    public static IEnumerable<Interval> GetModelBounds(
     31      IEnumerable<ShapeConstraint> constraints, IBoundsEstimator estimator, IntervalCollection intervalCollection,
     32      ISymbolicExpressionTree solution) {
     33      return constraints.Select(constraint => GetModelBound(constraint, estimator, intervalCollection, solution)).ToList();
     34    }
     35
     36    public static Interval GetModelBound(
     37      ShapeConstraint constraint, IBoundsEstimator estimator, IntervalCollection variableRanges,
     38      ISymbolicExpressionTree tree) {
     39      var regionRanges = GetRegionRanges(constraint, variableRanges);
     40      tree = DeriveTree(tree, constraint, estimator);
     41      return estimator.GetModelBound(tree, regionRanges);
     42    }
     43
    3044    public static IEnumerable<double> GetConstraintViolations(
    3145      IEnumerable<ShapeConstraint> constraints, IBoundsEstimator estimator, IntervalCollection intervalCollection,
     
    3751      ShapeConstraint constraint, IBoundsEstimator estimator, IntervalCollection variableRanges,
    3852      ISymbolicExpressionTree tree) {
     53
     54      var regionRanges = GetRegionRanges(constraint, variableRanges);
     55      tree = DeriveTree(tree, constraint, estimator);
     56      return estimator.GetConstraintViolation(tree, regionRanges, constraint);
     57      /*
     58      if (!constraint.IsDerivative) {
     59        return estimator.GetConstraintViolation(tree, regionRanges, constraint);
     60      } else {
     61        for (var i = 0; i < constraint.NumberOfDerivations; ++i) {
     62          if (!estimator.IsCompatible(tree) || !DerivativeCalculator.IsCompatible(tree)) {
     63            throw new ArgumentException("The tree contains an unsupported symbol.");
     64          }
     65
     66          tree = DerivativeCalculator.Derive(tree, constraint.Variable);
     67        }
     68
     69        return estimator.GetConstraintViolation(tree, regionRanges, constraint);
     70      }
     71      */
     72    }
     73
     74    private static ISymbolicExpressionTree DeriveTree(ISymbolicExpressionTree tree, ShapeConstraint constraint, IBoundsEstimator estimator) {
     75      if (constraint.IsDerivative) {
     76        for (var i = 0; i < constraint.NumberOfDerivations; ++i) {
     77          if (!estimator.IsCompatible(tree) || !DerivativeCalculator.IsCompatible(tree))
     78            throw new ArgumentException("The tree contains an unsupported symbol.");
     79          tree = DerivativeCalculator.Derive(tree, constraint.Variable);
     80        }
     81      }
     82      return tree;
     83    }
     84
     85    private static IntervalCollection GetRegionRanges(ShapeConstraint constraint, IntervalCollection variableRanges) {
    3986      var varRanges = variableRanges.GetReadonlyDictionary();
    4087
     
    55102      }
    56103
    57       if (!constraint.IsDerivative) {
    58         return estimator.GetConstraintViolation(tree, regionRanges, constraint);
    59       } else {
    60         for (var i = 0; i < constraint.NumberOfDerivations; ++i) {
    61           if (!estimator.IsCompatible(tree) || !DerivativeCalculator.IsCompatible(tree)) {
    62             throw new ArgumentException("The tree contains an unsupported symbol.");
    63           }
    64 
    65           tree = DerivativeCalculator.Derive(tree, constraint.Variable);
    66         }
    67 
    68         return estimator.GetConstraintViolation(tree, regionRanges, constraint);
    69       }
     104      return regionRanges;
    70105    }
    71106  }
Note: See TracChangeset for help on using the changeset viewer.