Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/17/10 13:42:53 (14 years ago)
Author:
svonolfe
Message:

Implemented unified tabu search (WIP) (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin
Files:
19 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs

    r4752 r5127  
    3939    public List<int> Unrouted { get; set; }
    4040
     41    [Storable]
     42    public double PenaltyFactor { get; set; }
     43
    4144    public PotvinEncoding(IVRPProblemInstance instance)
    4245      : base(instance) {
    4346      Unrouted = new List<int>();
     47      PenaltyFactor = 1;
    4448    }
    4549
     
    5660      : base(original, cloner) {
    5761        this.Unrouted = new List<int>(original.Unrouted);
     62        this.PenaltyFactor = original.PenaltyFactor;
    5863    }
    5964
     
    7277
    7378      return solution;
     79    }
     80
     81    public double EvaluateTour(Tour tour) {
     82      return ProblemInstance.Evaluate(tour);
    7483    }
    7584
     
    91100
    92101      return length;
     102    }
     103
     104    public int FindBestInsertionPlace(Tour tour, int city) {
     105      int place = -1;
     106      double minQuality = -1;
     107
     108      for (int i = 0; i <= tour.Stops.Count; i++) {
     109        tour.Stops.Insert(i, city);
     110
     111        double quality = EvaluateTour(tour);
     112
     113        if (place < 0 || quality < minQuality) {
     114          place = i;
     115          minQuality = quality;
     116        }
     117
     118        tour.Stops.RemoveAt(i);
     119      }
     120
     121      if (place == -1)
     122        place = 0;
     123
     124      return place;
    93125    }
    94126
Note: See TracChangeset for help on using the changeset viewer.