Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/03/19 14:15:11 (5 years ago)
Author:
msemenki
Message:

#2988:
Class HelpFuction get new static functions that are used in different Map’s classes and possible in other classes.
Branch was adapted to Hive.
New version of class structure for Maps:

  1. 3 new variants of maps (RankMap, SuccessMap and ZeroMap) are added.
  2. BaseMap class was simplified, some class members were deleted and other were transported to child class, because some of them are not used in all kinds of maps.
  3. Functions between base class and child class were divided in other way.
  4. Mutation operators were adapted to work with new class structure. Now mutation make less work for ModelNodes than previously.
  5. ModelNode and Model symbols were simplified. They should not take into account a map type.
  6. Models frequency analyzers were adapted for new variants of maps.
  7. EMMAlgorithm class was adapted to new maps
Location:
branches/2988_ModelsOfModels2/HeuristicLab.Algorithms.EMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2988_ModelsOfModels2/HeuristicLab.Algorithms.EMM

    • Property svn:ignore
      •  

        old new  
        1212*.nuget.props
        1313*.nuget.targets
         14Plugin.cs
  • branches/2988_ModelsOfModels2/HeuristicLab.Algorithms.EMM/EMMIslandMap.cs

    r16899 r17002  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     26using HeuristicLab.Random;
    2627using System.Collections.Generic;
     28using System.Linq;
    2729
    2830namespace HeuristicLab.Algorithms.EvolvmentModelsOfModels {
     
    3032  [StorableType("E4AB04B9-FD5D-47EE-949D-243660754F3A")]
    3133  public class EMMIslandMap : EMMMapBase<ISymbolicExpressionTree> {
     34    [Storable]
     35    public List<int> ClusterNumber { get; set; }  // May be only Island Map really need it
    3236    #region conctructors
    3337    [StorableConstructor]
    3438    protected EMMIslandMap(StorableConstructorFlag _) : base(_) { }
    35     public EMMIslandMap() : this(1) { }
     39    public EMMIslandMap() {
     40      ModelSet = new List<ISymbolicExpressionTree>();
     41      ClusterNumber = new List<int>();
     42    }
    3643    public override IDeepCloneable Clone(Cloner cloner) {
    3744      return new EMMIslandMap(this, cloner);
    3845    }
    39     public EMMIslandMap(int k) : base(k) { ModelSet = new List<ISymbolicExpressionTree>(); }
    40     public EMMIslandMap(EMMIslandMap original, Cloner cloner) : base(original, cloner) { }
    41     // public EMMIslandMap(IRandom random, IEnumerable<ISymbolicExpressionTree> trees, int k, int neghboorNumber) : base(random, trees, k) { }
    42     //public EMMIslandMap(IRandom random, IEnumerable<ISymbolicExpressionTree> trees, string fileName = "Map.txt") : base(random, trees, fileName) { }
     46    public EMMIslandMap(EMMIslandMap original, Cloner cloner) : base(original, cloner) {
     47      if (original.ClusterNumber != null) {
     48        ClusterNumber = original.ClusterNumber.ToList();
     49      }
     50    }
    4351    #endregion
    4452    #region MapApplayFunctions
    4553    override public void CreateMap(IRandom random, int k) {
    46       K = EMModelsClusterizationAlgorithm.ApplyClusteringAlgorithm(random, Distances, ClusterNumber, k);
    47       MapSizeCheck();
     54
     55      k = EMModelsClusterizationAlgorithm.ApplyClusteringAlgorithm(random, CalculateDistances(), ClusterNumber, k);
     56      MapSizeCheck(k);
    4857      for (int i = 0; i < ModelSet.Count; i++) {
    4958        Map[ClusterNumber[i]].Add(i);
    5059      }
    5160    }
    52     override public ISymbolicExpressionTree NewModelForInizializtionNotTree(IRandom random, out int cluster, out int treeNumber) {
    53       return NewModelForInizializtion(random, out cluster, out treeNumber);
     61    override public ISymbolicExpressionTree NewModelForInizializtionNotTree(IRandom random, out int treeNumber) {
     62      return NewModelForInizializtion(random, out treeNumber);
     63    }
     64
     65    public override ISymbolicExpressionTree NewModelForMutation(IRandom random, out int treeNumber, int parentTreeNumber) {
     66      if (parentTreeNumber == -10) {
     67        treeNumber = random.Next(ModelSet.Count);
     68      } else {
     69        treeNumber = Map[ClusterNumber[parentTreeNumber]].SampleRandom(random);
     70      }
     71      return (ISymbolicExpressionTree)ModelSet[treeNumber].Clone();
     72    }
     73    public void ClusterNumbersCalculate() {  // May be it should be transported to Child Clase (IslandMap)
     74      for (int i = 0; i < Map.Count; i++) {
     75        for (int j = 0; j < Map[i].Count; j++) {
     76          ClusterNumber.Add(0);
     77        }
     78      }
     79      for (int i = 0; i < Map.Count; i++) {
     80        for (int j = 0; j < Map[i].Count; j++) {
     81          ClusterNumber[Map[i][j]] = i;
     82        }
     83      }
    5484    }
    5585    #endregion
Note: See TracChangeset for help on using the changeset viewer.