Changeset 9242 for branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs
- Timestamp:
- 02/25/13 12:37:18 (11 years ago)
- Location:
- branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3
- Property svn:ignore
-
old new 1 1 obj 2 Plugin.cs
-
- Property svn:ignore
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs
r9226 r9242 66 66 min = original.min; 67 67 max = original.max; 68 currentSpread = original.currentSpread; 69 currentCenter = original.currentCenter; 68 70 } 69 71 public DoubleVariable() : base() { } … … 89 91 90 92 public override string ToString() { 91 return (currentCenter - current Center) + " - " + (currentCenter + currentSpread);93 return (currentCenter - currentSpread) + " - " + (currentCenter + currentSpread); 92 94 } 93 95 … … 97 99 98 100 public override bool Match(double target) { 99 return currentCenter - currentSpread < target && target <currentCenter + currentSpread;101 return currentCenter - currentSpread <= target && target <= currentCenter + currentSpread; 100 102 } 101 103 … … 128 130 var targetCast = target as DoubleVariable; 129 131 if (targetCast == null) { return false; } 130 if (variableName != targetCast.variableName || currentCenter != targetCast.currentCenter131 || currentSpread != targetCast.currentSpread || max != targetCast.max132 || min != targetCast.min) { return false; }132 if (variableName != targetCast.variableName || currentCenter.IsAlmost(targetCast.currentCenter) 133 || currentSpread.IsAlmost(targetCast.currentSpread) || max.IsAlmost(targetCast.max) 134 || min.IsAlmost(targetCast.min)) { return false; } 133 135 134 136 return true; … … 149 151 } 150 152 151 public new DoubleVariable CrossParentsAtPosition(IVariable parent2, int pos) {152 varparent2Cast = parent2 as DoubleVariable;153 public override IVariable CrossParentsAtPosition(IVariable parent2, int pos) { 154 DoubleVariable parent2Cast = parent2 as DoubleVariable; 153 155 if (parent2Cast == null) { throw new ArgumentException("Argument is not of the correct type."); } 154 156 if (pos > 1 || pos < 0) { throw new ArgumentOutOfRangeException(); } 155 157 DoubleVariable crossed = (DoubleVariable)this.GetSetCopy(); 156 if (pos == 0) {158 if (pos == 1) { 157 159 crossed.CurrentSpread = parent2Cast.CurrentSpread; 158 160 } … … 180 182 181 183 public override void Cover(IRandom random, string stringValue, double changeSymbolProbability) { 182 Cover (random, stringValue, 50);184 CoverWithSpreadPercentage(random, stringValue, changeSymbolProbability); 183 185 } 184 186 … … 186 188 currentCenter = double.Parse(stringValue); 187 189 double delta = max - min; 188 currentSpread = random.NextDouble() * (delta * (spreadPercentage / 100));190 currentSpread = random.NextDouble() * (delta * spreadPercentage); 189 191 } 190 192 }
Note: See TracChangeset
for help on using the changeset viewer.