Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/02/20 11:36:34 (4 years ago)
Author:
chaider
Message:

#3073

  • Removed Region class and used IntervallCollection instead
  • Changed Parser to work with IntervalColletions
  • Moved CheckConstraint methods from Analyzer to IntervalUtil class
  • Added CheckConstraint method to interface to check if an interval is in a given constraint
  • Added possibility to stop splitting as soon as a constraint is fulfiled
File:
1 edited

Legend:

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

    r17765 r17768  
    9393            if (match.Groups[10].Success)
    9494            {
    95               IList<Region> regions = new List<Region>();
     95              IntervalCollection regions = new IntervalCollection();
    9696              // option variables found
    9797              for(int idx = 0; idx < match.Groups[10].Captures.Count; ++idx)
    9898              {
    99                 Region region = ParseRegion(
     99                KeyValuePair<string, Interval> region = ParseRegion(
    100100                  match.Groups[11].Captures[idx].Value,
    101101                  match.Groups[13].Captures[idx].Value,
    102102                  match.Groups[15].Captures[idx].Value);
    103                 if(!regions.Any(r => r.VariableName == region.VariableName))
    104                   regions.Add(region);
     103                if (regions.GetReadonlyDictionary().All(r => r.Key != region.Key))
     104                  regions.AddInterval(region.Key, region.Value);
    105105                else
    106106                  throw new ArgumentException("A constraint cannot contain multiple regions of the same variable.");
     
    184184            if(match.Groups[17].Success)
    185185            {
    186               IList<Region> regions = new List<Region>();
     186              IntervalCollection regions = new IntervalCollection();
    187187              // option variables found
    188188              for (int idx = 0; idx < match.Groups[17].Captures.Count; ++idx)
    189189              {
    190                 Region region = ParseRegion(
     190                KeyValuePair<string, Interval> region = ParseRegion(
    191191                  match.Groups[18].Captures[idx].Value,
    192192                  match.Groups[20].Captures[idx].Value,
    193193                  match.Groups[22].Captures[idx].Value);
    194                 if (!regions.Any(r => r.VariableName == region.VariableName))
    195                   regions.Add(region);
     194                if (regions.GetReadonlyDictionary().All(r => r.Key != region.Key))
     195                  regions.AddInterval(region.Key, region.Value);
    196196                else
    197197                  throw new ArgumentException("A constraint cannot contain multiple regions of the same variable.");
     
    217217    }
    218218
    219     private static Region ParseRegion(string variable, string lb, string ub)
     219    private static KeyValuePair<string, Interval> ParseRegion(string variable, string lb, string ub)
    220220    {
    221221      var regionLb = ParseIntervalBounds(lb);
    222222      var regionUb = ParseIntervalBounds(ub);
    223       return new Region(variable, new Interval(regionLb, regionUb));
     223      return new KeyValuePair<string, Interval>(variable, new Interval(regionLb, regionUb));
     224      //return new Region(variable, new Interval(regionLb, regionUb));
    224225    }
    225226
Note: See TracChangeset for help on using the changeset viewer.