Changeset 17995 for branches/3119_AdditionalShapeConstraintFeatures/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/ShapeConstraint.cs
- Timestamp:
- 06/22/21 18:28:36 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3119_AdditionalShapeConstraintFeatures/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/ShapeConstraint.cs
r17946 r17995 107 107 108 108 [Storable] 109 private Interval threshold ;109 private Interval threshold = new Interval(0, 0); 110 110 public Interval Threshold { 111 111 get => threshold; … … 114 114 return; 115 115 threshold = value; 116 OnToStringChanged(); 117 OnChanged(); 118 } 119 } 120 121 122 [Storable] 123 private Interval targetInterval; 124 public Interval TargetInterval { 125 get => targetInterval; 126 set { 127 if (targetInterval == value) 128 return; 129 targetInterval = value; 130 OnToStringChanged(); 131 OnChanged(); 132 } 133 } 134 135 [Storable] 136 private Interval dynInterval = new Interval(double.NegativeInfinity, double.PositiveInfinity); 137 public Interval DynInterval { 138 get => dynInterval; 139 set { 140 if (dynInterval == value) 141 return; 142 dynInterval = value; 116 143 OnToStringChanged(); 117 144 OnChanged(); … … 125 152 private void AfterDeserialization() { 126 153 if (regions != null) regions.Changed += regions_Changed; 154 if (TargetInterval == null) 155 TargetInterval = new Interval(interval.LowerBound, interval.UpperBound); 127 156 } 128 157 129 158 // without derivation 130 public ShapeConstraint(Interval interval, double weight, Interval threshold )159 public ShapeConstraint(Interval interval, double weight, Interval threshold, Interval dynInterval) 131 160 : this(string.Empty, 0, 132 interval, new IntervalCollection(), weight, threshold ) { }133 134 public ShapeConstraint(Interval interval, IntervalCollection regions, double weight, Interval threshold )161 interval, new IntervalCollection(), weight, threshold, dynInterval) { } 162 163 public ShapeConstraint(Interval interval, IntervalCollection regions, double weight, Interval threshold, Interval dynInterval) 135 164 : this(string.Empty, 0, 136 interval, regions, weight, threshold ) { }165 interval, regions, weight, threshold, dynInterval) { } 137 166 138 167 public ShapeConstraint(string variable, int numberOfDerivations, 139 Interval interval, double weight, Interval threshold )168 Interval interval, double weight, Interval threshold, Interval dynInterval) 140 169 : this(variable, numberOfDerivations, 141 interval, new IntervalCollection(), weight, threshold ) { }170 interval, new IntervalCollection(), weight, threshold, dynInterval) { } 142 171 143 172 public ShapeConstraint(string variable, int numberOfDerivations, 144 Interval interval, IntervalCollection regions, double weight, Interval threshold ) {173 Interval interval, IntervalCollection regions, double weight, Interval threshold, Interval dynInterval) { 145 174 Variable = variable; 146 175 NumberOfDerivations = numberOfDerivations; … … 149 178 Weight = weight; 150 179 Threshold = threshold; 180 DynInterval = dynInterval; 181 TargetInterval = new Interval(interval.LowerBound, interval.UpperBound); 151 182 } 152 183 … … 162 193 Regions = cloner.Clone(original.Regions); 163 194 Weight = original.weight; 164 } 165 195 Threshold = original.Threshold; 196 DynInterval = original.DynInterval; 197 TargetInterval = original.TargetInterval; 198 } 166 199 167 200 public event EventHandler Changed; … … 188 221 string write(double val) => double.IsPositiveInfinity(val) ? "inf." : double.IsNegativeInfinity(val) ? "-inf." : $"{val}"; 189 222 if (!IsDerivative) { 190 expression = string.Format($"f in [{write( Interval.LowerBound)} .. {write(Interval.UpperBound)}]");223 expression = string.Format($"f in [{write(TargetInterval.LowerBound)} .. {write(TargetInterval.UpperBound)}]"); 191 224 } else { 192 225 var derivationString = string.Empty; … … 199 232 derivationString = "³"; break; 200 233 } 201 expression = string.Format($"∂{derivationString}f/∂{Variable}{derivationString} in [{write( Interval.LowerBound)} .. {write(Interval.UpperBound)}]");234 expression = string.Format($"∂{derivationString}f/∂{Variable}{derivationString} in [{write(TargetInterval.LowerBound)} .. {write(TargetInterval.UpperBound)}]"); 202 235 } 203 236 … … 209 242 expression += $" weight: {weight}"; 210 243 } 244 211 245 if (!double.IsNegativeInfinity(Threshold.LowerBound) || !double.IsPositiveInfinity(Threshold.UpperBound)) 212 expression += $" threshold: [{write(Threshold.LowerBound)} .. {write(Threshold.UpperBound)}]"; 246 expression += $" threshold in [{write(Threshold.LowerBound)} .. {write(Threshold.UpperBound)}]"; 247 248 if (!double.IsNegativeInfinity(DynInterval.LowerBound) && !double.IsPositiveInfinity(DynInterval.UpperBound)) 249 expression += $" start in [{write(DynInterval.LowerBound)} .. {write(DynInterval.UpperBound)}]"; 213 250 214 251 return expression;
Note: See TracChangeset
for help on using the changeset viewer.