Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/29/14 15:43:47 (10 years ago)
Author:
pfleck
Message:

#2208:

  • Fixed bugs in cost calculation of insertion and replacement
  • Rewritten Cleanup of infeasible tours
  • Small refactoring
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/DistanceMatrix.cs

    r11193 r11228  
    5555    public double CalculateTourLength(IList<int> path, double fixedPenalty) {
    5656      double length = 0.0;
    57 
    58       for (int i = 1; i < path.Count; i++) {
    59         length += this[i - 1, i];
    60       }
    61 
     57      for (int i = 1; i < path.Count; i++)
     58        length += this[path[i - 1], path[i]];
    6259      // Add the fixed penalty for every vertex except for the starting and ending vertex
    6360      length += (path.Count - 2) * fixedPenalty;
    64 
    6561      return length;
    6662    }
    67 
    68     public double CalculateInsertionCosts(IList<int> path, int pointPosition, int insertPosition, double fixedPenalty) {
    69       double detour = this[path[insertPosition - 1], pointPosition] + this[pointPosition, path[insertPosition]];
     63    public double CalculateInsertionCosts(IList<int> path, int insertPosition, int point, double fixedPenalty) {
     64      double detour = this[path[insertPosition - 1], point] + this[point, path[insertPosition]];
    7065      detour += fixedPenalty;
    7166      detour -= this[path[insertPosition - 1], path[insertPosition]];
    7267      return detour;
    7368    }
    74 
    75     public double CalculateReplacementCosts(List<int> path, int pointPosition, int replacementPosition) {
    76       double detour = this[pointPosition - 1, replacementPosition] + this[replacementPosition, pointPosition + 1];
    77       detour -= this[pointPosition - 1, pointPosition] + this[pointPosition, pointPosition + 1];
     69    public double CalculateReplacementCosts(List<int> path, int replacePosition, int point) {
     70      double detour = this[path[replacePosition - 1], point] + this[point, path[replacePosition + 1]];
     71      detour -= this[path[replacePosition - 1], path[replacePosition]] + this[path[replacePosition], path[replacePosition + 1]];
    7872      return detour;
     73    }
     74    public double CalculateRemovementSaving(List<int> path, int removePosition, double fixedPenalty) {
     75      double saving = this[path[removePosition - 1], path[removePosition]];
     76      saving += this[path[removePosition], path[removePosition + 1]];
     77      saving -= this[path[removePosition - 1], path[removePosition + 1]];
     78      saving += fixedPenalty;
     79      return saving;
    7980    }
    8081  }
Note: See TracChangeset for help on using the changeset viewer.