1 | using HEAL.Attic;
|
---|
2 | using HeuristicLab.Common;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
5 | using System.Collections.Generic;
|
---|
6 |
|
---|
7 | namespace 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 | }
|
---|