- Timestamp:
- 01/20/21 09:26:09 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraintsParser.cs
r17818 r17822 24 24 using System; 25 25 using System.Collections.Generic; 26 using System.Globalization;27 26 using System.Linq; 28 27 using System.Text.RegularExpressions; 28 using HeuristicLab.Data; 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis { … … 89 89 90 90 if (match.Groups[18].Success && !string.IsNullOrWhiteSpace(match.Groups[18].Value)) 91 weight = Parse Weight(match.Groups[18].Value);91 weight = ParseAndValidateDouble(match.Groups[18].Value); 92 92 93 93 if (match.Groups[10].Success) … … 180 180 181 181 if(match.Groups[25].Success && !string.IsNullOrWhiteSpace(match.Groups[25].Value)) 182 weight = Parse Weight(match.Groups[25].Value);182 weight = ParseAndValidateDouble(match.Groups[25].Value); 183 183 184 184 if(match.Groups[17].Success) … … 222 222 var regionUb = ParseIntervalBounds(ub); 223 223 return new KeyValuePair<string, Interval>(variable, new Interval(regionLb, regionUb)); 224 //return new Region(variable, new Interval(regionLb, regionUb));225 224 } 226 225 … … 234 233 return double.NegativeInfinity; 235 234 default: { 236 if (double.TryParse(input.Replace(',', '.'), NumberStyles.Any, CultureInfo.InvariantCulture, out var value))237 return value;238 throw new ArgumentException("The given boundary is not a double value!");239 240 } 241 }242 243 private static double ParseWeight(string input)244 {245 if (double.TryParse(input, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))246 return value; 247 throw new ArgumentException("The given weight is not a double value!");235 return ParseAndValidateDouble(input); 236 } 237 } 238 } 239 240 private static double ParseAndValidateDouble(string input) { 241 var valid = double.TryParse(input, out var value); 242 if (!valid) { 243 throw new ArgumentException("Invalid Value (Valid Value Format: \"" + FormatPatterns.GetDoubleFormatPattern() + "\")"); 244 } 245 246 return value; 248 247 } 249 248
Note: See TracChangeset
for help on using the changeset viewer.