Ignore:
Timestamp:
07/20/16 14:02:36 (5 years ago)
Author:
gkronber
Message:

#1966: refactoring of bin packing implementation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingSequence/Moves/Insertion/InsertionMove.cs

    r14046 r14128  
    3232  [Item("Insertion Move", "A move on a Sequence vector that is specified by two group-assignment-indexes.")]
    3333  [StorableClass]
    34   public class InsertionMove : SequenceMove, IPackingMove {
     34  public class InsertionMove : SequenceMove {
    3535    [Storable]
    3636    public int Index1 { get; protected set; }
     
    4545      this.Index2 = original.Index2;
    4646    }
    47     public InsertionMove(int index1, int index2, PackingSequenceEncoding PackingSequence)
    48       : base(PackingSequence) {
     47    public InsertionMove(int index1, int index2, Permutation packingSequence)
     48      : base(packingSequence) {
    4949      Index1 = index1;
    5050      Index2 = index2;
     
    5555    }
    5656
    57     public override IPackingSolutionEncoding GetSolutionAfterMove() {
    58       PackingSequenceEncoding newSolution = new PackingSequenceEncoding();
    59 
    60       Permutation original = PackingSequence.PackingSequence;
    61       Permutation resultingPermutation = (Permutation)PackingSequence.PackingSequence.Clone();
     57    public override Permutation GetSolutionAfterMove() {
     58      Permutation original = PackingSequence;
     59      Permutation resultingPermutation = (Permutation)PackingSequence.Clone();
    6260      int cutIndex, insertIndex, number;
    6361
     
    6866      int i = 0;  // index in new permutation
    6967      int j = 0;  // index in old permutation
    70       while (i < PackingSequence.PackingSequence.Length) {
     68      while (i < PackingSequence.Length) {
    7169        if (j == cutIndex) {
    7270          j++;
     
    8381      }
    8482
    85       newSolution.PackingSequence = resultingPermutation;
    86       return newSolution;
     83      return resultingPermutation;
    8784    }
    8885
     
    9289
    9390    public override SequenceMoveAttribute GetAttribute(double quality) {
    94       return new InsertionMoveAttribute(Index1, Index2, PackingSequence.PackingSequence[Index1], PackingSequence.PackingSequence[Index2], quality);
     91      return new InsertionMoveAttribute(Index1, Index2, PackingSequence[Index1], PackingSequence[Index2], quality);
    9592    }
    9693
     
    103100        } else
    104101          if (Index1 == attr.Index1 && Index2 == attr.Index2)
    105           return true;
     102            return true;
    106103      }
    107104      return false;
Note: See TracChangeset for help on using the changeset viewer.