Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/26/15 16:14:52 (10 years ago)
Author:
apolidur
Message:

#2221: Fixing MoveEvaluators after running unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PTSP/HeuristicLab.Problems.PTSP/3.3/MoveEvaluators/TwoOpt/PTSPEstimatedInversionMovePathEvaluator.cs

    r12219 r12261  
    100100              // find nearest predecessor in realization if source edge
    101101              while(realization[permutation.GetCircular(indices[i]-j)].Value==0) {
    102                 j--;
     102                j++;
    103103              }
    104104              aPosteriori[i] = permutation.GetCircular(indices[i] - j);
     
    113113        }
    114114        // compute cost difference between the two a posteriori solutions
    115         moveQuality += distanceMatrix[aPosteriori[0], aPosteriori[2]] + distanceMatrix[aPosteriori[1], aPosteriori[3]];
    116         moveQuality -= distanceMatrix[aPosteriori[0], aPosteriori[1]] - distanceMatrix[aPosteriori[2], aPosteriori[3]];
     115        if (!(aPosteriori[0] == aPosteriori[2] && aPosteriori[1] == aPosteriori[3])) {
     116          moveQuality = moveQuality + distanceMatrix[aPosteriori[0], aPosteriori[2]] + distanceMatrix[aPosteriori[1], aPosteriori[3]] - distanceMatrix[aPosteriori[0], aPosteriori[1]] - distanceMatrix[aPosteriori[2], aPosteriori[3]];
     117        }
     118        Array.Clear(aPosteriori, 0, aPosteriori.Length);
    117119      }
    118120      // return average of cost differences
    119       return moveQuality / realizations.Capacity;
     121      return Math.Abs(moveQuality) / realizations.Capacity;
    120122    }
    121123
Note: See TracChangeset for help on using the changeset viewer.