Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/01/10 11:13:46 (14 years ago)
Author:
svonolfe
Message:

Merged r4351 of the VRP feature branch into trunk (#1039)

Location:
trunk/sources/HeuristicLab.Problems.VehicleRouting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting

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

    r4177 r4352  
    2727using System.Drawing;
    2828using System.Collections.Generic;
     29using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    2930
    3031namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
    3132  [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.")]
    3233  [StorableClass]
    33   public class PotvinEncoding : Item, IVRPEncoding {
    34     public override Image ItemImage {
    35       get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; }
    36     }
    37    
    38     #region IVRPEncoding Members
    39     [Storable]
    40     public ItemList<Tour> Tours { get; set; }
    41 
    42     public int Cities {
    43       get
    44       {
    45         int cities = 0;
    46 
    47         foreach (Tour tour in Tours) {
    48           cities += tour.Cities.Count;
    49         }
    50 
    51         return cities;
    52       }
    53     }
    54     #endregion
    55 
     34  public class PotvinEncoding : TourEncoding {   
    5635    [Storable]
    5736    public List<int> Unrouted { get; set; }
     
    6544    }
    6645
    67     public PotvinEncoding() {
    68       Tours = new ItemList<Tour>();
     46    public PotvinEncoding(): base() {
    6947      Unrouted = new List<int>();
    7048    }
     49
     50    [StorableConstructor]
     51    private PotvinEncoding(bool serializing)
     52      : base() {
     53    }
    7154   
    72     public static PotvinEncoding ConvertFrom(IVRPEncoding encoding) {
     55    public static PotvinEncoding ConvertFrom(IVRPEncoding encoding, ILookupParameter<DoubleMatrix> distanceMatrix) {
    7356      PotvinEncoding solution = new PotvinEncoding();
    7457
    75       solution.Tours.AddRange(
    76         encoding.Tours);
     58      TourEncoding.ConvertFrom(encoding, solution, distanceMatrix);
    7759
    7860      return solution;
     
    8264      PotvinEncoding solution = new PotvinEncoding();
    8365
    84       Tour tour = new Tour();
    85       for (int i = 0; i < route.Count; i++) {
    86         if (route[i] == 0) {
    87           if (tour.Cities.Count > 0) {
    88             solution.Tours.Add(tour);
    89             tour = new Tour();
    90           }
    91         } else {
    92           tour.Cities.Add(route[i]);
    93         }
    94       }
     66      TourEncoding.ConvertFrom(route, solution);
    9567
    9668      return solution;
     
    11587            if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray,
    11688              capacity, coordinates, distanceMatrix, useDistanceMatrix)) {
    117               double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
     89                double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
    11890
    11991              double detour = newLength - length;
Note: See TracChangeset for help on using the changeset viewer.