Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/16/21 15:26:50 (3 years ago)
Author:
gkronber
Message:

#3073 bugfixing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/ShapeConstraintsParser.cs

    r17902 r17906  
    6161      } else {
    6262        throw new
    63           ArgumentException("Error at your constraints definition constraints have to start with (f | d | ∂ | #)",
     63          ArgumentException($"Error at in definition {expr}. Constraints have to start with (f | d | ∂ | #)",
    6464                            nameof(expr));
    6565      }
     
    6868    // [124 .. 145]
    6969    private const string intervalRegex = @"\s*[\[]" +
    70                                          @"\s*(?<lowerBound>[^\s\.;]*)" +
     70                                         @"\s*(?<lowerBound>[^\s;]*)" +
    7171                                         @"\s*(\.{2}|\s+|;)" +
    7272                                         @"\s*(?<upperBound>[^\s\]]*)" +
     
    7676    private const string weightRegex = @"\s*(weight:\s*(?<weight>\S*))?";
    7777    public static ShapeConstraint ParseFunctionRangeConstraint(string expr) {
    78       if (!expr.StartsWith("f")) throw new ArgumentException("Invalid function range constraint (e.g. f in [1..2])", nameof(expr));
     78      if (!expr.StartsWith("f")) throw new ArgumentException($"Invalid function range constraint {expr} (e.g. f in [1..2])", nameof(expr));
    7979      var start = "f".Length;
    8080      var end = expr.Length;
     
    9595                    intervalRegex +
    9696                    @"(" +
    97                       @"\s*,\s*"+ variableRegex +
     97                      @"\s*,\s*" + variableRegex +
    9898                      @"\s *\bin\b" +
    9999                      intervalRegex +
    100100                    @")*" +
    101101                    weightRegex
    102                     ); 
     102                    );
    103103
    104104
     
    125125              regions.AddInterval(region.Key, region.Value);
    126126            else
    127               throw new ArgumentException("A constraint cannot contain multiple regions of the same variable.");
     127              throw new ArgumentException($"The constraint {expr} has multiple regions of the same variable.");
    128128          }
    129129          return new ShapeConstraint(interval, regions, weight);
     
    131131          return new ShapeConstraint(interval, weight);
    132132      } else
    133         throw new ArgumentException("The inserted target constraint is not valid.", nameof(expr));
     133        throw new ArgumentException($"The inserted target constraint {expr} is not valid.", nameof(expr));
    134134    }
    135135    public static ShapeConstraint ParseDerivationConstraint(string expr) {
     
    149149                                  @")*" +
    150150                                weightRegex
    151                                 ); 
     151                                );
    152152
    153153      if (match.Success) {
     
    161161        if (enumeratorNumDeriv != "" || denominatorNumDeriv != "") {
    162162          if (enumeratorNumDeriv == "" || denominatorNumDeriv == "")
    163             throw new ArgumentException("Number of derivation has to be written on both sides.", nameof(expr));
     163            throw new ArgumentException($"Number of derivation has to be written on both sides in {expr}.", nameof(expr));
    164164          if (enumeratorNumDeriv != denominatorNumDeriv)
    165             throw new ArgumentException("Derivation number is not equal on both sides.", nameof(expr));
     165            throw new ArgumentException($"Derivation number is not equal on both sides in {expr}.", nameof(expr));
    166166        }
    167167
     
    187187              regions.AddInterval(region.Key, region.Value);
    188188            else
    189               throw new ArgumentException("A constraint cannot contain multiple regions of the same variable.");
     189              throw new ArgumentException($"The constraint {expr} has multiple regions of the same variable.");
    190190          }
    191191          return new ShapeConstraint(variable, numberOfDerivation, interval, regions, weight);
     
    193193          return new ShapeConstraint(variable, numberOfDerivation, interval, weight);
    194194      } else
    195         throw new ArgumentException("The inserted derivation constraint is not valid.", nameof(expr));
     195        throw new ArgumentException($"The inserted derivation constraint {expr} is not valid.", nameof(expr));
    196196    }
    197197
     
    220220      var valid = double.TryParse(input, out var value);
    221221      if (!valid) {
    222         throw new ArgumentException("Invalid value (valid value format: \"" + FormatPatterns.GetDoubleFormatPattern() + "\")");
     222        throw new ArgumentException($"Invalid value {input} (valid value format: \"" + "+inf. | inf. | -inf. | " + FormatPatterns.GetDoubleFormatPattern() + "\")");
    223223      }
    224224
Note: See TracChangeset for help on using the changeset viewer.