- Timestamp:
- 05/08/13 14:12:00 (12 years ago)
- Location:
- branches/LearningClassifierSystems
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems
-
Property
svn:mergeinfo
set to
/trunk/sources/HeuristicLab.Core merged eligible
-
Property
svn:mergeinfo
set to
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Creators/UniformRandomVariableVectorCreator.cs
r9226 r9467 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 25 using HeuristicLab.Parameters; 24 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 27 … … 30 32 31 33 #region Parameter Properties 34 public ILookupParameter<PercentValue> ChangeSymbolProbabilityParameter { 35 get { return (ILookupParameter<PercentValue>)Parameters["ChangeSymbolProbability"]; } 36 } 32 37 #endregion 33 38 … … 39 44 public UniformRandomVariableVectorCreator() 40 45 : base() { 46 Parameters.Add(new LookupParameter<PercentValue>("ChangeSymbolProbability")); 41 47 } 42 48 public override IDeepCloneable Clone(Cloner cloner) { … … 46 52 protected override VariableVector Create(IRandom random, VariableVector sampleVariableVector, double spreadPercentage) { 47 53 var result = sampleVariableVector.GetEmptyCopy(); 48 result.Randomize(random, spreadPercentage);54 result.Randomize(random, ChangeSymbolProbabilityParameter.ActualValue.Value, spreadPercentage); 49 55 return result; 50 56 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs
r9392 r9467 112 112 } 113 113 114 // Important! If this mehtod is called instead of the more concrete "Randomize(IRandom random, double spreadPercentage)" 115 // spread percentage is 50% 116 public override void Randomize(IRandom random) { 117 Randomize(random, 50); 114 // this method is not implemented on purpose, because it may lead to confusion or errors if the wrong parameter would be used (changeSymbolProbability instead of spreadPercentage) 115 public override void Randomize(IRandom random, double changeSymbolProbability) { 116 throw new NotImplementedException("The method DoubleVariable.Randomize(IRandom, double) should not be used. Use DoubleVariable.Randomize(IRandom, double, double) instead."); 118 117 } 119 118 120 public void Randomize(IRandom random, double spreadPercentage) { 119 // changeSymbolProbability is not used on purpose 120 public void Randomize(IRandom random, double changeSymbolProbability, double spreadPercentage) { 121 121 if (spreadPercentage < 0 || spreadPercentage > 100) { 122 122 throw new ArgumentException("Spread percentage has to be between 0 and 100."); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IActionVariable.cs
r9226 r9467 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Core; 23 24 24 25 namespace HeuristicLab.Encodings.VariableVector { … … 30 31 void SetTo(string value); 31 32 IEnumerable<string> GetAllPossibleActions(); 33 34 void RandomizeAction(IRandom random); 32 35 } 33 36 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IVariable.cs
r9242 r9467 33 33 IVariable GetSetCopy(); 34 34 35 void Randomize(IRandom random );35 void Randomize(IRandom random, double changeSymbolProbability); 36 36 bool MatchInput(string target); 37 37 bool MatchVariable(IVariable target); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IntVariable.cs
r9392 r9467 122 122 } 123 123 124 public override void Randomize(IRandom random) { 124 public void RandomizeAction(IRandom random) { 125 int index = random.Next(possibleFeatures.Count()); 126 currentValue = possibleFeatures.ElementAt(index); 127 } 128 129 public override void Randomize(IRandom random, double changeSymbolProbability) { 130 Wildcard = random.NextDouble() < changeSymbolProbability; 125 131 int index = random.Next(possibleFeatures.Count()); 126 132 currentValue = possibleFeatures.ElementAt(index); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/StringVariable.cs
r9392 r9467 167 167 } 168 168 169 public override void Randomize(IRandom random) { 169 public void RandomizeAction(IRandom random) { 170 int index = random.Next(possibleFeatures.Count()); 171 currentValue = possibleFeatures.ElementAt(index); 172 } 173 174 public override void Randomize(IRandom random, double changeSymbolProbability) { 175 Wildcard = random.NextDouble() < changeSymbolProbability; 170 176 int index = random.Next(possibleFeatures.Count()); 171 177 currentValue = possibleFeatures.ElementAt(index); -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/Variable.cs
r9242 r9467 55 55 public abstract IVariable GetSetCopy(); 56 56 57 public abstract void Randomize(IRandom random );57 public abstract void Randomize(IRandom random, double changeSymbolProbability); 58 58 59 59 public virtual bool MatchVariable(IVariable target) { throw new NotSupportedException("This method is not supported by this kind of Variable."); } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVector.cs
r9242 r9467 86 86 } 87 87 88 public void Randomize(IRandom random, double spreadPercentage) {89 condition.Randomize(random, spreadPercentage);88 public void Randomize(IRandom random, double changeSymbolProbability, double spreadPercentage) { 89 condition.Randomize(random, changeSymbolProbability, spreadPercentage); 90 90 action.Randomize(random); 91 91 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorAction.cs
r9411 r9467 113 113 public void Randomize(IRandom random) { 114 114 foreach (var variable in VariableDictionary.Values) { 115 variable.Randomize (random);115 variable.RandomizeAction(random); 116 116 } 117 117 } -
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/VariableVectorCondition.cs
r9392 r9467 97 97 } 98 98 99 public void Randomize(IRandom random, double spreadPercentage) {99 public void Randomize(IRandom random, double changeSymbolProbability, double spreadPercentage) { 100 100 foreach (var variable in VariableDictionary.Values) { 101 101 if (variable is DoubleVariable) { 102 ((DoubleVariable)variable).Randomize(random, spreadPercentage);102 ((DoubleVariable)variable).Randomize(random, changeSymbolProbability, spreadPercentage); 103 103 } else { 104 variable.Randomize(random );104 variable.Randomize(random, changeSymbolProbability); 105 105 } 106 106 }
Note: See TracChangeset
for help on using the changeset viewer.