- Timestamp:
- 09/25/15 14:39:59 (9 years ago)
- Location:
- branches/gteufl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gteufl
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 25 obj
-
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:ignore
-
branches/gteufl/HeuristicLab.Encodings.BinaryVectorEncoding
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/HLScript/HeuristicLab.Encodings.BinaryVectorEncoding merged eligible /branches/HiveStatistics/sources/HeuristicLab.Encodings.BinaryVectorEncoding merged eligible /stable/HeuristicLab.Encodings.BinaryVectorEncoding merged eligible /trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding merged eligible /branches/1721-RandomForestPersistence/HeuristicLab.Encodings.BinaryVectorEncoding 10321-10322 /branches/Algorithms.GradientDescent/HeuristicLab.Encodings.BinaryVectorEncoding 5516-5520 /branches/Benchmarking/sources/HeuristicLab.Encodings.BinaryVectorEncoding 6917-7005 /branches/CloningRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding 4656-4721 /branches/CodeEditor/HeuristicLab.Encodings.BinaryVectorEncoding 11700-11806 /branches/DataAnalysis Refactoring/HeuristicLab.Encodings.BinaryVectorEncoding 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Encodings.BinaryVectorEncoding 5815-6180 /branches/DataAnalysis/HeuristicLab.Encodings.BinaryVectorEncoding 4458-4459,4462,4464 /branches/DataPreprocessing/HeuristicLab.Encodings.BinaryVectorEncoding 10085-11101 /branches/GP.Grammar.Editor/HeuristicLab.Encodings.BinaryVectorEncoding 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Encodings.BinaryVectorEncoding 5060 /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Encodings.BinaryVectorEncoding 11570-12508 /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Encodings.BinaryVectorEncoding 6123-9799 /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Encodings.BinaryVectorEncoding 11130-12721 /branches/LogResidualEvaluator/HeuristicLab.Encodings.BinaryVectorEncoding 10202-10483 /branches/NET40/sources/HeuristicLab.Encodings.BinaryVectorEncoding 5138-5162 /branches/NSGA-II Changes/HeuristicLab.Encodings.BinaryVectorEncoding 12033-12122 /branches/ParallelEngine/HeuristicLab.Encodings.BinaryVectorEncoding 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Encodings.BinaryVectorEncoding 7568-7810 /branches/ProgrammableProblem/HeuristicLab.Encodings.BinaryVectorEncoding 11774-11959 /branches/QAPAlgorithms/HeuristicLab.Encodings.BinaryVectorEncoding 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Encodings.BinaryVectorEncoding 6828 /branches/RuntimeOptimizer/HeuristicLab.Encodings.BinaryVectorEncoding 8943-9078 /branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.BinaryVectorEncoding 7787-8333 /branches/SlaveShutdown/HeuristicLab.Encodings.BinaryVectorEncoding 8944-8956 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Encodings.BinaryVectorEncoding 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.Encodings.BinaryVectorEncoding 5370-5682 /branches/Trunk/HeuristicLab.Encodings.BinaryVectorEncoding 6829-6865 /branches/UnloadJobs/HeuristicLab.Encodings.BinaryVectorEncoding 9168-9215 /branches/VNS/HeuristicLab.Encodings.BinaryVectorEncoding 5594-5752 /branches/histogram/HeuristicLab.Encodings.BinaryVectorEncoding 5959-6341
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/gteufl/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Creators/RandomBinaryVectorCreator.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; 26 using HeuristicLab.Parameters; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 28 … … 32 34 [StorableClass] 33 35 public sealed class RandomBinaryVectorCreator : BinaryVectorCreator { 36 private const string TrueProbabilityParameterName = "TrueProbability"; 37 38 private IValueLookupParameter<DoubleValue> TrueProbabilityParameter { 39 get { return (IValueLookupParameter<DoubleValue>)Parameters[TrueProbabilityParameterName]; } 40 } 41 42 public DoubleValue TrueProbability { 43 get { return TrueProbabilityParameter.Value; } 44 set { TrueProbabilityParameter.Value = value; } 45 } 46 34 47 [StorableConstructor] 35 48 private RandomBinaryVectorCreator(bool deserializing) : base(deserializing) { } 36 49 private RandomBinaryVectorCreator(RandomBinaryVectorCreator original, Cloner cloner) : base(original, cloner) { } 37 public RandomBinaryVectorCreator() : base() { } 50 public override IDeepCloneable Clone(Cloner cloner) { return new RandomBinaryVectorCreator(this, cloner); } 51 public RandomBinaryVectorCreator() 52 : base() { 53 Parameters.Add(new ValueLookupParameter<DoubleValue>(TrueProbabilityParameterName, "Probability of true value", new DoubleValue(0.5))); 54 } 38 55 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new RandomBinaryVectorCreator(this, cloner); 56 [StorableHook(HookType.AfterDeserialization)] 57 private void AfterDeserialization() { 58 // BackwardsCompatibility3.3 59 #region Backwards compatible code, remove with 3.4 60 var defaultValue = 0.5; 61 const string parameterNameWithTypo = "TruePropability"; 62 if (Parameters.ContainsKey(parameterNameWithTypo) && Parameters[parameterNameWithTypo] is IValueParameter<DoubleValue>) { 63 defaultValue = ((IValueParameter<DoubleValue>)Parameters[parameterNameWithTypo]).Value.Value; 64 Parameters.Remove(parameterNameWithTypo); 65 } 66 if (!Parameters.ContainsKey(TrueProbabilityParameterName)) 67 Parameters.Add(new ValueLookupParameter<DoubleValue>(TrueProbabilityParameterName, "Probability of true value", new DoubleValue(defaultValue))); 68 #endregion 41 69 } 42 70 … … 46 74 /// <param name="random">The random number generator.</param> 47 75 /// <param name="length">The length of the binary vector.</param> 76 /// <param name="trueProbability">The propability for true to occur at a certain position in the binary vector</param> 48 77 /// <returns>The newly created binary vector.</returns> 49 public static BinaryVector Apply(IRandom random, int length) { 50 BinaryVector result = new BinaryVector(length, random); 78 public static BinaryVector Apply(IRandom random, int length, double trueProbability = 0.5) { 79 BinaryVector result; 80 81 //Backwards compatiblity code to ensure the same behavior for existing algorithm runs 82 //remove with HL 3.4 83 if (trueProbability.IsAlmost(0.5)) 84 result = new BinaryVector(length, random); 85 else { 86 var values = new bool[length]; 87 for (int i = 0; i < length; i++) 88 values[i] = random.NextDouble() < trueProbability; 89 result = new BinaryVector(values); 90 } 51 91 return result; 52 92 } 53 93 54 94 protected override BinaryVector Create(IRandom random, IntValue length) { 55 return Apply(random, length.Value); 95 if (TrueProbabilityParameter.ActualValue == null) throw new InvalidOperationException("RandomBinaryVectorCreator: Parameter " + TrueProbabilityParameter.ActualName + " could not be found."); 96 return Apply(random, length.Value, TrueProbabilityParameter.ActualValue.Value); 56 97 } 57 98 }
Note: See TracChangeset
for help on using the changeset viewer.