Changeset 9204 for branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs
- Timestamp:
- 02/04/13 16:16:38 (12 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
set to
obj
-
Property
svn:ignore
set to
-
branches/LearningClassifierSystems/HeuristicLab.Encodings.VariableVector/3.3/Variable/DoubleVariable.cs
r9194 r9204 137 137 public override double GetGenerality() { 138 138 double delta = max - min; 139 double interval Width = 2 * currentSpread;140 double generality = interval Width / delta;139 double intervalInBoundsWidth = Math.Min(max, currentCenter + currentSpread) - Math.Max(min, currentCenter - currentSpread); 140 double generality = intervalInBoundsWidth / delta; 141 141 return generality > 1 ? 1 : generality; 142 142 } … … 159 159 return crossed; 160 160 } 161 162 public override void Manipulate(IRandom random, string stringValue, int pos) { 163 if (pos > 1 || pos < 0) { throw new ArgumentOutOfRangeException(); } 164 Manipulate(random, pos, 10); 165 } 166 167 public void Manipulate(IRandom random, int pos, double percentage) { 168 if (pos > 1 || pos < 0) { throw new ArgumentOutOfRangeException(); } 169 double delta = max - min; 170 double maxChange = delta * (percentage / 100); 171 double actualChange = (random.NextDouble() * maxChange * 2) - maxChange; 172 if (pos == 0) { 173 currentCenter += actualChange; 174 } else if (pos == 1) { 175 currentSpread += actualChange; 176 //otherwise the interval could be corrupt and no input could match the rule. 177 currentSpread = currentSpread > 0 ? currentSpread : 0; 178 } 179 } 180 181 public override void Cover(IRandom random, string stringValue, double changeSymbolProbability) { 182 Cover(random, stringValue, 50); 183 } 184 185 public void CoverWithSpreadPercentage(IRandom random, string stringValue, double spreadPercentage) { 186 currentCenter = double.Parse(stringValue); 187 double delta = max - min; 188 currentSpread = random.NextDouble() * (delta * (spreadPercentage / 100)); 189 } 161 190 } 162 191 }
Note: See TracChangeset
for help on using the changeset viewer.