Changeset 7425
 Timestamp:
 01/27/12 18:41:01 (12 years ago)
 Location:
 branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3
 Files:

 1 added
 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/GQAPPathRelinking.cs
r7423 r7425 29 29 using HeuristicLab.Parameters; 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common; 31 32 32 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment .Operators{33 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { 33 34 [Item("GQAPPathRelinking", "Operator that performs path relinking between two solutions. It is described in Mateus, G., Resende, M., and Silva, R. 2011. GRASP with pathrelinking for the generalized quadratic assignment problem. Journal of Heuristics 17, Springer Netherlands, pp. 527565.")] 34 35 [StorableClass] … … 110 111 var target = parents[1]; 111 112 113 var nu = 1.0; 112 114 var pi_prime = (IntegerVector)source.Clone(); 113 115 var fix = new HashSet<int>(); 114 116 var nonFix = new HashSet<int>(Enumerable.Range(0, demands.Length)); 115 var phi = GQAPIntegerVectorProximityCalculator.GetDifference(pi_prime, target);117 var phi = new HashSet<int>(GQAPIntegerVectorProximityCalculator.GetDifference(pi_prime, target)); 116 118 117 119 while (phi.Any()) { 118 var B = new HashSet< IntegerVector>();120 var B = new HashSet<GQAPSolution>(new GQAPSolutionStructuralEqualityComparer()); 119 121 foreach (var v in phi) { 120 122 pi_prime[v] = target[v]; … … 124 126 GQAPEvaluator.Evaluate(pi2, weights, distances, installationCosts, demands, capacities, 125 127 out flowDistanceQuality, out installationQuality, out overbookedCapacity); 128 129 if (overbookedCapacity <= 0.0) { 130 var quality = GQAPEvaluator.GetCombinedQuality(flowDistanceQuality, installationQuality, overbookedCapacity, 131 transportationCosts.Value, overbookedCapacityPenalty.Value); 132 var solution = new GQAPSolution(pi2, new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity)); 133 if (B.Count >= nu * phi.Count) { 134 if (!B.Contains(solution) && quality <= B.Select(x => x.Quality.Value).Max()) { 135 // TODO: replace most similar element in B with worse cost 136 } 137 } else if (!B.Contains(solution)) { 138 B.Add(solution); 139 } 140 } 141 } 142 if (B.Any()) { 143 var pi = B.ChooseRandom(random); 144 var diff = GQAPIntegerVectorProximityCalculator.GetDifference(pi.Assignment, target); 145 var I = phi.Except(phi.Intersect(diff)); 146 var i = I.ChooseRandom(random); 147 fix.Add(i); 148 nonFix.Remove(i); 149 pi_prime = pi.Assignment; 150 // TODO 126 151 } 127 152 }
Note: See TracChangeset
for help on using the changeset viewer.