Changeset 7505 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluators
- Timestamp:
- 02/22/12 22:43:09 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluators/GQAPNMoveEvaluator.cs
r7419 r7505 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using System.Linq; 24 23 using HeuristicLab.Common; … … 32 31 33 32 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { 34 [Item(" GQAPNMoveEvaluator", "Evaluates an n-move.")]33 [Item("N-Move Evaluator", "Evaluates an N-Move.")] 35 34 [StorableClass] 36 35 public class GQAPNMoveEvaluator : SingleSuccessorOperator, IGQAPNMoveEvaluator, IAssignmentAwareGQAPOperator, … … 159 158 var slack = (DoubleArray)capacities.Clone(); 160 159 var oldSlack = (DoubleArray)slack.Clone(); 161 Dictionary<int, int> moving = new Dictionary<int, int>(); 162 for (int i = 0; i < moves; i++) moving.Add(move.Equipments[i], move.Locations[i]); 163 164 for (int i = 0; i < moves; i++) { 165 int equip = move.Equipments[i]; 166 int newLoc = move.Locations[i]; 160 bool first = true; 161 foreach (var kvp in move.NewAssignments) { 162 int equip = kvp.Key; 163 int newLoc = kvp.Value; 167 164 moveInstallationQuality -= installationCosts[equip, assignment[equip]]; 168 165 moveInstallationQuality += installationCosts[equip, newLoc]; 169 166 for (int j = 0; j < assignment.Length; j++) { 170 if (!mov ing.ContainsKey(j)) {167 if (!move.NewAssignments.ContainsKey(j)) { 171 168 moveFlowDistanceQuality += weights[equip, j] * distances[newLoc, assignment[j]]; 172 169 moveFlowDistanceQuality -= weights[equip, j] * distances[assignment[equip], assignment[j]]; 173 170 moveFlowDistanceQuality += weights[j, equip] * distances[assignment[j], newLoc]; 174 171 moveFlowDistanceQuality -= weights[j, equip] * distances[assignment[j], assignment[equip]]; 175 if ( i == 0) { // only once for each untouched equipment deduct the demand from the capacity172 if (first) { // only once for each untouched equipment deduct the demand from the capacity 176 173 slack[assignment[j]] -= demands[j]; 177 174 oldSlack[assignment[j]] -= demands[j]; 178 175 } 179 176 } else { 180 moveFlowDistanceQuality += weights[equip, j] * distances[newLoc, mov ing[j]];177 moveFlowDistanceQuality += weights[equip, j] * distances[newLoc, move.NewAssignments[j]]; 181 178 moveFlowDistanceQuality -= weights[equip, j] * distances[assignment[equip], assignment[j]]; 182 179 } 183 180 } 181 first = false; 184 182 slack[newLoc] -= demands[equip]; 185 183 oldSlack[assignment[equip]] -= demands[equip];
Note: See TracChangeset
for help on using the changeset viewer.