- Timestamp:
- 06/03/19 14:15:11 (5 years ago)
- 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 12 12 *.nuget.props 13 13 *.nuget.targets 14 Plugin.cs
-
- Property svn:ignore
-
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 21 using HeuristicLab.Core; 2 22 using System.Collections.Generic; 3 23 using System.Linq; 4 using System.Text;5 using System.Threading.Tasks;6 using HEAL.Attic;7 24 8 25 namespace HeuristicLab.Algorithms.EvolvmentModelsOfModels { 9 26 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 } 10 37 public static int ChooseMinElementIndex(List<double> distances, int currentElement, List<int> previousNumbers) { 11 38 double minValue = 100; … … 28 55 return minElementNumber; 29 56 } 57 30 58 public static bool CheckNumberIsInList(int number, List<int> priviousNumber) { 31 59 foreach (var pNum in priviousNumber) { … … 46 74 return minElementNumber; 47 75 } 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 } 48 113 } 49 114 }
Note: See TracChangeset
for help on using the changeset viewer.