Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2988_ModelsOfModels2/HeuristicLab.Algorithms.EMM/EMMDisatanceMap.cs @ 16899

Last change on this file since 16899 was 16899, checked in by msemenki, 5 years ago

#2988: New version of class structure.

File size: 2.1 KB
Line 
1using HEAL.Attic;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
5using System.Collections.Generic;
6
7namespace HeuristicLab.Algorithms.EvolvmentModelsOfModels {
8  [Item("DistanceMap", "A map of models of models of models")]
9  [StorableType("456692FB-2149-4359-8106-45D59D2D7FA0")]
10  public class EMMDisatanceMap : EMMMapBase<ISymbolicExpressionTree> {
11
12    // Under the work now. Do not take into account =)
13    #region conctructors
14    [StorableConstructor]
15    protected EMMDisatanceMap(StorableConstructorFlag _) : base(_) { }
16    public EMMDisatanceMap() : this(1) { }
17    public override IDeepCloneable Clone(Cloner cloner) {
18      return new EMMDisatanceMap(this, cloner);
19    }
20    public EMMDisatanceMap(int k) : base(k) { ModelSet = new List<ISymbolicExpressionTree>(); }
21    public EMMDisatanceMap(EMMDisatanceMap original, Cloner cloner) : base(original, cloner) { }
22    #endregion
23    #region MapApplayFunctions
24    override public void CreateMap(IRandom random, int k) {
25      K = Map.Count;
26      ApplyDistanceMapCreationAlgorithm(random, Distances, Map, K);
27      for (int i = 0; i < Map.Count; i++) {
28        ClusterNumber.Add(i);
29      }
30    }
31    public static void ApplyDistanceMapCreationAlgorithm(IRandom random, double[,] distances, List<List<int>> map, int k, int neghboorNumber = 10) {
32      int mapSize = distances.GetLength(0);
33      List<double> currentList = new List<double>();
34      for (int i = 0; i < mapSize; i++) {
35        map.Add(new List<int>());
36        for (int j = 0; j < mapSize; j++) {
37          currentList.Add(distances[i, j]);
38        }
39        map[i].Add(HelpFunctions.ChooseMinElementIndex(currentList));
40        while (map[i].Count < neghboorNumber) {
41          map[i].Add(HelpFunctions.ChooseMinElementIndex(currentList, i, map[i]));
42        }
43        currentList.Clear();
44      }
45    }
46
47    override public ISymbolicExpressionTree NewModelForInizializtionNotTree(IRandom random, out int cluster, out int treeNumber) {
48      return NewModelForInizializtion(random, out cluster, out treeNumber);
49    }
50    #endregion
51  }
52}
Note: See TracBrowser for help on using the repository browser.