Changeset 17918 for branches/3105_PythonFormatter/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval
- Timestamp:
- 03/29/21 09:54:58 (4 years ago)
- Location:
- branches/3105_PythonFormatter
- Files:
-
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3105_PythonFormatter
- Property svn:mergeinfo changed
/trunk (added) merged: 17845,17856,17858-17859,17861,17867,17871-17873,17888-17889,17902-17903,17906-17914
- Property svn:mergeinfo changed
-
branches/3105_PythonFormatter/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
branches/3105_PythonFormatter/HeuristicLab.Problems.DataAnalysis/3.4
- Property svn:mergeinfo changed
-
branches/3105_PythonFormatter/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Interval.cs
- Property svn:mergeinfo changed
r17583 r17918 33 33 [Storable] 34 34 public double UpperBound { get; private set; } 35 36 public double Width => UpperBound - LowerBound; 35 37 36 38 [StorableConstructor] … … 67 69 } 68 70 71 private Interval(double v) : this(v, v) { } 72 69 73 public bool Contains(double value) { 70 74 return LowerBound <= value && value <= UpperBound; … … 126 130 return false; 127 131 128 return (UpperBound .IsAlmost(other.UpperBound)|| (double.IsNaN(UpperBound) && double.IsNaN(other.UpperBound)))129 && (LowerBound .IsAlmost(other.LowerBound)|| (double.IsNaN(LowerBound) && double.IsNaN(other.LowerBound)));132 return (UpperBound==other.UpperBound || (double.IsNaN(UpperBound) && double.IsNaN(other.UpperBound))) 133 && (LowerBound==other.LowerBound || (double.IsNaN(LowerBound) && double.IsNaN(other.LowerBound))); 130 134 } 131 135 … … 267 271 } 268 272 269 public static Interval Analytic alQuotient(Interval a, Interval b) {273 public static Interval AnalyticQuotient(Interval a, Interval b) { 270 274 var dividend = a; 271 275 var divisor = Add(Square(b), new Interval(1.0, 1.0)); … … 276 280 } 277 281 #endregion 282 283 #region arithmetic overloads 284 public static Interval operator +(Interval a, Interval b) => Add(a, b); 285 public static Interval operator +(Interval a, double b) => Add(a, new Interval(b)); 286 public static Interval operator +(double a, Interval b) => Add(new Interval(a), b); 287 public static Interval operator -(Interval a, Interval b) => Subtract(a, b); 288 public static Interval operator -(Interval a, double b) => Subtract(a, new Interval(b)); 289 public static Interval operator -(double a, Interval b) => Subtract(new Interval(a), b); 290 public static Interval operator -(Interval a) => Subtract(new Interval(0), a); 291 public static Interval operator *(Interval a, Interval b) => Multiply(a, b); 292 public static Interval operator *(Interval a, double b) => Multiply(a, new Interval(b)); 293 public static Interval operator *(double a, Interval b) => Multiply(new Interval(a), b); 294 public static Interval operator /(Interval a, Interval b) => Divide(a, b); 295 public static Interval operator /(Interval a, double b) => Divide(a, new Interval(b)); 296 public static Interval operator /(double a, Interval b) => Divide(new Interval(a), b); 297 public static Interval Exponential(double a) { return Exponential(new Interval(a)); } 298 public static Interval Logarithm(double a) { return Logarithm(new Interval(a)); } 299 public static Interval Sine(double a) { return Sine(new Interval(a)); } 300 public static Interval Cosine(double a) { return Cosine(new Interval(a)); } 301 public static Interval Tangens(double a) { return Tangens(new Interval(a)); } 302 public static Interval HyperbolicTangent(double a) { return HyperbolicTangent(new Interval(a)); } 303 public static Interval Square(double a) { return Square(new Interval(a)); } 304 public static Interval Cube(double a) { return Cube(new Interval(a)); } 305 public static Interval SquareRoot(double a) { return SquareRoot(new Interval(a)); } 306 public static Interval CubicRoot(double a) { return CubicRoot(new Interval(a)); } 307 public static Interval Absolute(double a) { return Absolute(new Interval(a)); } 308 public static Interval AnalyticQuotient(Interval a, double b) { return AnalyticQuotient(a, new Interval(b)); } 309 public static Interval AnalyticQuotient(double a, Interval b) { return AnalyticQuotient(new Interval(a), b); } 310 public static Interval AnalyticQuotient(double a, double b) { return AnalyticQuotient(new Interval(a), new Interval(b)); } 311 #endregion 278 312 } 279 313 } -
branches/3105_PythonFormatter/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalCollection.cs
r17564 r17918 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2019Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 34 34 get => HeuristicLab.Common.Resources.VSImageLibrary.Object; 35 35 } 36 private IDictionary<string, Interval> intervals { get; } = new Dictionary<string, Interval>();37 36 38 [Storable(Name = "StorableIntervalInformation")] 37 private IDictionary<string, Interval> intervals { get; set; } = new Dictionary<string, Interval>(); 38 39 [Storable(OldName = "StorableIntervalInformation")] 39 40 private KeyValuePair<string, double[]>[] StorableIntervalInformation { 41 set { 42 foreach (var varInt in value) 43 intervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1])); 44 } 45 } 46 47 [Storable] 48 private object[] StorableIntervals { 40 49 get { 41 var l = new List<KeyValuePair<string, double[]>>(); 42 foreach (var varInt in intervals) 50 var names = intervals.Keys.ToArray(); 51 var lowerBounds = intervals.Values.Select(i => i.LowerBound).ToArray(); 52 var upperBounds = intervals.Values.Select(i => i.UpperBound).ToArray(); 43 53 44 l.Add(new KeyValuePair<string, double[]>(varInt.Key, 45 new double[] { varInt.Value.LowerBound, varInt.Value.UpperBound })); 46 return l.ToArray(); 54 return new object[] { names, lowerBounds, upperBounds }; 47 55 } 48 56 49 57 set { 50 foreach (var varInt in value) 51 intervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1])); 58 var names = (string[])value[0]; 59 var lowerBounds = (double[])value[1]; 60 var upperBounds = (double[])value[2]; 61 62 for (int i = 0; i < names.Length; i++) { 63 intervals.Add(names[i], new Interval(lowerBounds[i], upperBounds[i])); 64 } 52 65 } 53 66 } … … 80 93 public void SetInterval(string identifier, Interval interval) { 81 94 intervals[identifier] = interval; 95 RaiseChanged(); 82 96 } 83 97 84 98 public void AddInterval(string identifier, Interval interval) { 85 99 intervals.Add(identifier, interval); 100 RaiseChanged(); 86 101 } 87 102 88 103 public void DeleteInterval(string identifier) { 89 104 intervals.Remove(identifier); 105 RaiseChanged(); 90 106 } 91 107 92 108 public IReadOnlyDictionary<string, Interval> GetReadonlyDictionary() { 109 return intervals.ToDictionary(pair => pair.Key, pair => pair.Value); 110 } 111 112 public IDictionary<string, Interval> GetDictionary() { 93 113 return intervals.ToDictionary(pair => pair.Key, pair => pair.Value); 94 114 } … … 98 118 yield return Tuple.Create(variableInterval.Key, variableInterval.Value); 99 119 } 120 121 public event EventHandler Changed; 122 private void RaiseChanged() { 123 var handler = Changed; 124 if (handler != null) 125 handler(this, EventArgs.Empty); 126 } 127 100 128 } 101 129 }
Note: See TracChangeset
for help on using the changeset viewer.