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/Moves/SingleItemRotationMove.cs

    r9473 r9495  
    2424using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HeuristicLab.Problems.BinPacking.Interfaces;
    2627
    2728namespace HeuristicLab.Encodings.PackingEncoding.MultiComponentVector {
     
    3031  public class SingleItemRotationMove : MultiComponentVectorMove {
    3132    [Storable]
    32     public int ItemIndex { get; protected set; }
     33    public int AffectedGroup { get; protected set; }
     34    [Storable]
     35    public int Index { get; protected set; }
    3336
    3437    [StorableConstructor]
     
    3639    protected SingleItemRotationMove(SingleItemRotationMove original, Cloner cloner)
    3740      : base(original, cloner) {
    38         this.ItemIndex = original.ItemIndex;
     41        this.AffectedGroup = original.AffectedGroup;
     42        this.Index = original.Index;
    3943    }
    40     public SingleItemRotationMove(int index, MultiComponentVectorEncoding multiComponentVector)
     44    public SingleItemRotationMove(int affectedBin, int index, MultiComponentVectorEncoding multiComponentVector)
    4145      : base(multiComponentVector) {
    42         ItemIndex = index;
     46        AffectedGroup = affectedBin;
     47        Index = index;
    4348    }
    4449
     
    4752    }
    4853
    49     public override MultiComponentVectorEncoding GetVectorAfterMove() {
    50       return GetVectorAfterMove (MultiComponentVector, ItemIndex);
     54    public override IPackingSolutionEncoding GetSolutionAfterMove() {
     55      return GetVectorAfterMove (MultiComponentVector, AffectedGroup, Index);
    5156    }
    52     public static MultiComponentVectorEncoding GetVectorAfterMove(MultiComponentVectorEncoding multiComponentVector, int itemIndex) {
     57    public static MultiComponentVectorEncoding GetVectorAfterMove(MultiComponentVectorEncoding multiComponentVector, int affectedGroup, int index) {
    5358      var result = multiComponentVector.Clone(new Cloner()) as MultiComponentVectorEncoding;
    54       result.PackingInformations[itemIndex].Rotated = !result.PackingInformations[itemIndex].Rotated;
     59      result.PackingInformations[affectedGroup][index].Rotated = !result.PackingInformations[affectedGroup][index].Rotated;
    5560      return result;
    5661    }
     
    6166
    6267    public override string ToString() {
    63       return "RM(i=" + ItemIndex+")";
     68      return "RM(g=" + AffectedGroup + ",i=" + Index + ")";
     69    }
     70
     71    public override MultiComponentVectorMoveAttribute GetAttribute(double quality) {
     72        return new SingleItemRotationMoveAttribute(AffectedGroup, Index,
     73          MultiComponentVector.PackingInformations[AffectedGroup][Index].ItemID,
     74          MultiComponentVector.PackingInformations[AffectedGroup][Index].Rotated, quality);
     75    }
     76
     77    public override bool BelongsToAttribute(MultiComponentVectorMoveAttribute attribute, bool hardCriterion) {
     78      SingleItemRotationMoveAttribute actualAttribute = attribute as SingleItemRotationMoveAttribute;
     79      if (actualAttribute != null) {
     80        if (hardCriterion) {
     81          if (AffectedGroup == actualAttribute.AffectedGroup || MultiComponentVector.PackingInformations[AffectedGroup][Index].Rotated == actualAttribute.ItemRotation)
     82            return true;
     83        } else {
     84          if (AffectedGroup == actualAttribute.AffectedGroup && MultiComponentVector.PackingInformations[AffectedGroup][Index].Rotated == actualAttribute.ItemRotation)
     85            return true;
     86        }
     87      }
     88      return false;
    6489    }
    6590  }
Note: See TracChangeset for help on using the changeset viewer.