Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/30/10 14:52:30 (14 years ago)
Author:
abeham
Message:

Updated inversion moves to respect different types of permutation #889

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt/ExhaustiveInversionMoveGenerator.cs

    r3232 r3233  
    3434      InversionMove[] moves = new InversionMove[totalMoves];
    3535      int count = 0;
    36       for (int i = 0; i < length - 1; i++)
    37         for (int j = i + 1; j < length; j++) {
    38           // doesn't make sense to inverse the whole permutation or the whole but one
    39           /*if (i == 0 && j >= length - 2) continue;
    40           else if (i == 1 && j >= length - 1) continue;*/
    41           moves[count++] = new InversionMove(i, j);
     36
     37      if (permutation.PermutationType == PermutationTypes.RelativeUndirected) {
     38        for (int i = 0; i < length - 1; i++) {
     39          for (int j = i + 1; j < length; j++) {
     40            // doesn't make sense to inverse the whole permutation or the whole but one in case of relative undirected permutations
     41            if (j - i >= length - 2) continue;
     42            moves[count++] = new InversionMove(i, j);
     43          }
    4244        }
     45      } else {
     46          for (int i = 0; i < length - 1; i++)
     47            for (int j = i + 1; j < length; j++) {
     48              moves[count++] = new InversionMove(i, j);
     49            }
     50      }
    4351      return moves;
    4452    }
Note: See TracChangeset for help on using the changeset viewer.