Changeset 16692 for branches/2521_ProblemRefactoring/HeuristicLab.Common
- Timestamp:
- 03/18/19 17:24:30 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 1 deleted
- 27 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/ArrayExtensions.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/CancelEventArgs.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/Cloner.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/ColorGradient.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/Constants.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/Content/ContentManager.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/Content/IContent.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/Content/IStorableContent.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/DeepCloneable.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/DoubleExtensions.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/EnumerableExtensions.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 98 98 return sequences.Where(s => s.Any()).Aggregate(result, (current, s) => (from seq in current from item in s select seq.Concat(new[] { item }))); 99 99 } 100 101 /// <summary> 102 /// Compute all k-combinations of elements from the provided collection. 103 /// <param name="elements">The collection of elements</param> 104 /// <param name="k">The combination group size</param> 105 /// <returns>An enumerable sequence of all the possible k-combinations of elements</returns> 106 /// </summary> 107 public static IEnumerable<IEnumerable<T>> Combinations<T>(this IList<T> elements, int k) { 108 if (k > elements.Count) 109 throw new ArgumentException(); 110 111 if (k == 1) { 112 foreach (var element in elements) 113 yield return new[] { element }; 114 yield break; 115 } 116 117 int n = elements.Count; 118 var range = Enumerable.Range(0, k).ToArray(); 119 var length = BinomialCoefficient(n, k); 120 121 for (int i = 0; i < length; ++i) { 122 yield return range.Select(x => elements[x]).ToArray(); 123 124 if (i == length - 1) break; 125 var m = k - 1; 126 var max = n - 1; 127 128 while (range[m] == max) { --m; --max; } 129 range[m]++; 130 for (int j = m + 1; j < k; ++j) { 131 range[j] = range[j - 1] + 1; 132 } 133 } 134 } 135 136 /// <summary> 137 /// This function gets the total number of unique combinations based upon N and K, 138 /// where N is the total number of items and K is the size of the group. 139 /// It calculates the total number of unique combinations C(N, K) = N! / ( K! (N - K)! ) 140 /// using the recursion C(N+1, K+1) = (N+1 / K+1) * C(N, K). 141 /// <remarks>http://blog.plover.com/math/choose.html</remarks> 142 /// <remark>https://en.wikipedia.org/wiki/Binomial_coefficient#Multiplicative_formula</remark> 143 /// <param name="n">The number of elements</param> 144 /// <param name="k">The size of the group</param> 145 /// <returns>The binomial coefficient C(N, K)</returns> 146 /// </summary> 147 public static long BinomialCoefficient(long n, long k) { 148 if (k > n) return 0; 149 if (k == n) return 1; 150 if (k > n - k) 151 k = n - k; 152 153 // enable explicit overflow checking for very large coefficients 154 checked { 155 long r = 1; 156 for (long d = 1; d <= k; d++) { 157 r *= n--; 158 r /= d; 159 } 160 return r; 161 } 162 } 100 163 } 101 164 } -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/EventArgs.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/HeuristicLab.Common-3.3.csproj
r12292 r16692 123 123 </ItemGroup> 124 124 <ItemGroup> 125 <Compile Include="AsyncHelper.cs" /> 125 126 <Compile Include="CancelEventArgs.cs" /> 126 127 <None Include="Plugin.cs.frame" /> … … 131 132 <Compile Include="Constants.cs" /> 132 133 <Compile Include="ArrayExtensions.cs" /> 134 <Compile Include="ExceptionExtensions.cs" /> 135 <Compile Include="Statistics\EmpiricalCumulativeDistributionFunction.cs" /> 133 136 <Compile Include="ListExtensions.cs" /> 134 137 <Compile Include="Point2D.cs" /> … … 139 142 <Compile Include="DeepCloneable.cs" /> 140 143 <Compile Include="Content\IContent.cs" /> 141 <Compile Include=" EnumerableStatisticExtensions.cs" />144 <Compile Include="Statistics\EnumerableStatisticExtensions.cs" /> 142 145 <Compile Include="IDeepCloneable.cs" /> 143 146 <Compile Include="Plugin.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/IDeepCloneable.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/ListExtensions.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/MatrixExtensions.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System.Diagnostics.Contracts; 23 22 24 namespace HeuristicLab.Common { 23 25 public static class MatrixExtensions { … … 35 37 return result; 36 38 } 39 40 /// <summary> 41 /// Concatenates matrices vertically. 42 /// A B 43 /// 1 2 9 8 44 /// 3 4 7 6 45 /// 46 /// VertCat(A, B) 47 /// 1 2 48 /// 3 4 49 /// 9 8 50 /// 7 6 51 /// </summary> 52 /// <typeparam name="T"></typeparam> 53 /// <param name="a"></param> 54 /// <param name="b"></param> 55 /// <returns>A new matrix with the number of rows = a.GetLength(0) + b.GetLength(0)</returns> 56 public static T[,] VertCat<T>(this T[,] a, T[,] b) { 57 Contract.Assert(a.GetLength(1) == b.GetLength(1)); 58 var aLen = a.GetLength(0); 59 var bLen = b.GetLength(0); 60 var result = new T[aLen + bLen, a.GetLength(1)]; 61 for (int i = 0; i < aLen; i++) 62 for (int j = 0; j < a.GetLength(1); j++) 63 result[i, j] = a[i, j]; 64 for (int i = 0; i < bLen; i++) 65 for (int j = 0; j < b.GetLength(1); j++) 66 result[i + aLen, j] = b[i, j]; 67 68 return result; 69 } 70 71 /// <summary> 72 /// Concatenates matrices horizontally. 73 /// A B 74 /// 1 2 9 8 75 /// 3 4 7 6 76 /// 77 /// HorzCat(A, B) 78 /// 1 2 9 8 79 /// 3 4 7 6 80 /// </summary> 81 /// <typeparam name="T"></typeparam> 82 /// <param name="a"></param> 83 /// <param name="b"></param> 84 /// <returns>A new matrix with the number of columns = a.GetLength(1) + b.GetLength(1)</returns> 85 public static T[,] HorzCat<T>(this T[,] a, T[,] b) { 86 Contract.Assert(a.GetLength(0) == b.GetLength(0)); 87 var aLen = a.GetLength(1); 88 var bLen = b.GetLength(1); 89 var result = new T[a.GetLength(0), aLen + bLen]; 90 for (int i = 0; i < a.GetLength(0); i++) 91 for (int j = 0; j < aLen; j++) 92 result[i, j] = a[i, j]; 93 for (int i = 0; i < a.GetLength(0); i++) 94 for (int j = 0; j < bLen; j++) 95 result[i, j + aLen] = b[i, j]; 96 return result; 97 } 37 98 } 38 99 } -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/NaturalStringComparer.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/ObjectExtensions.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 30 30 31 31 namespace HeuristicLab.Common { 32 33 [AttributeUsage(AttributeTargets.Field)] 34 // this attribute can be used to mark fields that should be excluded from object graph traversal 35 public class ExcludeFromObjectGraphTraversalAttribute : Attribute { 36 } 37 32 38 public static class ObjectExtensions { 33 39 public static IEnumerable<T> ToEnumerable<T>(this T obj) { … … 66 72 /// * string, decimal, DateTime 67 73 /// * Arrays of types not collected 74 /// * All types from System.Reflection.Emit 68 75 /// </summary> 69 76 private static bool ExcludeType(Type type) { … … 77 84 typeof(Delegate).IsAssignableFrom(type) || 78 85 typeof(Pointer).IsAssignableFrom(type) || 79 type == typeof(System.Reflection.Emit.SignatureHelper)||86 type.Namespace == "System.Reflection.Emit" || 80 87 (type.HasElementType && ExcludeType(type.GetElementType())); 81 88 } … … 112 119 } 113 120 } else { 114 if (!fieldInfos.ContainsKey(type)) 115 fieldInfos[type] = type.GetAllFields().ToArray(); 116 foreach (FieldInfo f in fieldInfos[type]) { 121 FieldInfo[] fieldInfo; 122 if (!fieldInfos.TryGetValue(type, out fieldInfo)) { 123 fieldInfo = type.GetAllFields() 124 .Where(fi => !Attribute.IsDefined(fi, typeof(ExcludeFromObjectGraphTraversalAttribute))) 125 .ToArray(); 126 fieldInfos.Add(type, fieldInfo); 127 } 128 foreach (FieldInfo f in fieldInfo) { 117 129 if (excludeStaticMembers && f.IsStatic) continue; 118 130 object fieldValue; 119 131 try { 120 132 fieldValue = f.GetValue(obj); 121 } 122 catch (SecurityException) { 133 } catch (SecurityException) { 123 134 continue; 124 135 } -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/Plugin.cs.frame
r13321 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 29 29 /// Plugin class for HeuristicLab.Common plugin. 30 30 /// </summary> 31 [Plugin("HeuristicLab.Common", "3.3.1 3.$WCREV$")]31 [Plugin("HeuristicLab.Common", "3.3.15.$WCREV$")] 32 32 [PluginFile("HeuristicLab.Common-3.3.dll", PluginFileType.Assembly)] 33 33 public class HeuristicLabCommonPlugin : PluginBase { -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/Point2D.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 namespace HeuristicLab.Common { 27 27 [Serializable] 28 public struct Point2D<T> where T : struct {28 public struct Point2D<T> where T : struct, IEquatable<T> { 29 29 public static readonly Point2D<T> Empty = new Point2D<T>(); 30 30 … … 38 38 } 39 39 40 private object tag; 41 public object Tag { 42 get { return tag; } 43 } 44 40 45 [Browsable(false)] 41 46 public bool IsEmpty { … … 43 48 } 44 49 45 public Point2D(T x, T y ) {50 public Point2D(T x, T y, object tag = null) { 46 51 this.x = x; 47 52 this.y = y; 53 this.tag = tag; 54 } 55 56 public static Point2D<T> Create(T x, T y, object tag = null) { 57 return new Point2D<T>(x, y, tag); 48 58 } 49 59 50 60 public static bool operator ==(Point2D<T> left, Point2D<T> right) { 51 return left.x.Equals(right.x) && left.y.Equals(right.y) ;61 return left.x.Equals(right.x) && left.y.Equals(right.y) && left.tag == right.tag; 52 62 } 53 63 public static bool operator !=(Point2D<T> left, Point2D<T> right) { … … 59 69 return false; 60 70 Point2D<T> point = (Point2D<T>)obj; 61 return x.Equals(point.x) && y.Equals(point.y) && GetType().Equals(point.GetType()); 71 return GetType() == point.GetType() && x.Equals(point.x) && y.Equals(point.y) && 72 ((tag != null && tag.Equals(point.tag)) || tag == point.tag); 62 73 } 63 74 public override int GetHashCode() { -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/Properties/AssemblyInfo.cs.frame
r13321 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 32 32 [assembly: AssemblyCompany("")] 33 33 [assembly: AssemblyProduct("HeuristicLab")] 34 [assembly: AssemblyCopyright("(c) 2002-201 5HEAL")]34 [assembly: AssemblyCopyright("(c) 2002-2018 HEAL")] 35 35 [assembly: AssemblyTrademark("")] 36 36 [assembly: AssemblyCulture("")] … … 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3.1 3.$WCREV$")]56 [assembly: AssemblyFileVersion("3.3.15.$WCREV$")] -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/ReferenceEqualityComparer.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/SequenceGenerator.cs
r12292 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/TimeSpanHelper.cs
r12626 r16692 2 2 3 3 /* HeuristicLab 4 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/TypeEqualityComparer.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Common/3.3/TypeExtensions.cs
r12012 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab.
Note: See TracChangeset
for help on using the changeset viewer.