Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/06/13 03:12:42 (11 years ago)
Author:
jhelm
Message:

#1966: Applied some heavy refactoring on the decoder-classes and cleaned up the code a bit;

Location:
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/Moves/Triple/Moves/MCVTripleMove.cs

    r9563 r9593  
    102102            return true;
    103103        } else {
    104           if ((Index == actualAttribute.Index && TargetIndex == actualAttribute.TargetIndex)
     104          if ((Index == actualAttribute.Index || TargetIndex == actualAttribute.TargetIndex)
    105105                  && MultiComponentVector.PackingInformations[OldGroup][Index].ItemID == actualAttribute.ItemID
    106106                  //&& Rotation == actualAttribute.Rotation
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/MultiComponentVectorRandomCreator.cs

    r9563 r9593  
    7070      var solution = new MultiComponentVectorEncoding();
    7171      if (sortedSequence)
    72         solution.PackingInformations = PackingInformation.CreateDictionaryRandomlyWithSortedSequence(items, lowerBound, random);
     72        solution.PackingInformations = PackingInformation.CreateDictionaryRandomlyWithSortedSequence(items, /*lowerBound*/ 1, random);
    7373      else
    74         solution.PackingInformations = PackingInformation.CreateDictionaryRandomly(items, lowerBound, random);
     74        solution.PackingInformations = PackingInformation.CreateDictionaryRandomly(items, /*lowerBound*/ 1, random);
    7575      return solution;
    7676    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/SequenceBasedMultiComponentVectorCrossover.cs

    r9563 r9593  
    4444    public override MultiComponentVectorEncoding Cross(IRandom random, MultiComponentVectorEncoding parent1, MultiComponentVectorEncoding parent2) {
    4545      MultiComponentVectorEncoding child = new MultiComponentVectorEncoding ();
    46      
     46
     47      int nrOfItems = parent1.NrOfItems;
     48      bool[] itemAlreadyAssigned = new bool[nrOfItems];
     49      int nrOfBins = parent1.NrOfBins > parent2.NrOfBins ? parent2.NrOfBins : parent1.NrOfBins;
     50      int swappedBin = random.Next(nrOfBins);
     51
     52      for (int binNr = 0; binNr < nrOfBins; binNr++) {
     53
     54        var newBin = new ItemList<PackingInformation>();
     55        var currentParent = binNr == swappedBin ? parent1 : parent2;
     56
     57        int nrOfItemsInBin = currentParent.PackingInformations[binNr].Count;
     58        for (int i = 0; i < nrOfItemsInBin; i++) {
     59          PackingInformation pi = new PackingInformation(currentParent.PackingInformations[binNr][i]);
     60          if (!itemAlreadyAssigned[pi.ItemID]) {
     61            itemAlreadyAssigned[pi.ItemID] = true;
     62            newBin.Add(new PackingInformation(pi));
     63          }
     64        }
     65
     66        child.PackingInformations[binNr] = newBin;
     67      }
     68
     69      for (int itemID = 0; itemID < nrOfItems; itemID++) {
     70        if (!itemAlreadyAssigned[itemID])
     71          child.PackingInformations[0].Add(new PackingInformation(itemID, random.Next(2) == 0 ? true : false));
     72      }
    4773
    4874
Note: See TracChangeset for help on using the changeset viewer.