Changeset 7040 for trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSeachOperator.cs
- Timestamp:
- 11/22/11 14:54:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSeachOperator.cs
r6628 r7040 31 31 namespace HeuristicLab.Problems.QuadraticAssignment.Algorithms { 32 32 [Item("RobustTabooSearchOperator", "Performs an iteration of the robust taboo search algorithm as descrbied in Taillard 1991.")] 33 [StorableClass] 33 34 public sealed class RobustTabooSeachOperator : SingleSuccessorOperator, IIterationBasedOperator, IStochasticOperator { 34 35 … … 85 86 public IValueLookupParameter<IntValue> AlternativeAspirationTenureParameter { 86 87 get { return (IValueLookupParameter<IntValue>)Parameters["AlternativeAspirationTenure"]; } 88 } 89 90 private ILookupParameter<BoolValue> AllMovesTabuParameter { 91 get { return (ILookupParameter<BoolValue>)Parameters["AllMovesTabu"]; } 87 92 } 88 93 #endregion … … 111 116 Parameters.Add(new ValueLookupParameter<BoolValue>("UseAlternativeAspiration", "True if the alternative aspiration condition should be used that takes moves that have not been made for some time above others.")); 112 117 Parameters.Add(new ValueLookupParameter<IntValue>("AlternativeAspirationTenure", "The time t that a move will be remembered for the alternative aspiration condition.")); 118 Parameters.Add(new LookupParameter<BoolValue>("AllMovesTabu", "Indicates that all moves are tabu.")); 113 119 } 114 120 115 121 public override IDeepCloneable Clone(Cloner cloner) { 116 122 return new RobustTabooSeachOperator(this, cloner); 123 } 124 125 [StorableHook(HookType.AfterDeserialization)] 126 private void AfterDeserialization() { 127 // BackwardsCompatibility3.3 128 #region Backwards compatible code, remove with 3.4 129 if (!Parameters.ContainsKey("AllMovesTabu")) { 130 Parameters.Add(new LookupParameter<BoolValue>("AllMovesTabu", "Indicates that all moves are tabu.")); 131 } 132 #endregion 117 133 } 118 134 … … 131 147 bestQuality = BestQualityParameter.ActualValue; 132 148 } 149 bool allMovesTabu = false; 150 if (AllMovesTabuParameter.ActualValue == null) 151 AllMovesTabuParameter.ActualValue = new BoolValue(false); 152 else allMovesTabu = AllMovesTabuParameter.ActualValue.Value; 133 153 134 154 int minTenure = MinimumTabuTenureParameter.ActualValue.Value; … … 147 167 if (lastMove == null) 148 168 moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, weights, distances); 169 else if (allMovesTabu) moveQuality = moveQualityMatrix[move.Index1, move.Index2]; 149 170 else moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, moveQualityMatrix[move.Index1, move.Index2], weights, distances, lastMove); 150 171 … … 180 201 } 181 202 182 LastMoveParameter.ActualValue = bestMove; 183 184 if (bestMove == null) return base.Apply(); 203 allMovesTabu = bestMove == null; 204 if (!allMovesTabu) 205 LastMoveParameter.ActualValue = bestMove; 206 AllMovesTabuParameter.ActualValue.Value = allMovesTabu; 207 208 if (allMovesTabu) return base.Apply(); 185 209 186 210 bool useNewAdaptionScheme = UseNewTabuTenureAdaptionSchemeParameter.ActualValue.Value;
Note: See TracChangeset
for help on using the changeset viewer.