Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/08/22 13:06:49 (3 years ago)
Author:
dpiringe
Message:

#3138

  • reimplemented extended constraints with an interface and an implementation, because of project reference troubles
  • moved the extended shape constraints into IShapeConstrainedRegressionProblemData
  • added thresholds for shape constraints -> the error is linear between 0 and 1, error caps at 1 when error >= (intervalbound + thresholdbound)
    • adapted ShapeConstraint and ShapeConstraintsParser to identify and store thresholds
  • adapted IntervalUtil to work with thresholds
  • adapted NMSESingleObjectiveConstraintsEvaluator and ShapeConstraintsAnalyzer to work with extended constraints
  • added a new chart in ShapeConstraintsAnalyzer to show the average constraint violation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ShapeConstraint.cs

    r17960 r18213  
    106106    }
    107107
     108    [Storable]
     109    private Interval threshold = new Interval(0, 0);
     110    public Interval Threshold {
     111      get => threshold;
     112      set {
     113        if (threshold == value)
     114          return;
     115        threshold = value;
     116        OnToStringChanged();
     117        OnChanged();
     118      }
     119    }
     120
    108121    [StorableConstructor]
    109122    private ShapeConstraint(StorableConstructorFlag _) : base(_) { }
     
    115128
    116129    // without derivation
    117     public ShapeConstraint(Interval interval, double weight)
     130    public ShapeConstraint(Interval interval, double weight, Interval threshold)
    118131      : this(string.Empty, 0,
    119          interval, new IntervalCollection(), weight) { }
    120 
    121     public ShapeConstraint(Interval interval, IntervalCollection regions, double weight)
     132         interval, new IntervalCollection(), weight, threshold) { }
     133
     134    public ShapeConstraint(Interval interval, IntervalCollection regions, double weight, Interval threshold)
    122135      : this(string.Empty, 0,
    123          interval, regions, weight) { }
     136         interval, regions, weight, threshold) { }
    124137
    125138    public ShapeConstraint(string variable, int numberOfDerivations,
    126                               Interval interval, double weight)
     139                              Interval interval, double weight, Interval threshold)
    127140      : this(variable, numberOfDerivations,
    128              interval, new IntervalCollection(), weight) { }
     141             interval, new IntervalCollection(), weight, threshold) { }
    129142
    130143    public ShapeConstraint(string variable, int numberOfDerivations,
    131                               Interval interval, IntervalCollection regions, double weight) {
     144                              Interval interval, IntervalCollection regions, double weight, Interval threshold) {
    132145      Variable = variable;
    133146      NumberOfDerivations = numberOfDerivations;
     
    135148      Regions = regions;
    136149      Weight = weight;
     150      Threshold = threshold;
    137151    }
    138152
     
    148162      Regions = cloner.Clone(original.Regions);
    149163      Weight = original.weight;
     164      Threshold = original.threshold;
    150165    }
    151166
     
    175190      if (!IsDerivative) {
    176191        expression = string.Format($"f in [{write(Interval.LowerBound)} .. {write(Interval.UpperBound)}]");
    177         if (Regions != null) {
    178           foreach (var region in Regions.GetReadonlyDictionary())
    179             expression += $", {region.Key} in [{write(region.Value.LowerBound)} .. {write(region.Value.UpperBound)}]";
     192      } else {
     193        var derivationString = string.Empty;
     194        switch (numberOfDerivations) {
     195          case 1:
     196            derivationString = ""; break;
     197          case 2:
     198            derivationString = "²"; break;
     199          case 3:
     200            derivationString = "³"; break;
    180201        }
    181         if (Weight != 1.0) {
    182           expression += $" weight: {weight}";
    183         }
    184 
    185         return expression;
    186       }
    187 
    188       var derivationString = string.Empty;
    189       switch (numberOfDerivations) {
    190         case 1:
    191           derivationString = ""; break;
    192         case 2:
    193           derivationString = "²"; break;
    194         case 3:
    195           derivationString = "³"; break;
    196       }
    197       expression = string.Format($"∂{derivationString}f/∂{Variable}{derivationString} in [{write(Interval.LowerBound)} .. {write(Interval.UpperBound)}]");
    198       if (Regions != null) {
     202        expression = string.Format($"∂{derivationString}f/∂{Variable}{derivationString} in [{write(Interval.LowerBound)} .. {write(Interval.UpperBound)}]");
     203      }
     204
     205      if (Regions != null)
    199206        foreach (var region in Regions.GetReadonlyDictionary())
    200207          expression += $", {region.Key} in [{write(region.Value.LowerBound)} .. {write(region.Value.UpperBound)}]";
    201       }
    202       if (Weight != 1.0) {
     208
     209      if (Weight != 1.0)
    203210        expression += $" weight: {weight}";
    204       }
     211
     212      if (Threshold.LowerBound != 0 || Threshold.UpperBound != 0)
     213        expression += $" threshold in [{write(Threshold.LowerBound)} .. {write(Threshold.UpperBound)}]";
     214
    205215      return expression;
    206216    }
Note: See TracChangeset for help on using the changeset viewer.