Changeset 17765
- Timestamp:
- 09/29/20 10:16:11 (4 years ago)
- Location:
- branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r17607 r17765 192 192 <Compile Include="Implementation\Interval\IntervalConstraint.cs" /> 193 193 <Compile Include="Implementation\Interval\IntervalConstraintsParser.cs" /> 194 <Compile Include="Implementation\Interval\Region.cs" /> 194 195 <Compile Include="Implementation\Regression\ConfidenceBoundRegressionSolution.cs" /> 195 196 <Compile Include="Implementation\Regression\ConstantRegressionModel.cs" /> … … 300 301 <Compile Include="Implementation\Classification\ThresholdCalculators\NormalDistributionCutPointsThresholdCalculator.cs" /> 301 302 <Compile Include="Implementation\Classification\ThresholdCalculators\ThresholdCalculator.cs" /> 303 <None Include=".editorconfig" /> 302 304 <None Include="HeuristicLab.snk" /> 303 305 <None Include="Plugin.cs.frame" /> -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraint.cs
r17728 r17765 115 115 116 116 [Storable] 117 private IDictionary<string, Interval> regions= new Dictionary<string, Interval>();118 public I Dictionary<string, Interval> Regions117 private /*IDictionary<string, Interval>*/ IEnumerable<Region> regions; //= new Dictionary<string, Interval>(); 118 public IEnumerable<Region> Regions 119 119 { 120 120 get => regions; … … 152 152 Interval interval, double weight, bool enabled) 153 153 : this(expression, variable, target, numberOfDerivations, 154 interval, new Dictionary<string, Interval>(), weight, enabled) { }154 interval, new List<Region>(), weight, enabled) { } 155 155 156 156 public IntervalConstraint(string expression, string variable, string target, int numberOfDerivations, 157 Interval interval, I Dictionary<string, Interval> regions, double weight, bool enabled)157 Interval interval, IEnumerable<Region> regions, double weight, bool enabled) 158 158 { 159 159 this.expression = expression; … … 213 213 Interval?.UpperBound, 214 214 "]"); 215 foreach(var kvpin Regions)216 expression += $", { kvp.Key}=({kvp.Value.LowerBound} .. {kvp.Value.UpperBound})";215 foreach(var region in Regions) 216 expression += $", {region.VariableName}=({region.Interval.LowerBound} .. {region.Interval.UpperBound})"; 217 217 Expression = expression; 218 218 return; … … 227 227 "]", 228 228 GetDerivationString(numberOfDerivations)); 229 foreach (var kvpin Regions)230 expression += $", { kvp.Key}=({kvp.Value.LowerBound} .. {kvp.Value.UpperBound})";229 foreach (var region in Regions) 230 expression += $", {region.VariableName}=({region.Interval.LowerBound} .. {region.Interval.UpperBound})"; 231 231 Expression = expression; 232 232 } -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraintsParser.cs
r17736 r17765 93 93 if (match.Groups[10].Success) 94 94 { 95 I Dictionary<string, Interval> pairs = new Dictionary<string, Interval>();95 IList<Region> regions = new List<Region>(); 96 96 // option variables found 97 97 for(int idx = 0; idx < match.Groups[10].Captures.Count; ++idx) 98 98 { 99 AddRegion(pairs,99 Region 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); 105 else 106 throw new ArgumentException("A constraint cannot contain multiple regions of the same variable."); 103 107 } 104 yield return new IntervalConstraint(expression, variable, parsedTarget, numberOfDerivation, interval, pairs, weight, isEnabled);108 yield return new IntervalConstraint(expression, variable, parsedTarget, numberOfDerivation, interval, regions, weight, isEnabled); 105 109 } 106 110 else … … 180 184 if(match.Groups[17].Success) 181 185 { 182 I Dictionary<string, Interval> pairs = new Dictionary<string, Interval>();186 IList<Region> regions = new List<Region>(); 183 187 // option variables found 184 188 for (int idx = 0; idx < match.Groups[17].Captures.Count; ++idx) 185 189 { 186 AddRegion(pairs,187 match.Groups[18].Captures[idx].Value, 188 match.Groups[20].Captures[idx].Value, 190 Region region = ParseRegion( 191 match.Groups[18].Captures[idx].Value, 192 match.Groups[20].Captures[idx].Value, 189 193 match.Groups[22].Captures[idx].Value); 194 if (!regions.Any(r => r.VariableName == region.VariableName)) 195 regions.Add(region); 196 else 197 throw new ArgumentException("A constraint cannot contain multiple regions of the same variable."); 190 198 } 191 yield return new IntervalConstraint(expression, variable, parsedTarget, numberOfDerivation, interval, pairs, weight, isEnabled);199 yield return new IntervalConstraint(expression, variable, parsedTarget, numberOfDerivation, interval, regions, weight, isEnabled); 192 200 } else 193 201 yield return new IntervalConstraint(expression, variable, parsedTarget, numberOfDerivation, interval, weight, isEnabled); … … 209 217 } 210 218 211 private static void AddRegion(IDictionary<string, Interval> dict,string variable, string lb, string ub)219 private static Region ParseRegion(string variable, string lb, string ub) 212 220 { 213 221 var regionLb = ParseIntervalBounds(lb); 214 222 var regionUb = ParseIntervalBounds(ub); 215 if (dict.ContainsKey(variable)) 216 throw new ArgumentException("A constraint cannot contain multiple regions of the same variable."); 217 dict.Add(variable, new Interval(regionLb, regionUb)); 223 return new Region(variable, new Interval(regionLb, regionUb)); 218 224 } 219 225
Note: See TracChangeset
for help on using the changeset viewer.