Changeset 17946 for branches/3119_AdditionalShapeConstraintFeatures/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/ShapeConstraint.cs
- Timestamp:
- 04/16/21 16:04:02 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3119_AdditionalShapeConstraintFeatures/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/ShapeConstraint.cs
r17937 r17946 106 106 } 107 107 108 [Storable] 109 private Interval threshold; 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 108 121 [StorableConstructor] 109 122 private ShapeConstraint(StorableConstructorFlag _) : base(_) { } … … 115 128 116 129 // without derivation 117 public ShapeConstraint(Interval interval, double weight )130 public ShapeConstraint(Interval interval, double weight, Interval threshold) 118 131 : 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) 122 135 : this(string.Empty, 0, 123 interval, regions, weight ) { }136 interval, regions, weight, threshold) { } 124 137 125 138 public ShapeConstraint(string variable, int numberOfDerivations, 126 Interval interval, double weight )139 Interval interval, double weight, Interval threshold) 127 140 : this(variable, numberOfDerivations, 128 interval, new IntervalCollection(), weight ) { }141 interval, new IntervalCollection(), weight, threshold) { } 129 142 130 143 public ShapeConstraint(string variable, int numberOfDerivations, 131 Interval interval, IntervalCollection regions, double weight ) {144 Interval interval, IntervalCollection regions, double weight, Interval threshold) { 132 145 Variable = variable; 133 146 NumberOfDerivations = numberOfDerivations; … … 135 148 Regions = regions; 136 149 Weight = weight; 150 Threshold = threshold; 137 151 } 138 152 … … 175 189 if (!IsDerivative) { 176 190 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)}]"; 191 } else { 192 var derivationString = string.Empty; 193 switch (numberOfDerivations) { 194 case 1: 195 derivationString = ""; break; 196 case 2: 197 derivationString = "²"; break; 198 case 3: 199 derivationString = "³"; break; 180 200 } 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)}]"); 201 expression = string.Format($"∂{derivationString}f/∂{Variable}{derivationString} in [{write(Interval.LowerBound)} .. {write(Interval.UpperBound)}]"); 202 } 203 198 204 if (Regions != null) { 199 205 foreach (var region in Regions.GetReadonlyDictionary()) … … 203 209 expression += $" weight: {weight}"; 204 210 } 211 if (!double.IsNegativeInfinity(Threshold.LowerBound) || !double.IsPositiveInfinity(Threshold.UpperBound)) 212 expression += $" threshold: [{write(Threshold.LowerBound)} .. {write(Threshold.UpperBound)}]"; 213 205 214 return expression; 206 215 }
Note: See TracChangeset
for help on using the changeset viewer.