- Timestamp:
- 10/02/20 11:36:34 (4 years ago)
- Location:
- branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r17765 r17768 192 192 <Compile Include="Implementation\Interval\IntervalConstraint.cs" /> 193 193 <Compile Include="Implementation\Interval\IntervalConstraintsParser.cs" /> 194 <Compile Include="Implementation\Interval\Region.cs" />195 194 <Compile Include="Implementation\Regression\ConfidenceBoundRegressionSolution.cs" /> 196 195 <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" /> -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraint.cs
r17767 r17768 115 115 } 116 116 117 [Storable] private I Enumerable<Region>regions;118 public I Enumerable<Region>Regions {117 [Storable] private IntervalCollection regions; 118 public IntervalCollection Regions { 119 119 get => regions; 120 120 set { … … 146 146 Interval interval, double weight, bool enabled) 147 147 : this(expression, variable, target, numberOfDerivations, 148 interval, Enumerable.Empty<Region>(), weight, enabled) { }148 interval, new IntervalCollection(), weight, enabled) { } 149 149 150 150 public IntervalConstraint(string expression, string variable, string target, int numberOfDerivations, 151 Interval interval, I Enumerable<Region>regions, double weight, bool enabled) {151 Interval interval, IntervalCollection regions, double weight, bool enabled) { 152 152 this.regions = regions; 153 153 this.weight = weight; … … 166 166 private IntervalConstraint(IntervalConstraint original, Cloner cloner) 167 167 : base(original, cloner) { 168 Regions = new List<Region>(original.Regions?.Select(r => cloner.Clone(r)) ?? Enumerable.Empty<Region>());168 Regions = original.Regions; 169 169 Expression = original.Expression; 170 170 Variable = original.Variable; … … 207 207 "]"); 208 208 if(Regions != null) { 209 foreach (var region in Regions )210 expression += $", {region. VariableName}=({region.Interval.LowerBound} .. {region.Interval.UpperBound})";209 foreach (var region in Regions.GetReadonlyDictionary()) 210 expression += $", {region.Key}=({region.Value.LowerBound} .. {region.Value.UpperBound})"; 211 211 } 212 212 … … 224 224 GetDerivationString(numberOfDerivations)); 225 225 if (Regions != null) { 226 foreach (var region in Regions )227 expression += $", {region. VariableName}=({region.Interval.LowerBound} .. {region.Interval.UpperBound})";226 foreach (var region in Regions.GetReadonlyDictionary()) 227 expression += $", {region.Key}=({region.Value.LowerBound} .. {region.Value.UpperBound})"; 228 228 } 229 229 Expression = expression; -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraintsParser.cs
r17765 r17768 93 93 if (match.Groups[10].Success) 94 94 { 95 I List<Region> regions = new List<Region>();95 IntervalCollection regions = new IntervalCollection(); 96 96 // option variables found 97 97 for(int idx = 0; idx < match.Groups[10].Captures.Count; ++idx) 98 98 { 99 Regionregion = ParseRegion(99 KeyValuePair<string, Interval> region = ParseRegion( 100 100 match.Groups[11].Captures[idx].Value, 101 101 match.Groups[13].Captures[idx].Value, 102 102 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); 105 105 else 106 106 throw new ArgumentException("A constraint cannot contain multiple regions of the same variable."); … … 184 184 if(match.Groups[17].Success) 185 185 { 186 I List<Region> regions = new List<Region>();186 IntervalCollection regions = new IntervalCollection(); 187 187 // option variables found 188 188 for (int idx = 0; idx < match.Groups[17].Captures.Count; ++idx) 189 189 { 190 Regionregion = ParseRegion(190 KeyValuePair<string, Interval> region = ParseRegion( 191 191 match.Groups[18].Captures[idx].Value, 192 192 match.Groups[20].Captures[idx].Value, 193 193 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); 196 196 else 197 197 throw new ArgumentException("A constraint cannot contain multiple regions of the same variable."); … … 217 217 } 218 218 219 private static RegionParseRegion(string variable, string lb, string ub)219 private static KeyValuePair<string, Interval> ParseRegion(string variable, string lb, string ub) 220 220 { 221 221 var regionLb = ParseIntervalBounds(lb); 222 222 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)); 224 225 } 225 226
Note: See TracChangeset
for help on using the changeset viewer.