Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/08/11 09:47:31 (11 years ago)
Author:
svonolfe
Message:

Added pairwise manipulators, removed relocation manipulator (#1177)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDRearrange/PotvinPDRearrangeMoveMaker.cs

    r6857 r6960  
    5959    }
    6060
    61     public static void InsertPair(PotvinEncoding solution, Tour tour, int source, int target, IVRPProblemInstance problemInstance, int positionToAvoid = -1, int positionToAvoid2 = -1) {
    62       int stops = tour.Stops.Count;
    63       VRPEvaluation eval = problemInstance.EvaluateTour(tour, solution);
    64       double minCosts = double.MaxValue;
    65       int sourceLocation = -1;
    66       int targetLocation = -1;
    67 
    68       for (int i = 0; i <= stops; i++) {
    69         tour.Stops.Insert(i, source);
    70         VRPEvaluation tourEval = problemInstance.EvaluateTour(tour, solution);
    71         double sourceCosts = tourEval.Quality - eval.Quality;
    72 
    73         for (int j = i + 1; j <= stops + 1; j++) {
    74           if (positionToAvoid != i || positionToAvoid2 != j || stops == 0) {
    75             bool feasible;
    76             double targetCosts = problemInstance.GetInsertionCosts(tourEval, solution, target, 0, j, out feasible);
    77 
    78             double costs = sourceCosts + targetCosts;
    79             if (costs < minCosts) {
    80               minCosts = costs;
    81               sourceLocation = i;
    82               targetLocation = j;
    83             }
    84           }
    85         }
    86         tour.Stops.Remove(source);
    87       }
    88 
    89       tour.Stops.Insert(sourceLocation, source);
    90       tour.Stops.Insert(targetLocation, target);
    91     }
    92 
    9361    public static void Apply(PotvinEncoding solution, PotvinPDRearrangeMove move, IVRPProblemInstance problemInstance) {
    9462      Tour tour = solution.Tours[move.Tour];
     
    10472        tour2.Stops.Remove(location);
    10573
    106         PotvinPDRearrangeMoveMaker.InsertPair(solution, tour, move.City, location, problemInstance, position, position2);
     74        solution.InsertPair(tour, move.City, location, problemInstance, position, position2);
    10775      } else {
    10876        tour.Stops.Remove(move.City);
Note: See TracChangeset for help on using the changeset viewer.