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/HelpFunctions.cs

    r16899 r17002  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21using HeuristicLab.Core;
    222using System.Collections.Generic;
    323using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
    6 using HEAL.Attic;
    724
    825namespace HeuristicLab.Algorithms.EvolvmentModelsOfModels {
    926  class HelpFunctions {
     27    public static int OneElementFromListProportionalSelection(IRandom random, List<double> list) {
     28      double selectedQuality = random.NextDouble() * list.Sum();
     29      int index = 0;
     30      double currentQuality = list[index];
     31      while ((currentQuality < selectedQuality) && (index < list.Count)) {
     32        index++;
     33        currentQuality += list[index];
     34      }
     35      return index;
     36    }
    1037    public static int ChooseMinElementIndex(List<double> distances, int currentElement, List<int> previousNumbers) {
    1138      double minValue = 100;
     
    2855      return minElementNumber;
    2956    }
     57
    3058    public static bool CheckNumberIsInList(int number, List<int> priviousNumber) {
    3159      foreach (var pNum in priviousNumber) {
     
    4674      return minElementNumber;
    4775    }
     76    public static int ChooseMaxElementIndex(List<double> averageClusterDistance) {
     77      double maxValue = averageClusterDistance[0];
     78      int maxElementNumber = 0;
     79      for (int i = 1; i < averageClusterDistance.Count(); i++) {
     80        if (averageClusterDistance[i] > maxValue) {
     81          maxValue = averageClusterDistance[i];
     82          maxElementNumber = i;
     83        }
     84      }
     85      return maxElementNumber;
     86    }
     87    public static double CheckSocialKatre(double socialKarteValue, double value, double stepValue) {
     88      if (value > (socialKarteValue + stepValue))
     89        return stepValue;
     90      else if (value > socialKarteValue)
     91        return (value - socialKarteValue);
     92      else return 0;
     93    }
     94    public static void ProbabilitiesUpDate(List<List<double>> sucsessStatistics, List<double> probabilities) {
     95
     96      var averageQuality = new List<double>();
     97      foreach (var variant in sucsessStatistics) {
     98        if (variant[0] > 0.005) {
     99          averageQuality.Add(variant[1] / variant[0]);
     100        } else { averageQuality.Add(0); }
     101      }
     102      int bestModelNumber = ChooseMaxElementIndex(averageQuality);
     103      double socialKarte = 1.0 / (probabilities.Count * 20.0); // parameters of method
     104      double stepValue = socialKarte / 5.0;
     105      double totalChangeValue = 0, changeValue = 0;
     106      for (int i = 0; i < probabilities.Count; i++) {
     107        changeValue = CheckSocialKatre(socialKarte, probabilities[i], stepValue);
     108        totalChangeValue += changeValue;
     109        probabilities[i] -= changeValue;
     110      }
     111      probabilities[bestModelNumber] += totalChangeValue;
     112    }
    48113  }
    49114}
Note: See TracChangeset for help on using the changeset viewer.