Changeset 5522 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding
- Timestamp:
- 02/21/11 00:46:33 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
r5361 r5522 493 493 } 494 494 } 495 496 public double CalculateSimilarity(IOptimizable optimizable) { 497 var other = (IParameterConfiguration)optimizable; 498 if (this.ActualValueConfigurationIndex == other.ActualValueConfigurationIndex) { 499 return this.ValueConfigurations[this.ActualValueConfigurationIndex].CalculateSimilarity(other.ValueConfigurations[other.ActualValueConfigurationIndex]); 500 } else { 501 return 0.0; 502 } 503 } 495 504 } 496 505 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/ConstrainedValue.cs
r5231 r5522 86 86 #endregion 87 87 88 void value_ToStringChanged(object sender, EventArgs e) {88 private void value_ToStringChanged(object sender, EventArgs e) { 89 89 OnToStringChanged(); 90 90 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/DoubleValueRange.cs
r5337 r5522 48 48 return solutions; 49 49 } 50 51 protected override double CalculateSimilarityValue(DoubleValue a, DoubleValue b) { 52 double range = UpperBound.Value - LowerBound.Value; 53 double diff = Math.Abs(a.Value - b.Value); 54 return Math.Max(0, (range - (diff*2)) / range); 55 } 50 56 } 51 57 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/IntValueRange.cs
r5337 r5522 47 47 return solutions; 48 48 } 49 50 protected override double CalculateSimilarityValue(IntValue a, IntValue b) { 51 double range = UpperBound.Value - LowerBound.Value; 52 double diff = Math.Abs(a.Value - b.Value); 53 return Math.Max(0, (range - (diff * 2)) / range); 54 } 49 55 } 50 56 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/PercentValueRange.cs
r5337 r5522 52 52 return solutions; 53 53 } 54 55 protected override double CalculateSimilarityValue(PercentValue a, PercentValue b) { 56 double range = UpperBound.Value - LowerBound.Value; 57 double diff = Math.Abs(a.Value - b.Value); 58 return Math.Max(0, (range - (diff * 2)) / range); 59 } 54 60 } 55 61 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/RangeConstraints/Range.cs
r5144 r5522 208 208 209 209 protected abstract T GetRandomSample(IRandom random); 210 210 211 IItem IRange.GetRandomValue(IRandom random) { 211 212 return GetRandomValue(random); … … 216 217 return GetCombinations().Cast<IItem>().ToArray(); 217 218 } 219 220 public virtual double CalculateSimilarity(IItem a, IItem b) { 221 return CalculateSimilarityValue((T)a, (T)b); 222 } 223 224 protected abstract double CalculateSimilarityValue(T a, T b); 218 225 } 219 226 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs
r5361 r5522 326 326 return list; 327 327 } 328 329 public double CalculateSimilarity(IOptimizable optimizable) { 330 var other = (IValueConfiguration)optimizable; 331 if (rangeConstraint != null) { 332 return this.RangeConstraint.CalculateSimilarity(this.ActualValue.Value, other.ActualValue.Value); 333 } else { 334 double sum = 0; 335 int count = 0; 336 for (int i = 0; i < ParameterConfigurations.Count; i++) { 337 if (this.ParameterConfigurations.ElementAt(i).Optimize) { 338 sum += this.ParameterConfigurations.ElementAt(i).CalculateSimilarity(other.ParameterConfigurations.ElementAt(i)); 339 count++; 340 } 341 } 342 return count == 0 ? 1.0 : sum / (double)count; 343 } 344 } 328 345 } 329 346 }
Note: See TracChangeset
for help on using the changeset viewer.