Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/01/11 17:48:53 (13 years ago)
Author:
mkommend
Message:

#1479: Integrated trunk changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GP.Grammar.Editor/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs

    r5445 r6618  
    6969      DoubleArray dueTimeArray,
    7070      DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
    71       DoubleMatrix coordinates, ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix,
    72       int city, int routeToAvoid, out int route, out int place) {
     71      DistanceMatrix distMatrix,
     72      int city, int routeToAvoid, bool allowInfeasible,
     73      out int route, out int place) {
    7374      route = -1;
    7475      place = -1;
    75       double minDetour = 0;
     76      bool bestFeasible = false;
     77      double minDetour = double.MaxValue;
    7678
    7779      for (int tour = 0; tour < Tours.Count; tour++) {
    7880        if (tour != routeToAvoid) {
    7981          for (int i = 0; i <= Tours[tour].Cities.Count; i++) {
    80             double length = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
     82            double length = Tours[tour].GetLength(distMatrix);
    8183
    8284            Tours[tour].Cities.Insert(i, city);
    8385
    84             if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray,
    85               capacity, coordinates, distanceMatrix, useDistanceMatrix)) {
    86               double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
     86            bool feasible = Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray,
     87              capacity, distMatrix);
    8788
     89            if (feasible || allowInfeasible && !bestFeasible) {
     90              double newLength = Tours[tour].GetLength(distMatrix);
    8891              double detour = newLength - length;
    8992
    90               if (route <= 0 || detour < minDetour) {
     93              if (route < 0 || detour < minDetour || feasible && !bestFeasible) {
    9194                route = tour;
    9295                place = i;
    9396                minDetour = detour;
     97
     98                if (feasible)
     99                  bestFeasible = true;
    94100              }
    95101            }
Note: See TracChangeset for help on using the changeset viewer.