Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/09/10 16:24:09 (14 years ago)
Author:
svonolfe
Message:

Added Potvin encoding (#1177)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/TourEncoding.cs

    r4365 r4376  
    7171    protected IVRPProblemInstance ProblemInstance { get; set; }
    7272
    73     public override IDeepCloneable Clone(Cloner cloner) {
    74       TourEncoding clone = (TourEncoding)base.Clone(cloner);
    75 
    76       clone.ProblemInstance = (IVRPProblemInstance)cloner.Clone(ProblemInstance);
    77 
    78       return clone;
    79     }
    80 
    8173    public TourEncoding(IVRPProblemInstance problemInstance) {
    8274      Tours = new ItemList<Tour>();
     
    8779    [StorableConstructor]
    8880    protected TourEncoding(bool serializing)
    89       : base() {
     81      : base(serializing) {
     82    }
     83
     84    public static void ConvertFrom(IVRPEncoding encoding, TourEncoding solution, IVRPProblemInstance problemInstance) {
     85      solution.Tours = new ItemList<Tour>(encoding.GetTours());
     86    }
     87
     88    public static void ConvertFrom(List<int> route, TourEncoding solution) {
     89      solution.Tours = new ItemList<Tour>();
     90
     91      Tour tour = new Tour();
     92      for (int i = 0; i < route.Count; i++) {
     93        if (route[i] == 0) {
     94          if (tour.Stops.Count > 0) {
     95            solution.Tours.Add(tour);
     96            tour = new Tour();
     97          }
     98        } else {
     99          tour.Stops.Add(route[i]);
     100        }
     101      }
    90102    }
    91103  }
Note: See TracChangeset for help on using the changeset viewer.