Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/06/19 14:37:02 (6 years ago)
Author:
chaider
Message:

#2971
Interval-Parser:

  • Changed Parser ==> after last group there can be now an infinite amount of whitepsaces
  • Save userinput as property
  • Save variable case-sensitive

NamedIntervals

  • Changed Storable attribute from IEnumerable to KeyValuePair, because old Persistance cant handle IEnumerable

Added SymbolicRegressionConstraintAnalyzer
SymbolicRegressionSingleObjectiveConstraintPearsonRSquaredEvaluator

  • Fixed checking if a given interval is in another interval
Location:
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/NamedIntervals.cs

    r16588 r16590  
    1313  [Item("NamedIntervals", "Represents variables with their interval ranges.")]
    1414  [StorableClass]
    15   public class NamedIntervals : Item {   
     15  public class NamedIntervals : Item {
    1616    Dictionary<string, Interval> variableIntervals = new Dictionary<string, Interval>();
    1717    public Dictionary<string, Interval> VariableIntervals => variableIntervals;
    1818
    1919    [Storable(Name = "StorableIntervalInformation")]
    20     private IEnumerable<Tuple<string, double, double>> StorableIntervalInformation {
     20    private KeyValuePair<string, double[]>[] StorableIntervalInformation {
    2121      get {
     22        var l = new List<KeyValuePair<string, double[]>>();
    2223        foreach (var varInt in variableIntervals)
    23           yield return Tuple.Create(varInt.Key, varInt.Value.LowerBound, varInt.Value.UpperBound);
     24
     25          l.Add(new KeyValuePair<string, double[]>(varInt.Key,
     26            new double[] { varInt.Value.LowerBound, varInt.Value.UpperBound }));
     27        return l.ToArray();
    2428      }
    2529
    2630      set {
    2731        foreach (var varInt in value)
    28           variableIntervals.Add(varInt.Item1,new Interval(varInt.Item2,varInt.Item3));
     32          variableIntervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1]));
    2933      }
    3034    }
    3135
    32     public NamedIntervals() : base(){}
     36    public NamedIntervals() : base() { }
    3337    protected NamedIntervals(bool deserializing) : base(deserializing) { }
    3438
     
    6266      return true;
    6367    }
    64    
     68
    6569  }
    6670}
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraint.cs

    r16587 r16590  
    77namespace HeuristicLab.Problems.DataAnalysis {
    88  public class IntervalConstraint {
     9    public string Derivaiton { get; set; }
    910    public string Definition { get; set; }
    1011    public Interval Interval { get; set; }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraintsParser.cs

    r16587 r16590  
    11using System;
    22using System.Collections.Generic;
     3using System.Globalization;
    34using System.IO;
    45using System.Linq;
     
    1415    public List<IntervalConstraint> Parse(string input) {
    1516      var options = RegexOptions.Multiline | RegexOptions.IgnoreCase;
    16       var matches = Regex.Matches(input, @"^(.*)\bin\b\s*([\[\]])(.*[^\s])(\s*\.\.\s*)([^\s].*)([\[\]])\r?$", options);
     17      var matches = Regex.Matches(input, @"^(.*)\bin\b\s*([\[\]])(.*[^\s])(\s*\.\.\s*)([^\s].*)([\[\]])\r?\s*$", options);
    1718
    1819      for (var i = 0; i < matches.Count; ++i) {
     
    2223          var definition = Regex.Replace(matches[i].Groups[1].Value, @"\s *", "");
    2324          if (Regex.IsMatch(definition, @"\/")) {
    24             var splitted = Regex.Split(definition.ToLower().Replace(" ", string.Empty), @"\/");
     25            var splitted = Regex.Split(definition.Replace(" ", string.Empty), @"\/");
    2526            var match = Regex.Match(splitted[0], @"([d∂])([0-9]|[²³])?(.*[^\s*])");
    2627            if (match.Success) {
     
    2829              intervalConstraint.Definition = match.Groups[3].Value;
    2930              intervalConstraint.IsDerivation = true;
    30               var formulation = Regex.Match(splitted[1], @"([d∂])(.*[^\s*][^²³])([²³])?");
     31              var formulation = Regex.Match(splitted[1], @"([d∂])(.*[^²³])([²³])?");
    3132              if (formulation.Success) {
    3233                intervalConstraint.Variable = formulation.Groups[2].Success ? formulation.Groups[2].Value : "";
     
    3839            intervalConstraint.Definition = Regex.Match(definition, @".*[^.\s]*").Value;
    3940            intervalConstraint.IsDerivation = false;
    40           }     
     41          }
     42          intervalConstraint.Derivaiton = matches[i].Groups[0].Value;
    4143          intervalConstraint.InclusiveLowerBound = (matches[i].Groups[2].Value == "[");
    4244          intervalConstraint.InclusiveUpperBound = (matches[i].Groups[6].Value == "]");
     
    6264          return double.NegativeInfinity;
    6365        default: {
    64           if (double.TryParse(input, out var value)) {
     66          if (double.TryParse(input, NumberStyles.Any, CultureInfo.InvariantCulture, out var value)) {
    6567            return value;
    6668          } else {
Note: See TracChangeset for help on using the changeset viewer.