Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/27/12 18:41:01 (13 years ago)
Author:
abeham
Message:

#1614

  • worked on path relinking
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/GQAPPathRelinking.cs

    r7423 r7425  
    2929using HeuristicLab.Parameters;
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;
    3132
    32 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Operators {
     33namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
    3334  [Item("GQAPPathRelinking", "Operator that performs path relinking between two solutions. It is described in Mateus, G., Resende, M., and Silva, R. 2011. GRASP with path-relinking for the generalized quadratic assignment problem. Journal of Heuristics 17, Springer Netherlands, pp. 527-565.")]
    3435  [StorableClass]
     
    110111      var target = parents[1];
    111112
     113      var nu = 1.0;
    112114      var pi_prime = (IntegerVector)source.Clone();
    113115      var fix = new HashSet<int>();
    114116      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));
    116118
    117119      while (phi.Any()) {
    118         var B = new HashSet<IntegerVector>();
     120        var B = new HashSet<GQAPSolution>(new GQAPSolutionStructuralEqualityComparer());
    119121        foreach (var v in phi) {
    120122          pi_prime[v] = target[v];
     
    124126          GQAPEvaluator.Evaluate(pi2, weights, distances, installationCosts, demands, capacities,
    125127            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
    126151        }
    127152      }
Note: See TracChangeset for help on using the changeset viewer.