Changeset 6593 for branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSeachOperator.cs
- Timestamp:
- 07/25/11 18:28:10 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAPAlgorithms/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSeachOperator.cs
r6586 r6593 37 37 get { return (ILookupParameter<IntValue>)Parameters["Iterations"]; } 38 38 } 39 public ILookupParameter<IRandom> RandomParameter { 40 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 41 } 39 42 public ILookupParameter<Permutation> PermutationParameter { 40 43 get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } … … 61 64 get { return (ILookupParameter<Swap2Move>)Parameters["LastMove"]; } 62 65 } 66 public ILookupParameter<BoolValue> UseNewTabuTenureAdaptionSchemeParameter { 67 get { return (ILookupParameter<BoolValue>)Parameters["UseNewTabuTenureAdaptionScheme"]; } 68 } 63 69 public ILookupParameter<ResultCollection> ResultsParameter { 64 70 get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; } 65 71 } 66 72 67 public ILookupParameter<IRandom> RandomParameter {68 get { return (ILookupParameter<IRandom>)Parameters["Random"]; }69 }70 73 public IValueLookupParameter<IntValue> MaximumIterationsParameter { 71 74 get { return (IValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; } … … 101 104 Parameters.Add(new LookupParameter<DoubleValue>("BestQuality", "The best quality value.")); 102 105 Parameters.Add(new LookupParameter<Swap2Move>("LastMove", "The last move that was applied.")); 106 Parameters.Add(new LookupParameter<BoolValue>("UseNewTabuTenureAdaptionScheme", "True if the new tabu tenure adaption should be used or false otherwise.")); 103 107 Parameters.Add(new LookupParameter<ResultCollection>("Results", "Collection that houses the results of the algorithm.")); 104 108 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The number of iterations that the algorithm should run.")); … … 151 155 || shortTermMemory[move.Index2, solution[move.Index1]] < iteration; 152 156 153 bool aspired = shortTermMemory[move.Index1, solution[move.Index2]] < iteration - alternativeAspirationTenure154 || shortTermMemory[move.Index2, solution[move.Index1]] < iteration - alternativeAspirationTenure155 157 bool aspired = (shortTermMemory[move.Index1, solution[move.Index2]] < iteration - alternativeAspirationTenure 158 && shortTermMemory[move.Index2, solution[move.Index1]] < iteration - alternativeAspirationTenure) 159 || quality.Value + moveQuality < bestQuality.Value; 156 160 157 161 if ((aspired && !already_aspired) // the first alternative move is aspired … … 169 173 if (!results.ContainsKey("AspiredMoves")) { 170 174 aspiredMoves = new IntValue(already_aspired ? 1 : 0); 171 results.Add(new Result("AspiredMoves", aspiredMoves));175 results.Add(new Result("AspiredMoves", "Counts the number of moves that were selected because of the aspiration criteria.", aspiredMoves)); 172 176 } else if (already_aspired) { 173 177 aspiredMoves = (IntValue)results["AspiredMoves"].Value; … … 180 184 if (bestMove == null) return base.Apply(); 181 185 182 shortTermMemory[bestMove.Index1, solution[bestMove.Index1]] = iteration + random.Next(minTenure, maxTenure); 183 shortTermMemory[bestMove.Index2, solution[bestMove.Index2]] = iteration + random.Next(minTenure, maxTenure); 186 bool useNewAdaptionScheme = UseNewTabuTenureAdaptionSchemeParameter.ActualValue.Value; 187 if (useNewAdaptionScheme) { 188 double r = random.NextDouble(); 189 shortTermMemory[bestMove.Index1, solution[bestMove.Index1]] = (int)(iteration + r * r * r * maxTenure); 190 r = random.NextDouble(); 191 shortTermMemory[bestMove.Index2, solution[bestMove.Index2]] = (int)(iteration + r * r * r * maxTenure); 192 } else { 193 shortTermMemory[bestMove.Index1, solution[bestMove.Index1]] = iteration + random.Next(minTenure, maxTenure); 194 shortTermMemory[bestMove.Index2, solution[bestMove.Index2]] = iteration + random.Next(minTenure, maxTenure); 195 } 184 196 Swap2Manipulator.Apply(solution, bestMove.Index1, bestMove.Index2); 185 197 quality.Value += bestMoveQuality;
Note: See TracChangeset
for help on using the changeset viewer.