Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/24/20 16:12:03 (5 years ago)
Author:
chaider
Message:

#3073

  • Added splitting parameter in IntervalInterpreter
  • Added methods for spitting in Interval class
  • Fixed some typos and other minor changes
Location:
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs

    r17583 r17631  
    3333    [Storable]
    3434    public double UpperBound { get; private set; }
     35
     36    public double Width => UpperBound - LowerBound;
    3537
    3638    [StorableConstructor]
     
    7880    }
    7981
     82    public Tuple<Interval, Interval> Split() {
     83      var midpoint = Width / 2;
     84      var left     = new Interval(LowerBound, LowerBound + midpoint - double.Epsilon);
     85      var right    = new Interval(LowerBound + midpoint, UpperBound);
     86      return Tuple.Create(left, right);
     87    }
     88
     89    //Interval Intersection
     90    public static Interval operator &(Interval lhs, Interval rhs) {
     91      return new Interval(Math.Max(lhs.LowerBound, rhs.LowerBound), Math.Min(lhs.UpperBound, rhs.UpperBound));
     92    }
     93
     94    //Interval Union
     95    public static Interval operator |(Interval lhs, Interval rhs) {
     96      return new Interval(Math.Min(lhs.LowerBound, rhs.LowerBound), Math.Max(lhs.UpperBound, rhs.UpperBound));
     97    }
     98
    8099    public override string ToString() {
    81100      return "Interval: [" + LowerBound + ", " + UpperBound + "]";
  • branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalCollection.cs

    r17564 r17631  
    9494    }
    9595
     96    public IDictionary<string, Interval> GetDictionary() {
     97      return intervals.ToDictionary(pair => pair.Key, pair => pair.Value);
     98    }
     99
    96100    public IEnumerable<Tuple<string, Interval>> GetVariableIntervals() {
    97101      foreach (var variableInterval in intervals)
Note: See TracChangeset for help on using the changeset viewer.