- Timestamp:
- 03/18/10 22:57:22 (15 years ago)
- 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 31 31 [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.")] 32 32 [StorableClass] 33 public class TwoOptTabuMoveMaker : SingleSuccessorOperator, ITwoOptPermutationMoveOperator, ITabuMoveMaker {33 public class TwoOptTabuMoveMaker : TabuMoveMaker, ITwoOptPermutationMoveOperator { 34 34 public ILookupParameter<Permutation> PermutationParameter { 35 35 get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } … … 38 38 get { return (LookupParameter<TwoOptMove>)Parameters["TwoOptMove"]; } 39 39 } 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 }46 40 47 41 public TwoOptTabuMoveMaker() 48 42 : base() { 49 43 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."));52 44 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation.")); 53 45 } 54 46 55 public override IOperation Apply() { 56 ItemList<IItem> tabuList = TabuListParameter.ActualValue; 47 protected override IItem GetTabuAttribute() { 57 48 TwoOptMove move = TwoOptMoveParameter.ActualValue; 58 IntValue tabuTenure = TabuTenureParameter.ActualValue;59 49 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)); 72 54 } 73 55
Note: See TracChangeset
for help on using the changeset viewer.