Changeset 15301 for trunk/sources/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageTree.cs
- Timestamp:
- 08/01/17 11:07:48 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageTree.cs
r14185 r15301 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.Encodings.BinaryVectorEncoding; 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 30 using HeuristicLab.Random; 30 31 … … 33 34 // B. W. Goldman and W. F. Punch, "Parameter-less Population Pyramid," GECCO, pp. 785–792, 2014 34 35 // and the original source code in C++11 available from: https://github.com/brianwgoldman/Parameter-less_Population_Pyramid 35 public class LinkageTree { 36 [StorableClass] 37 public class LinkageTree : DeepCloneable { 38 [Storable] 36 39 private readonly int[][][] occurances; 40 [Storable] 37 41 private readonly List<int>[] clusters; 42 [Storable] 38 43 private List<int> clusterOrdering; 44 [Storable] 39 45 private readonly int length; 46 [Storable] 40 47 private readonly IRandom rand; 48 [Storable] 41 49 private bool rebuildRequired = false; 50 51 52 [StorableConstructor] 53 protected LinkageTree(bool deserializing) : base() { } 54 55 56 protected LinkageTree(LinkageTree original, Cloner cloner) : base(original, cloner) { 57 occurances = new int[original.occurances.Length][][]; 58 //mkommend: first entry is not used, cf. ctor line 83 59 for (int i = 1; i < original.occurances.Length; i++) { 60 occurances[i] = new int[original.occurances[i].Length][]; 61 for (int j = 0; j < original.occurances[i].Length; j++) 62 occurances[i][j] = original.occurances[i][j].ToArray(); 63 } 64 65 clusters = original.clusters.Select(c => c.ToList()).ToArray(); 66 clusterOrdering = new List<int>(original.clusterOrdering); 67 length = original.length; 68 rand = cloner.Clone(original.rand); 69 rebuildRequired = original.rebuildRequired; 70 } 71 72 73 public override IDeepCloneable Clone(Cloner cloner) { 74 return new LinkageTree(this, cloner); 75 } 42 76 43 77 public LinkageTree(int length, IRandom rand) { … … 93 127 // Uses the frequency table to calcuate the entropy distance between two indices. 94 128 // In the GECCO paper, calculates Equation 1 95 private int[] bits = new int[4];96 129 private double EntropyDistance(int i, int j) { 130 int[] bits = new int[4]; 97 131 // This ensures you are using the lower triangular part of "occurances" 98 132 if (i < j) { … … 125 159 // by I. Gronau and S. Moran 126 160 // In the GECCO paper, Figure 2 is a simplified version of this algorithm. 127 private double[][] distances;128 161 private void Rebuild() { 162 double[][] distances = null; 129 163 if (distances == null) { 130 164 distances = new double[clusters.Length * 2 - 1][];
Note: See TracChangeset
for help on using the changeset viewer.