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/3.4/Implementation/Interval.cs

    r16548 r16592  
    4343    public bool Contains(double value) {
    4444      return LowerBound <= value && value <= UpperBound;
     45    }
     46
     47    public bool Contains(Interval other, bool lowerBoundInclusive = true, bool upperBoundInclusive = false) {
     48      if (double.IsNegativeInfinity(this.LowerBound) && double.IsPositiveInfinity(this.UpperBound))
     49        return true;
     50      //Left-unbounded and right-bounded:
     51      if (double.IsNegativeInfinity(this.LowerBound)) {
     52        if (upperBoundInclusive)
     53          return other.LowerBound <= this.UpperBound && other.UpperBound <= this.UpperBound;
     54        return other.LowerBound < this.UpperBound && other.UpperBound < this.UpperBound;
     55      }
     56
     57      //Left-bounded and right-unbounded:
     58      if (double.IsPositiveInfinity(this.UpperBound)) {
     59        if (lowerBoundInclusive)
     60          return other.LowerBound >= this.LowerBound && other.UpperBound >= this.LowerBound;
     61        return other.LowerBound > this.LowerBound && other.UpperBound > this.LowerBound;
     62      }
     63
     64      //Proper and bounded:
     65      //Closed:
     66      if (lowerBoundInclusive && upperBoundInclusive) {
     67        return this.LowerBound <= other.LowerBound && other.UpperBound <= this.UpperBound;
     68      }
     69
     70      //Open:
     71      if (!lowerBoundInclusive && !upperBoundInclusive) {
     72        return this.LowerBound < other.LowerBound && other.UpperBound < this.UpperBound;
     73      }
     74
     75      //Left-closed, right-open:
     76      if (lowerBoundInclusive) {
     77        return this.LowerBound <= other.LowerBound && other.UpperBound < this.UpperBound;
     78      }
     79
     80      //Left-open, right-closed:
     81      return this.LowerBound < other.LowerBound && other.UpperBound <= this.UpperBound;
    4582    }
    4683
Note: See TracChangeset for help on using the changeset viewer.