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

    r14046 r14128  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Encodings.PermutationEncoding;
    2627using HeuristicLab.Operators;
    2728using HeuristicLab.Optimization;
     
    3738      get { return false; }
    3839    }
    39     public ILookupParameter<IPackingMove> PackingMoveParameter {
    40       get { return (ILookupParameter<IPackingMove>)Parameters["PackingMove"]; }
     40    public ILookupParameter<IPackingMove<Permutation>> PackingMoveParameter {
     41      get { return (ILookupParameter<IPackingMove<Permutation>>)Parameters["PackingMove"]; }
    4142    }
    42     public ILookupParameter<PackingSequenceEncoding> PackingSequenceParameter {
    43       get { return (ILookupParameter<PackingSequenceEncoding>)Parameters["PackingSequence"]; }
     43    public ILookupParameter<Permutation> PackingSequenceParameter {
     44      get { return (ILookupParameter<Permutation>)Parameters["PackingSequence"]; }
    4445    }
    4546    public ILookupParameter<ItemList<IItem>> TabuListParameter {
     
    6465    public SequenceMoveHardTabuCriterion()
    6566      : base() {
    66       Parameters.Add(new LookupParameter<IPackingMove>("PackingMove", "The move to evaluate."));
    67       Parameters.Add(new LookupParameter<PackingSequenceEncoding>("PackingSequence", "The solution to evaluate."));
     67      Parameters.Add(new LookupParameter<IPackingMove<Permutation>>("PackingMove", "The move to evaluate."));
     68      Parameters.Add(new LookupParameter<Permutation>("PackingSequence", "The solution candidate to evaluate."));
    6869      Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu."));
    6970      Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list."));
     
    8081      ItemList<IItem> tabuList = TabuListParameter.ActualValue;
    8182      SequenceMove move = PackingMoveParameter.ActualValue as SequenceMove;
    82       PackingSequenceEncoding PackingSequence = PackingSequenceParameter.ActualValue;
    83       int length = PackingSequence.PackingSequence.Length;
    8483      double moveQuality = MoveQualityParameter.ActualValue.Value;
    8584      bool maximization = MaximizationParameter.ActualValue.Value;
    8685      bool useAspiration = UseAspirationCriterionParameter.Value.Value;
    87       bool isTabu = IsMoveTabu(tabuList, move, PackingSequence, moveQuality, maximization, useAspiration);
     86      bool isTabu = IsMoveTabu(tabuList, move, moveQuality, maximization, useAspiration);
    8887
    8988      MoveTabuParameter.ActualValue = new BoolValue(isTabu);
     
    9190    }
    9291
    93     private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, PackingSequenceEncoding PackingSequence, double moveQuality, bool maximization, bool useAspiration) {
     92    private bool IsMoveTabu(ItemList<IItem> tabuList, SequenceMove move, double moveQuality, bool maximization, bool useAspiration) {
    9493      bool isTabu = false;
    95       var attributes = tabuList.FindAll(ta => ta.GetType().Equals(move.GetMoveAttributeType()));
     94      var attributes = tabuList.FindAll(ta => ta.GetType() == move.GetMoveAttributeType());
    9695
    9796      foreach (IItem attr in attributes) {
     
    102101              || !maximization && moveQuality >= gvAttr.MoveQuality)) {
    103102
    104           isTabu = move.BelongsToAttribute(gvAttr, true);
     103          isTabu = move.BelongsToAttribute(gvAttr, true); // only difference to soft tabu criterion
    105104        }
    106105        if (isTabu) break;
Note: See TracChangeset for help on using the changeset viewer.