Changeset 9242 for branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable
- Timestamp:
- 02/25/13 12:37:18 (12 years ago)
- Location:
- branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3 ¶
- Property svn:ignore
-
TabularUnified
old new 1 1 obj 2 Plugin.cs
-
- Property svn:ignore
-
TabularUnified 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 } -
TabularUnified branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IVariable.cs ¶
r9226 r9242 30 30 31 31 IVariable GetEmptyCopy(); 32 //GetSetCopy is used instead of Clone, so that data doesn't have to be duplicated 32 33 IVariable GetSetCopy(); 33 34 -
TabularUnified branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/IntVariable.cs ¶
r9226 r9242 149 149 } 150 150 151 public new IntVariable CrossParentsAtPosition(IVariable parent2, int pos) {151 public override IVariable CrossParentsAtPosition(IVariable parent2, int pos) { 152 152 var parent2Cast = parent2 as IntVariable; 153 153 if (parent2Cast == null) { throw new ArgumentException("Argument is not of the correct type."); } 154 154 if (pos != 0) { throw new ArgumentOutOfRangeException(); } 155 return (IntVariable) this.GetSetCopy();155 return (IntVariable)parent2.GetSetCopy(); 156 156 } 157 157 -
TabularUnified branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/StringVariable.cs ¶
r9226 r9242 198 198 } 199 199 200 public new StringVariable CrossParentsAtPosition(IVariable parent2, int pos) {200 public override IVariable CrossParentsAtPosition(IVariable parent2, int pos) { 201 201 var parent2Cast = parent2 as StringVariable; 202 202 if (parent2Cast == null) { throw new ArgumentException("Argument is not of the correct type."); } 203 203 if (pos != 0) { throw new ArgumentOutOfRangeException(); } 204 return (StringVariable) this.GetSetCopy();204 return (StringVariable)parent2.GetSetCopy(); 205 205 } 206 206 -
TabularUnified branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/Variable.cs ¶
r9226 r9242 68 68 public abstract bool IsGreaterThanOrEquallyGeneral(IVariable target); 69 69 70 public virtual IVariable CrossParentsAtPosition(IVariable parent2, int pos) { throw new NotSupportedException("This method is not supported."); }70 public abstract IVariable CrossParentsAtPosition(IVariable parent2, int pos); 71 71 72 72 public abstract void Manipulate(IRandom random, string stringValue, int pos);
Note: See TracChangeset
for help on using the changeset viewer.