Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/28/11 14:16:21 (13 years ago)
Author:
svonolfe
Message:

Merged changes from trunk (#1561) into branch (#1177)

File:
1 edited

Legend:

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

    r4752 r6607  
    2727using HeuristicLab.Common;
    2828using HeuristicLab.Core;
     29using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2930
    3031namespace HeuristicLab.Problems.VehicleRouting {
     
    4647        this.Stops = new List<int>(original.Stops);
    4748    }
     49
     50    public double GetTourLength(IVRPProblemInstance instance) {
     51      double length = 0;
     52
     53      if (Stops.Count > 0) {
     54        List<int> cities = new List<int>();
     55        cities.Add(0);
     56        foreach (int city in Stops) {
     57          cities.Add(city);
     58        }
     59        cities.Add(0);
     60
     61        for (int i = 1; i < cities.Count; i++) {
     62          length += instance.GetDistance(cities[i - 1], cities[i]);
     63        }
     64      }
     65
     66      return length;
     67    }
    4868  }
    4969}
Note: See TracChangeset for help on using the changeset viewer.