Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/20/11 13:36:49 (13 years ago)
Author:
svonolfe
Message:

Improved performance of many VRP operators by optimizing the parameter lookup (#1561)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs

    r5445 r6449  
    6969      DoubleArray dueTimeArray,
    7070      DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
    71       DoubleMatrix coordinates, ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix,
     71      DistanceMatrix distMatrix,
    7272      int city, int routeToAvoid, out int route, out int place) {
    7373      route = -1;
    7474      place = -1;
     75      bool bestFeasible = false;
    7576      double minDetour = 0;
    7677
     
    7879        if (tour != routeToAvoid) {
    7980          for (int i = 0; i <= Tours[tour].Cities.Count; i++) {
    80             double length = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
     81            double length = Tours[tour].GetLength(distMatrix);
    8182
    8283            Tours[tour].Cities.Insert(i, city);
    8384
    84             if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray,
    85               capacity, coordinates, distanceMatrix, useDistanceMatrix)) {
    86               double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
     85            bool feasible = Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray,
     86              capacity, distMatrix);
    8787
     88            if (!bestFeasible || feasible) {
     89              double newLength = Tours[tour].GetLength(distMatrix);
    8890              double detour = newLength - length;
    8991
    90               if (route <= 0 || detour < minDetour) {
     92              if (route <= 0 || detour < minDetour || (!(bestFeasible && !feasible)) && detour < minDetour || (feasible && !bestFeasible)) {
    9193                route = tour;
    9294                place = i;
    9395                minDetour = detour;
     96
     97                if (feasible)
     98                  bestFeasible = true;
    9499              }
    95100            }
Note: See TracChangeset for help on using the changeset viewer.