Changeset 12810
- Timestamp:
- 07/30/15 14:56:55 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSeachOperator.cs
r12012 r12810 90 90 private ILookupParameter<BoolValue> AllMovesTabuParameter { 91 91 get { return (ILookupParameter<BoolValue>)Parameters["AllMovesTabu"]; } 92 } 93 94 public ILookupParameter<IntValue> EvaluatedMovesParameter { 95 get { return (ILookupParameter<IntValue>)Parameters["EvaluatedMoves"]; } 92 96 } 93 97 #endregion … … 117 121 Parameters.Add(new ValueLookupParameter<IntValue>("AlternativeAspirationTenure", "The time t that a move will be remembered for the alternative aspiration condition.")); 118 122 Parameters.Add(new LookupParameter<BoolValue>("AllMovesTabu", "Indicates that all moves are tabu.")); 123 Parameters.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of move evaluations made.")); 119 124 } 120 125 … … 129 134 if (!Parameters.ContainsKey("AllMovesTabu")) { 130 135 Parameters.Add(new LookupParameter<BoolValue>("AllMovesTabu", "Indicates that all moves are tabu.")); 136 } 137 if (!Parameters.ContainsKey("EvaluatedMoves")) { 138 Parameters.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of move evaluations made.")); 131 139 } 132 140 #endregion … … 163 171 bool already_aspired = false; 164 172 173 var evaluatedMoves = 0; 165 174 foreach (Swap2Move move in ExhaustiveSwap2MoveGenerator.Generate(solution)) { 166 175 double moveQuality; 167 if (lastMove == null) 176 if (lastMove == null) { 168 177 moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, weights, distances); 169 else if (allMovesTabu) moveQuality = moveQualityMatrix[move.Index1, move.Index2]; 170 else moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, moveQualityMatrix[move.Index1, move.Index2], weights, distances, lastMove); 178 evaluatedMoves++; 179 } else if (allMovesTabu) moveQuality = moveQualityMatrix[move.Index1, move.Index2]; 180 else { 181 moveQuality = QAPSwap2MoveEvaluator.Apply(solution, move, moveQualityMatrix[move.Index1, move.Index2], weights, distances, lastMove); 182 evaluatedMoves++; 183 } 171 184 172 185 moveQualityMatrix[move.Index1, move.Index2] = moveQuality; … … 200 213 } 201 214 } 215 216 EvaluatedMovesParameter.ActualValue.Value += evaluatedMoves; 202 217 203 218 allMovesTabu = bestMove == null; -
trunk/sources/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSearch.cs
r12504 r12810 168 168 VariableCreator variableCreator = new VariableCreator(); 169 169 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0))); 170 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0))); 171 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedMoves", new IntValue(0))); 170 172 171 173 ResultsCollector resultsCollector = new ResultsCollector(); 172 174 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations", "The actual iteration.")); 175 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of full solution evaluations.")); 176 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedMoves", "The number of move evaluations.")); 173 177 174 178 solutionsCreator = new SolutionsCreator(); 175 179 solutionsCreator.NumberOfSolutions = new IntValue(1); 180 181 IntCounter counter = new IntCounter(); 182 counter.ValueParameter.ActualName = "EvaluatedSolutions"; 183 counter.Increment = new IntValue(1); 176 184 177 185 Placeholder analyzer = new Placeholder(); … … 194 202 mainOperator.ShortTermMemoryParameter.ActualName = "ShortTermMemory"; 195 203 mainOperator.UseAlternativeAspirationParameter.ActualName = UseAlternativeAspirationParameter.Name; 204 mainOperator.EvaluatedMovesParameter.ActualName = "EvaluatedMoves"; 196 205 197 206 ConditionalBranch qualityStopBranch = new ConditionalBranch(); … … 226 235 variableCreator.Successor = resultsCollector; 227 236 resultsCollector.Successor = solutionsCreator; 228 solutionsCreator.Successor = analyzer; 237 solutionsCreator.Successor = counter; 238 counter.Successor = analyzer; 229 239 analyzer.Successor = ussp; 230 240 ussp.Operator = mainOperator;
Note: See TracChangeset
for help on using the changeset viewer.