Changeset 11203 for branches/HiveStatistics/sources/HeuristicLab.Random/3.3
- Timestamp:
- 07/18/14 12:35:00 (10 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll11 10 HeuristicLab 3.3.5.1.ReSharper.user 12 11 HeuristicLab 3.3.6.0.ReSharper.user 13 12 HeuristicLab.4.5.resharper.user 14 13 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development16 14 HeuristicLab.resharper.user 17 15 ProtoGen.exe … … 19 17 _ReSharper.HeuristicLab 20 18 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests22 19 _ReSharper.HeuristicLab.ExtLibs 23 20 bin 24 21 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HiveStatistics/sources/HeuristicLab.Random/3.3/MersenneTwister.cs
r11202 r11203 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HiveStatistics/sources/HeuristicLab.Random/3.3/NormalDistributedRandom.cs
r11202 r11203 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HiveStatistics/sources/HeuristicLab.Random/3.3/NormalRandomizer.cs
r11202 r11203 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HiveStatistics/sources/HeuristicLab.Random/3.3/Plugin.cs.frame
r11202 r11203 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 /// Plugin class for HeuristicLab.Random plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Random", "3.3. 10.$WCREV$")]28 [Plugin("HeuristicLab.Random", "3.3.7.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Random-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/HiveStatistics/sources/HeuristicLab.Random/3.3/Properties/AssemblyInfo.cs.frame
r11202 r11203 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 32 32 [assembly: AssemblyCompany("")] 33 33 [assembly: AssemblyProduct("HeuristicLab")] 34 [assembly: AssemblyCopyright("(c) 2002-201 4HEAL")]34 [assembly: AssemblyCopyright("(c) 2002-2012 HEAL")] 35 35 [assembly: AssemblyTrademark("")] 36 36 [assembly: AssemblyCulture("")] … … 54 54 // by using the '*' as shown below: 55 55 [assembly: AssemblyVersion("3.3.0.0")] 56 [assembly: AssemblyFileVersion("3.3. 10.$WCREV$")]56 [assembly: AssemblyFileVersion("3.3.7.$WCREV$")] -
branches/HiveStatistics/sources/HeuristicLab.Random/3.3/RandomCreator.cs
r11202 r11203 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HiveStatistics/sources/HeuristicLab.Random/3.3/RandomEnumerable.cs
r11202 r11203 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 36 36 37 37 //algorithm taken from progamming pearls page 127 38 //IMPORTANT because IEnumerables with yield are used the seed must be specified to return always38 //IMPORTANT because IEnumerables with yield are used the seed must best be specified to return always 39 39 //the same sequence of numbers without caching the values. 40 40 public static IEnumerable<int> SampleRandomNumbers(int seed, int start, int end, int count) { … … 166 166 /// 167 167 /// The method internally holds two arrays: One that is the sequence itself and another one for the values. 168 ///169 /// The method does not check if the number of elements in source and weights are the same.170 168 /// </remarks> 171 169 /// <typeparam name="T">The type of the items to be selected.</typeparam> … … 175 173 /// <param name="weights">The weight values for the items.</param> 176 174 /// <param name="windowing">Whether to scale the proportional values or not.</param> 177 /// <param name=" inverseProportional">Determines whether to choose proportionally (true) or inverse-proportionally (false).</param>178 /// <returns>A sequence of selected items. Might actually be shorter than <paramref name="count"/> elements if source has less than <paramref name="count"/> elements.</returns>175 /// <param name="maximization">Determines whether to choose proportionally (true) or inverse-proportionally (false).</param> 176 /// <returns>A sequence of selected items.</returns> 179 177 public static IEnumerable<T> SampleProportionalWithoutRepetition<T>(this IEnumerable<T> source, IRandom random, int count, IEnumerable<double> weights, bool windowing = true, bool inverseProportional = false) { 180 178 return source.SampleProportionalWithoutRepetition(random, weights, windowing, inverseProportional).Take(count); … … 183 181 private static IEnumerable<T> SampleProportional<T>(this IEnumerable<T> source, IRandom random, IEnumerable<double> weights, bool windowing, bool inverseProportional) { 184 182 var sourceArray = source.ToArray(); 185 var valueArray = PrepareProportional (weights, windowing, inverseProportional);183 var valueArray = PrepareProportional<T>(sourceArray, weights, windowing, inverseProportional); 186 184 double total = valueArray.Sum(); 187 185 … … 195 193 } 196 194 private static IEnumerable<T> SampleProportionalWithoutRepetition<T>(this IEnumerable<T> source, IRandom random, IEnumerable<double> weights, bool windowing, bool inverseProportional) { 197 var valueArray = PrepareProportional(weights, windowing, inverseProportional);198 var list = new LinkedList<Tuple<T, double>>(source.Zip(valueArray, Tuple.Create));195 var sourceArray = source.ToArray(); 196 var valueArray = PrepareProportional<T>(sourceArray, weights, windowing, inverseProportional); 199 197 double total = valueArray.Sum(); 200 198 201 while (list.Count > 0) { 202 var cur = list.First; 203 double ball = cur.Value.Item2, sum = random.NextDouble() * total; // assert: sum < total. When there is only one item remaining: sum < ball 199 HashSet<int> chosenIndices = new HashSet<int>(); 200 while (chosenIndices.Count < sourceArray.Length) { 201 int index = 0; 202 double ball = valueArray[index], sum = random.NextDouble() * total; 204 203 while (ball < sum) { 205 cur = cur.Next;206 ball += cur.Value.Item2;207 }208 yield return cur.Value.Item1;209 list.Remove(cur);210 total -= cur.Value.Item2;211 }212 }213 214 private static double[] PrepareProportional (IEnumerable<double> weights, bool windowing, bool inverseProportional) {204 index++; 205 if (!chosenIndices.Contains(index)) 206 ball += valueArray[++index]; 207 } 208 yield return sourceArray[index]; 209 chosenIndices.Add(index); 210 total -= valueArray[index]; 211 } 212 } 213 private static double[] PrepareProportional<T>(IList<T> sourceArray, IEnumerable<double> weights, bool windowing, bool inverseProportional) { 215 214 double maxValue = double.MinValue, minValue = double.MaxValue; 216 double[] valueArray = weights.ToArray(); 217 218 for (int i = 0; i < valueArray.Length; i++) { 215 double[] valueArray = new double[sourceArray.Count]; 216 217 var weightsEnum = weights.GetEnumerator(); 218 for (int i = 0; i < sourceArray.Count && weightsEnum.MoveNext(); i++) { 219 valueArray[i] = weightsEnum.Current; 219 220 if (valueArray[i] > maxValue) maxValue = valueArray[i]; 220 221 if (valueArray[i] < minValue) minValue = valueArray[i]; 221 222 } 222 223 if (minValue == maxValue) { // all values are equal 223 for (int i = 0; i < valueArray.Length; i++) {224 for (int i = 0; i < sourceArray.Count; i++) { 224 225 valueArray[i] = 1.0; 225 226 } … … 273 274 } 274 275 } 275 -
branches/HiveStatistics/sources/HeuristicLab.Random/3.3/UniformDistributedRandom.cs
r11202 r11203 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/HiveStatistics/sources/HeuristicLab.Random/3.3/UniformRandomizer.cs
r11202 r11203 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab.
Note: See TracChangeset
for help on using the changeset viewer.