Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/18/10 22:57:22 (15 years ago)
Author:
abeham
Message:

Fixed changing of MoveTabuParameter and added two different tabu criteria for a move: One prevents only readding deleted edges, the other prevents both readding deleted edges and deleting added edges. #840

Location:
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt
Files:
2 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt/TwoOptTabuMoveMaker.cs

    r3074 r3104  
    3131  [Item("TwoOptTabuMoveMaker", "Declares a given 2-opt move as tabu, by adding its attributes to the tabu list. It also removes the oldest entry in the tabu list when its size is greater than tenure.")]
    3232  [StorableClass]
    33   public class TwoOptTabuMoveMaker : SingleSuccessorOperator, ITwoOptPermutationMoveOperator, ITabuMoveMaker {
     33  public class TwoOptTabuMoveMaker : TabuMoveMaker, ITwoOptPermutationMoveOperator {
    3434    public ILookupParameter<Permutation> PermutationParameter {
    3535      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
     
    3838      get { return (LookupParameter<TwoOptMove>)Parameters["TwoOptMove"]; }
    3939    }
    40     public LookupParameter<ItemList<IItem>> TabuListParameter {
    41       get { return (LookupParameter<ItemList<IItem>>)Parameters["TabuList"]; }
    42     }
    43     public ValueLookupParameter<IntValue> TabuTenureParameter {
    44       get { return (ValueLookupParameter<IntValue>)Parameters["TabuTenure"]; }
    45     }
    4640
    4741    public TwoOptTabuMoveMaker()
    4842      : base() {
    4943      Parameters.Add(new LookupParameter<TwoOptMove>("TwoOptMove", "The move that was made."));
    50       Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list where move attributes are stored."));
    51       Parameters.Add(new ValueLookupParameter<IntValue>("TabuTenure", "The tenure of the tabu list."));
    5244      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation."));
    5345    }
    5446
    55     public override IOperation Apply() {
    56       ItemList<IItem> tabuList = TabuListParameter.ActualValue;
     47    protected override IItem GetTabuAttribute() {
    5748      TwoOptMove move = TwoOptMoveParameter.ActualValue;
    58       IntValue tabuTenure = TabuTenureParameter.ActualValue;
    5949      Permutation permutation = PermutationParameter.ActualValue;
    60      
    61       if (tabuList.Count >= tabuTenure.Value) {
    62         for (int i = 0; i < tabuTenure.Value - 1; i++)
    63           tabuList[i] = tabuList[i + 1];
    64         tabuList.RemoveAt(tabuList.Count - 1);
    65       }
    66 
    67       TwoOptTabuMoveAttribute attribute = new TwoOptTabuMoveAttribute(
    68         permutation.GetCircular(move.Index1 - 1), permutation[move.Index1],
    69         permutation[move.Index2], permutation.GetCircular(move.Index2 + 1));
    70       tabuList.Add(attribute);
    71       return base.Apply();
     50      return new TwoOptTabuMoveAttribute( permutation.GetCircular(move.Index1 - 1),
     51        permutation[move.Index1],
     52        permutation[move.Index2],
     53        permutation.GetCircular(move.Index2 + 1));
    7254    }
    7355
Note: See TracChangeset for help on using the changeset viewer.