Changeset 3132
- Timestamp:
- 03/19/10 18:21:24 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearchMainLoop.cs
r3104 r3132 162 162 bestAverageWorstMoveQualityCalculator.QualityParameter.ActualName = "MoveQuality"; 163 163 bestAverageWorstMoveQualityCalculator.WorstQualityParameter.ActualName = "Worst Move Quality"; 164 165 tabuSelector.NumberOfSelectedSubScopes = new IntValue(1);166 164 167 165 moveMakingProcessor.Name = "MoveMaking processor (UniformSequentialSubScopesProcessor)"; -
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSelector.cs
r3100 r3132 69 69 get { return (ILookupParameter<ItemArray<BoolValue>>)Parameters["MoveTabu"]; } 70 70 } 71 72 public IntValue NumberOfSelectedSubScopes { 73 set { NumberOfSelectedSubScopesParameter.Value = value; } 71 public IValueLookupParameter<BoolValue> CopySelectedParameter { 72 get { return (IValueLookupParameter<BoolValue>)Parameters["CopySelected"]; } 74 73 } 75 74 … … 85 84 Parameters.Add(new SubScopesLookupParameter<DoubleValue>("MoveQuality", "The quality of the move.")); 86 85 Parameters.Add(new SubScopesLookupParameter<BoolValue>("MoveTabu", "The tabu status of the move.")); 86 Parameters.Add(new ValueLookupParameter<BoolValue>("CopySelected", "True if the selected move should be copied.")); 87 87 } 88 88 … … 94 94 /// <returns>The selected scopes.</returns> 95 95 protected override IScope[] Select(List<IScope> scopes) { 96 int count = NumberOfSelectedSubScopesParameter.ActualValue.Value;97 96 bool copy = CopySelectedParameter.Value.Value; 98 97 bool aspiration = AspirationParameter.ActualValue.Value; … … 102 101 ItemArray<BoolValue> moveTabus = MoveTabuParameter.ActualValue; 103 102 104 IScope[] selected = new IScope[ count];103 IScope[] selected = new IScope[1]; 105 104 106 105 // remember scopes that should be removed 107 106 List<int> scopesToRemove = new List<int>(); 108 107 for (int i = 0; i < scopes.Count; i++) { 109 if ( count > 0 && (!moveTabus[i].Value110 || aspiration && IsBetter(maximization, moveQualities[i].Value, bestQuality)) ){108 if (!moveTabus[i].Value 109 || aspiration && IsBetter(maximization, moveQualities[i].Value, bestQuality)) { 111 110 scopesToRemove.Add(i); 112 if (copy) selected[selected.Length - count] = (IScope)scopes[i].Clone(); 113 else selected[selected.Length - count] = scopes[i]; 114 count--; 115 if (count == 0) break; 111 if (copy) selected[0] = (IScope)scopes[i].Clone(); 112 else selected[0] = scopes[i]; 113 break; 116 114 } 117 115 } 118 116 119 if ( count > 0) throw new InvalidOperationException("TabuSelector: The neighborhood contained no or too little moves that are not tabu.");117 if (selected[0] == null) throw new InvalidOperationException("TabuSelector: The neighborhood contained no or too little moves that are not tabu."); 120 118 121 119 // remove from last to first so that the stored indices remain the same
Note: See TracChangeset
for help on using the changeset viewer.