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/GroupingMoveSoftTabuCriterion.cs

    r14046 r14128  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Optimization;
     
    3839      get { return false; }
    3940    }
    40     public ILookupParameter<IPackingMove> PackingMoveParameter {
    41       get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     41    public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter {
     42      get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; }
    4243    }
    43     public ILookupParameter<PackingSequenceEncoding> PackingSequenceParameter {
    44       get { return (ILookupParameter<PackingSequenceEncoding>)Parameters["PackingSequence"]; }
     44    public ILookupParameter<Permutation> PackingSequenceParameter {
     45      get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }
    4546    }
    4647    public ILookupParameter<ItemList<IItem>> TabuListParameter {
     
    6566    public SequenceMoveSoftTabuCriterion()
    6667      : base() {
    67       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
    68       Parameters.Add(new LookupParameter<PackingSequenceEncoding>("PackingSequence", "The solution to evaluate."));
     68      Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate."));
     69      Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution to evaluate."));
    6970      Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu."));
    7071      Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list."));
     
    8182      ItemList<IItem> tabuList = TabuListParameter.ActualValue;
    8283      SequenceMove move = PackingMoveParameter.ActualValue as SequenceMove;
    83       PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;
    84       int length = PackingSequence.PackingSequence.Length;
    8584      double moveQuality = MoveQualityParameter.ActualValue.Value;
    86       bool maximization = MaximizationParameter.ActualValue.Value;   
     85      bool maximization = MaximizationParameter.ActualValue.Value;
    8786      bool useAspiration = UseAspirationCriterionParameter.Value.Value;
    88       bool isTabu = IsMoveTabu(tabuList, move, PackingSequence, moveQuality, maximization, useAspiration);
     87      bool isTabu = IsMoveTabu(tabuList, move, moveQuality, maximization, useAspiration);
    8988
    9089      MoveTabuParameter.ActualValue = new BoolValue(isTabu);
     
    9291    }
    9392
    94     private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, PackingSequenceEncoding PackingSequence, double moveQuality, bool maximization, bool useAspiration) {
     93    private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, double moveQuality, bool maximization, bool useAspiration) {
    9594      bool isTabu = false;
    96       var attributes = tabuList.FindAll(ta => ta.GetType().Equals(move.GetMoveAttributeType()));
     95      var attributes = tabuList.FindAll(ta => ta.GetType() == move.GetMoveAttributeType());
    9796
    9897      foreach (IItem attr in attributes) {
     
    103102              || !maximization && moveQuality >= gvAttr.MoveQuality)) {
    104103
    105           isTabu = move.BelongsToAttribute(gvAttr, false);
     104          isTabu = move.BelongsToAttribute(gvAttr, false); // only difference to hard tabu criterion
    106105        }
    107106        if (isTabu) break;
Note: See TracChangeset for help on using the changeset viewer.