Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/15/13 22:23:36 (11 years ago)
Author:
jhelm
Message:

#1966: Did some major refactoring in Decoder-classes; Added MoveEvaluator classes for different encodings and dimensions; Added new crossover-class for MCV encoding;

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/Moves/ThreeWay/ExhaustiveMCVTripleMoveGenerator.cs

    r9473 r9495  
    4040    }
    4141
    42     public static IEnumerable<MultiComponentVectorMove> GenerateMCVTripleMoves(MultiComponentVectorEncoding mcv) {
    43       int nrOfBins = 0;
    44       foreach (var pi in mcv.PackingInformations) {
    45         if (pi.AssignedBin > nrOfBins)
    46           nrOfBins = pi.AssignedBin;
    47       }
    48       nrOfBins++;
    49       Dictionary<int, List<int>> indexesPerBin = new Dictionary<int, List<int>>();
    50       for (int i = 0; i < mcv.PackingInformations.Count; i++) {
    51         int currentBin = mcv.PackingInformations[i].AssignedBin;
    52         if (!indexesPerBin.ContainsKey(currentBin))
    53           indexesPerBin[currentBin] = new List<int>();
    54         indexesPerBin[currentBin].Add(i);
    55       }
    56                                                        
    57       for (int index = 0; index < mcv.PackingInformations.Count; index++) {
    58         for (int group = 0; group < nrOfBins; group++) {
    59           foreach (int targetIndex in indexesPerBin[group]) {
    60             yield return new MCVTripleMove(index, false, group, targetIndex, mcv);
    61             yield return new MCVTripleMove(index, true, group, targetIndex, mcv);
    62           }
    63         }
    64       }
     42    public static IEnumerable<MultiComponentVectorMove> GenerateMCVTripleMoves(MultiComponentVectorEncoding mcv) { 
     43      foreach (var oldGroup in mcv.PackingInformations)
     44        for (int sourceIndex = 0; sourceIndex < oldGroup.Value.Count; sourceIndex++)
     45          foreach (var newGroup in mcv.PackingInformations)
     46            for (int targetIndex = 0; targetIndex < newGroup.Value.Count; targetIndex++) {
     47              yield return new MCVTripleMove(oldGroup.Key, newGroup.Key, sourceIndex, targetIndex, false, mcv);
     48              yield return new MCVTripleMove(oldGroup.Key, newGroup.Key, sourceIndex, targetIndex, true, mcv);
     49            }
    6550    }
    6651
Note: See TracChangeset for help on using the changeset viewer.