- Timestamp:
- 03/11/10 02:23:25 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.TS/3.3/TabuSelector.cs
r2994 r2997 40 40 public class TabuSelector : Selector { 41 41 /// <summary> 42 /// The quality of the current solution.43 /// </summary>44 public LookupParameter<DoubleData> QualityParameter {45 get { return (LookupParameter<DoubleData>)Parameters["Quality"]; }46 }47 /// <summary>48 42 /// The best found quality so far. 49 43 /// </summary> … … 76 70 } 77 71 72 public IntData NumberOfSelectedSubScopes { 73 set { NumberOfSelectedSubScopesParameter.Value = value; } 74 } 75 78 76 /// <summary> 79 77 /// Initializes a new intsance with 6 parameters (<c>Quality</c>, <c>BestQuality</c>, … … 82 80 public TabuSelector() 83 81 : base() { 84 Parameters.Add(new LookupParameter<DoubleData>("Quality", "The quality of the current solution."));85 82 Parameters.Add(new LookupParameter<DoubleData>("BestQuality", "The best found quality so far.")); 86 83 Parameters.Add(new ValueLookupParameter<BoolData>("Aspiration", "Whether the default aspiration criterion should be used or not. The default aspiration criterion accepts a tabu move if it results in a better solution than the best solution found so far.", new BoolData(true))); … … 101 98 bool maximization = MaximizationParameter.ActualValue.Value; 102 99 double bestQuality = BestQualityParameter.ActualValue.Value; 103 double quality = QualityParameter.ActualValue.Value;104 100 ItemArray<DoubleData> moveQualities = MoveQualityParameter.ActualValue; 105 101 ItemArray<BoolData> moveTabus = MoveTabuParameter.ActualValue; … … 110 106 List<int> scopesToRemove = new List<int>(); 111 107 for (int i = 0; i < scopes.Count; i++) { 112 if (count > 0 && (!moveTabus[i].Value || aspiration && 113 (maximization && moveQualities[i].Value + quality > bestQuality 114 || !maximization && moveQualities[i].Value + quality < bestQuality))) { 108 if (count > 0 && (!moveTabus[i].Value 109 || aspiration && IsBetter(maximization, moveQualities[i].Value, bestQuality))) { 115 110 scopesToRemove.Add(i); 116 111 if (copy) selected[selected.Length - count] = (IScope)scopes[i].Clone(); … … 133 128 return selected; 134 129 } 130 131 private bool IsBetter(bool maximization, double moveQuality, double bestQuality) { 132 return (maximization && moveQuality > bestQuality || !maximization && moveQuality < bestQuality); 133 } 135 134 } 136 135 }
Note: See TracChangeset
for help on using the changeset viewer.