Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/06/11 13:00:12 (13 years ago)
Author:
svonolfe
Message:

Added support for pickups and deliveries (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin
Files:
2 edited

Legend:

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

    r6608 r6710  
    2727using System;
    2828using HeuristicLab.Parameters;
     29using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    2930
    3031namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    151152      int city, bool allowInfeasible, out int place) {
    152153      place = -1;
     154
     155      if (tour.Stops.Contains(city))
     156        return false;
     157
    153158      bool bestFeasible = false;
    154159      double minDetour = 0;
    155160
     161      VRPEvaluation eval = ProblemInstance.Evaluate(tour);
     162      double length = eval.Quality;
    156163      for (int i = 0; i <= tour.Stops.Count; i++) {
    157         double length = tour.GetTourLength(ProblemInstance);
    158 
    159164        tour.Stops.Insert(i, city);
    160165
    161         bool feasible = ProblemInstance.Feasible(tour);
     166        eval = ProblemInstance.Evaluate(tour);
     167        bool feasible = ProblemInstance.Feasible(eval);
    162168
    163169        if (feasible || allowInfeasible && !bestFeasible) {
    164           double newLength = tour.GetTourLength(ProblemInstance);
     170          double newLength = eval.Quality;
    165171          double detour = newLength - length;
    166172
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs

    r6607 r6710  
    3535  [Item("PotvinEncoding", "Represents a potvin encoding of VRP solutions. It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.")]
    3636  [StorableClass]
    37   public class PotvinEncoding : TourEncoding, ISingleDepotEncoding, ITimeWindowedEncoding, IHomogenousCapacitatedEncoding {   
     37  public class PotvinEncoding : TourEncoding {   
    3838    [Storable]
    3939    public List<int> Unrouted { get; set; }
     
    115115      for (int tour = 0; tour < Tours.Count; tour++) {
    116116        if (tour != routeToAvoid) {
     117          VRPEvaluation eval = ProblemInstance.Evaluate(Tours[tour]);
     118          double length = eval.Quality;
     119
    117120          for (int i = 0; i <= Tours[tour].Stops.Count; i++) {
    118             double length = GetTourLength(Tours[tour]);
    119 
    120121            Tours[tour].Stops.Insert(i, city);
    121122
    122             bool feasible = ProblemInstance.Feasible(Tours[tour]);
     123            eval = ProblemInstance.Evaluate(Tours[tour]);
     124            bool feasible = ProblemInstance.Feasible(eval);
    123125
    124126            if (feasible || allowInfeasible && !bestFeasible) {
    125               double newLength = GetTourLength(Tours[tour]);
     127              double newLength = eval.Quality;
    126128              double detour = newLength - length;
    127129
Note: See TracChangeset for help on using the changeset viewer.