Changeset 7543


Ignore:
Timestamp:
03/05/12 10:15:50 (7 years ago)
Author:
svonolfe
Message:

Fixed minor issues (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4
Files:
5 edited

Legend:

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

    r6851 r7543  
    126126      int cities = instance.Cities.Value;
    127127
    128       int vehicle = cities;
    129128      for (int i = 0; i < route.Count; i++) {
    130         if (route[i] == 0) {
    131           route[i] = vehicle;
    132           vehicle++;
     129        if (route[i] <= 0) {
     130          int vehicle = -route[i];
     131          route[i] = cities + vehicle;
    133132        } else {
    134133          route[i] = route[i] - 1;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/RandomCreator.cs

    r4752 r7543  
    6565        perm[i] = i + 1;
    6666      for (int i = cities; i < cities + vehicles; i++)
    67         perm[i] = 0;
     67        perm[i] = -(i - cities);
    6868      for (int i = 0; i < perm.Length - 2; i++) {
    6969        sortingArray[i] = RandomParameter.ActualValue.Next(perm.Length * 2);
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/TourEncoding.cs

    r7203 r7543  
    128128      Tour tour = new Tour();
    129129      for (int i = 0; i < route.Count; i++) {
    130         if (route[i] == 0) {
     130        if (route[i] <= 0) {
    131131          if (tour.Stops.Count > 0) {
    132132            solution.Tours.Add(tour);
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs

    r6960 r7543  
    130130      PotvinEncoding solution = new PotvinEncoding(instance);
    131131
    132       TourEncoding.ConvertFrom(route, solution);
     132      solution.Tours = new ItemList<Tour>();
     133
     134      Tour tour = new Tour();
     135      int routeIdx = 0;
     136      for (int i = 0; i < route.Count; i++) {
     137        if (route[i] <= 0) {
     138          if (tour.Stops.Count > 0) {
     139            solution.Tours.Add(tour);
     140            tour = new Tour();
     141          }
     142          int vehicle = -route[i];
     143          solution.VehicleAssignment[routeIdx] = vehicle;
     144          routeIdx++;
     145        } else {
     146          tour.Stops.Add(route[i]);
     147        }
     148      }
     149
     150      solution.Repair();
    133151
    134152      return solution;
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs

    r6885 r7543  
    177177
    178178      for (int i = 0; i < distanceMatrix.Rows; i++) {
    179         for (int j = i; j < distanceMatrix.Columns; j++) {
     179        for (int j = 0; j < distanceMatrix.Columns; j++) {
    180180          double distance = CalculateDistance(i, j);
    181181
    182182          distanceMatrix[i, j] = distance;
    183           distanceMatrix[j, i] = distance;
    184183        }
    185184      }
Note: See TracChangeset for help on using the changeset viewer.