- Timestamp:
- 03/29/10 18:49:55 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt
- Files:
-
- 1 added
- 1 deleted
- 10 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/PreventReaddAndRemovalTranslocationMoveTabuChecker.cs
r3231 r3232 29 29 30 30 namespace HeuristicLab.Encodings.PermutationEncoding { 31 [Item(" ThreeOptPreventEdgeRemovalAndReadding", "Prevents readding of previously deleted edges as well as deleting previously added edges.")]31 [Item("PreventReaddAndRemovalTranslocationMoveTabuChecker", "Prevents readding of previously deleted edges as well as deleting previously added edges.")] 32 32 [StorableClass] 33 public class PreventReadd DeleteThreeOptTabuMoveEvaluator : SingleSuccessorOperator, IThreeOptPermutationMoveOperator, ITabuMoveEvaluator {33 public class PreventReaddAndRemovalTranslocationMoveTabuChecker : SingleSuccessorOperator, IPermutationTranslocationMoveOperator, ITabuChecker { 34 34 public override bool CanChangeName { 35 35 get { return false; } 36 36 } 37 public ILookupParameter<T hreeOptMove> ThreeOptMoveParameter {38 get { return (LookupParameter<T hreeOptMove>)Parameters["ThreeOptMove"]; }37 public ILookupParameter<TranslocationMove> TranslocationMoveParameter { 38 get { return (LookupParameter<TranslocationMove>)Parameters["TranslocationMove"]; } 39 39 } 40 40 public ILookupParameter<Permutation> PermutationParameter { … … 51 51 } 52 52 53 public PreventReadd DeleteThreeOptTabuMoveEvaluator()53 public PreventReaddAndRemovalTranslocationMoveTabuChecker() 54 54 : base() { 55 Parameters.Add(new LookupParameter<T hreeOptMove>("ThreeOptMove", "The move to evaluate."));55 Parameters.Add(new LookupParameter<TranslocationMove>("TranslocationMove", "The move to evaluate.")); 56 56 Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu.")); 57 57 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation.")); … … 62 62 public override IOperation Apply() { 63 63 ItemList<IItem> tabuList = TabuListParameter.ActualValue; 64 T hreeOptMove move = ThreeOptMoveParameter.ActualValue;64 TranslocationMove move = TranslocationMoveParameter.ActualValue; 65 65 Permutation permutation = PermutationParameter.ActualValue; 66 66 int length = permutation.Length; … … 83 83 if (!isTabu) { 84 84 foreach (IItem tabuMove in tabuList) { 85 T hreeOptTabuMoveAttribute attribute = (tabuMove as ThreeOptTabuMoveAttribute);85 TranslocationMoveAttribute attribute = (tabuMove as TranslocationMoveAttribute); 86 86 if (attribute != null) { 87 87 // if previously deleted Edge1Source-Target is readded -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/PreventReaddTranslocationMoveTabuChecker.cs
r3231 r3232 29 29 30 30 namespace HeuristicLab.Encodings.PermutationEncoding { 31 [Item(" ThreeOptPreventEdgeReadding", "Prevents readding of previously deleted edges.")]31 [Item("PreventReaddTranslocationMoveTabuChecker", "Prevents readding of previously deleted edges.")] 32 32 [StorableClass] 33 public class PreventReaddT hreeOptTabuMoveEvaluator : SingleSuccessorOperator, IThreeOptPermutationMoveOperator, ITabuMoveEvaluator {33 public class PreventReaddTranslocationMoveTabuChecker : SingleSuccessorOperator, IPermutationTranslocationMoveOperator, ITabuChecker { 34 34 public override bool CanChangeName { 35 35 get { return false; } 36 36 } 37 public ILookupParameter<T hreeOptMove> ThreeOptMoveParameter {38 get { return (LookupParameter<T hreeOptMove>)Parameters["ThreeOptMove"]; }37 public ILookupParameter<TranslocationMove> TranslocationMoveParameter { 38 get { return (LookupParameter<TranslocationMove>)Parameters["TranslocationMove"]; } 39 39 } 40 40 public ILookupParameter<Permutation> PermutationParameter { … … 51 51 } 52 52 53 public PreventReaddT hreeOptTabuMoveEvaluator()53 public PreventReaddTranslocationMoveTabuChecker() 54 54 : base() { 55 Parameters.Add(new LookupParameter<T hreeOptMove>("ThreeOptMove", "The move to evaluate."));55 Parameters.Add(new LookupParameter<TranslocationMove>("TranslocationMove", "The move to evaluate.")); 56 56 Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu.")); 57 57 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation.")); … … 62 62 public override IOperation Apply() { 63 63 ItemList<IItem> tabuList = TabuListParameter.ActualValue; 64 T hreeOptMove move = ThreeOptMoveParameter.ActualValue;64 TranslocationMove move = TranslocationMoveParameter.ActualValue; 65 65 Permutation permutation = PermutationParameter.ActualValue; 66 66 int length = permutation.Length; … … 83 83 if (!isTabu) { 84 84 foreach (IItem tabuMove in tabuList) { 85 T hreeOptTabuMoveAttribute attribute = (tabuMove as ThreeOptTabuMoveAttribute);85 TranslocationMoveAttribute attribute = (tabuMove as TranslocationMoveAttribute); 86 86 if (attribute != null) { 87 87 // if previously deleted Edge1Source-Target is readded -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/PreventRemovalTranslocationMoveTabuChecker.cs
r3231 r3232 29 29 30 30 namespace HeuristicLab.Encodings.PermutationEncoding { 31 [Item(" ThreeOptPreventEdgeRemoval", "Prevents deleting of previously added edges.")]31 [Item("PreventRemovalTranslocationMoveTabuChecker", "Prevents deleting of previously added edges.")] 32 32 [StorableClass] 33 public class Prevent DeleteThreeOptTabuMoveEvaluator : SingleSuccessorOperator, IThreeOptPermutationMoveOperator, ITabuMoveEvaluator {33 public class PreventRemovalTranslocationMoveTabuChecker : SingleSuccessorOperator, IPermutationTranslocationMoveOperator, ITabuChecker { 34 34 public override bool CanChangeName { 35 35 get { return false; } 36 36 } 37 public ILookupParameter<T hreeOptMove> ThreeOptMoveParameter {38 get { return (LookupParameter<T hreeOptMove>)Parameters["ThreeOptMove"]; }37 public ILookupParameter<TranslocationMove> TranslocationMoveParameter { 38 get { return (LookupParameter<TranslocationMove>)Parameters["TranslocationMove"]; } 39 39 } 40 40 public ILookupParameter<Permutation> PermutationParameter { … … 51 51 } 52 52 53 public Prevent DeleteThreeOptTabuMoveEvaluator()53 public PreventRemovalTranslocationMoveTabuChecker() 54 54 : base() { 55 Parameters.Add(new LookupParameter<T hreeOptMove>("ThreeOptMove", "The move to evaluate."));55 Parameters.Add(new LookupParameter<TranslocationMove>("TranslocationMove", "The move to evaluate.")); 56 56 Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The variable to store if a move was tabu.")); 57 57 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation.")); … … 62 62 public override IOperation Apply() { 63 63 ItemList<IItem> tabuList = TabuListParameter.ActualValue; 64 T hreeOptMove move = ThreeOptMoveParameter.ActualValue;64 TranslocationMove move = TranslocationMoveParameter.ActualValue; 65 65 Permutation permutation = PermutationParameter.ActualValue; 66 66 int length = permutation.Length; … … 83 83 if (!isTabu) { 84 84 foreach (IItem tabuMove in tabuList) { 85 T hreeOptTabuMoveAttribute attribute = (tabuMove as ThreeOptTabuMoveAttribute);85 TranslocationMoveAttribute attribute = (tabuMove as TranslocationMoveAttribute); 86 86 if (attribute != null) { 87 87 // if previously added Edge3Source-Edge1Target is deleted -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/StochasticTranslocationMultiMoveGenerator.cs
r3231 r3232 28 28 29 29 namespace HeuristicLab.Encodings.PermutationEncoding { 30 [Item("StochasticT hreeOptMultiMoveGenerator", "Randomly samples n from all possible 3-opt movesfrom a given permutation.")]30 [Item("StochasticTranslocationMultiMoveGenerator", "Randomly samples n from all possible translocation and insertion moves (3-opt) from a given permutation.")] 31 31 [StorableClass] 32 public class StochasticT hreeOptMultiMoveGenerator : ThreeOptMoveGenerator, IStochasticOperator, IMultiMoveGenerator {32 public class StochasticTranslocationMultiMoveGenerator : TranslocationMoveGenerator, IStochasticOperator, IMultiMoveGenerator { 33 33 public ILookupParameter<IRandom> RandomParameter { 34 34 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } … … 43 43 } 44 44 45 public StochasticT hreeOptMultiMoveGenerator()45 public StochasticTranslocationMultiMoveGenerator() 46 46 : base() { 47 47 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); … … 49 49 } 50 50 51 public static T hreeOptMove[] Apply(Permutation permutation, IRandom random, int sampleSize) {51 public static TranslocationMove[] Apply(Permutation permutation, IRandom random, int sampleSize) { 52 52 int length = permutation.Length; 53 T hreeOptMove[] moves = new ThreeOptMove[sampleSize];53 TranslocationMove[] moves = new TranslocationMove[sampleSize]; 54 54 for (int i = 0; i < sampleSize; i++) { 55 55 moves[i] = StochasticThreeOptSingleMoveGenerator.Apply(permutation, random); … … 58 58 } 59 59 60 protected override T hreeOptMove[] GenerateMoves(Permutation permutation) {60 protected override TranslocationMove[] GenerateMoves(Permutation permutation) { 61 61 IRandom random = RandomParameter.ActualValue; 62 62 return Apply(permutation, random, SampleSizeParameter.ActualValue.Value); -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/StochasticTranslocationSingleMoveGenerator.cs
r3231 r3232 28 28 29 29 namespace HeuristicLab.Encodings.PermutationEncoding { 30 [Item("StochasticT hreeOptSingleMoveGenerator", "Randomly samples one from all possible 3-opt movesfrom a given permutation.")]30 [Item("StochasticTranslocationSingleMoveGenerator", "Randomly samples one from all possible translocation and insertion moves (3-opt) from a given permutation.")] 31 31 [StorableClass] 32 public class StochasticThreeOptSingleMoveGenerator : T hreeOptMoveGenerator, IStochasticOperator, ISingleMoveGenerator {32 public class StochasticThreeOptSingleMoveGenerator : TranslocationMoveGenerator, IStochasticOperator, ISingleMoveGenerator { 33 33 public ILookupParameter<IRandom> RandomParameter { 34 34 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } … … 40 40 } 41 41 42 public static T hreeOptMove Apply(Permutation permutation, IRandom random) {42 public static TranslocationMove Apply(Permutation permutation, IRandom random) { 43 43 int length = permutation.Length; 44 44 int index1, index2, index3; … … 51 51 } while (index3 == index1); 52 52 53 return new T hreeOptMove(index1, index2, index3);53 return new TranslocationMove(index1, index2, index3); 54 54 } 55 55 56 protected override T hreeOptMove[] GenerateMoves(Permutation permutation) {56 protected override TranslocationMove[] GenerateMoves(Permutation permutation) { 57 57 IRandom random = RandomParameter.ActualValue; 58 return new T hreeOptMove[] { Apply(permutation, random) };58 return new TranslocationMove[] { Apply(permutation, random) }; 59 59 } 60 60 } -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/TranslocationMove.cs
r3231 r3232 24 24 25 25 namespace HeuristicLab.Encodings.PermutationEncoding { 26 [Item("T hreeOptMove", "A move that changes three edges by performing a translocation.")]26 [Item("TranslocationMove", "A move that changes three edges by performing a translocation.")] 27 27 [StorableClass] 28 public class T hreeOptMove : ThreeIndexMove {29 public T hreeOptMove()28 public class TranslocationMove : ThreeIndexMove { 29 public TranslocationMove() 30 30 : base() { 31 31 } 32 32 33 public T hreeOptMove(int index1, int index2, int index3)33 public TranslocationMove(int index1, int index2, int index3) 34 34 : base(index1, index2, index3, null) { 35 35 } 36 36 37 public T hreeOptMove(int index1, int index2, int index3, Permutation permutation)37 public TranslocationMove(int index1, int index2, int index3, Permutation permutation) 38 38 : base(index1, index2, index3, permutation) { 39 39 } -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/TranslocationMoveAttribute.cs
r3231 r3232 24 24 25 25 namespace HeuristicLab.Encodings.PermutationEncoding { 26 [Item("T hreeOptTabuMoveAttribute", "Specifies the tabu attributes for a 3-opt move.")]26 [Item("TranslocationMoveAttribute", "Specifies the tabu attributes for a translocation and insertion move (3-opt).")] 27 27 [StorableClass] 28 public class T hreeOptTabuMoveAttribute : Item {28 public class TranslocationMoveAttribute : Item { 29 29 [Storable] 30 30 public int Edge1Source { get; private set; } … … 41 41 42 42 [StorableConstructor] 43 private T hreeOptTabuMoveAttribute(bool deserializing)43 private TranslocationMoveAttribute(bool deserializing) 44 44 : base() { 45 45 } 46 46 47 public T hreeOptTabuMoveAttribute()47 public TranslocationMoveAttribute() 48 48 : this(-1, -1, -1, -1, -1, -1) { } 49 49 50 public T hreeOptTabuMoveAttribute(int edge1Source, int edge1Target, int edge2Source, int edge2Target, int edge3Source, int edge3Target)50 public TranslocationMoveAttribute(int edge1Source, int edge1Target, int edge2Source, int edge2Target, int edge3Source, int edge3Target) 51 51 : base() { 52 52 Edge1Source = edge1Source; … … 59 59 60 60 public override IDeepCloneable Clone(Cloner cloner) { 61 T hreeOptTabuMoveAttribute clone = (ThreeOptTabuMoveAttribute)base.Clone(cloner);61 TranslocationMoveAttribute clone = (TranslocationMoveAttribute)base.Clone(cloner); 62 62 clone.Edge1Source = Edge1Source; 63 63 clone.Edge1Target = Edge1Target; -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/TranslocationMoveGenerator.cs
r3231 r3232 28 28 29 29 namespace HeuristicLab.Encodings.PermutationEncoding { 30 [Item("T hreeOptMoveGenerator", "Base class for move generators that produce 3-opt moves.")]30 [Item("TranslocationMoveGenerator", "Base class for move generators that produce translocation moves (3-opt).")] 31 31 [StorableClass] 32 public abstract class T hreeOptMoveGenerator : SingleSuccessorOperator, IThreeOptPermutationMoveOperator, IMoveGenerator {32 public abstract class TranslocationMoveGenerator : SingleSuccessorOperator, IPermutationTranslocationMoveOperator, IMoveGenerator { 33 33 public override bool CanChangeName { 34 34 get { return false; } … … 37 37 get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } 38 38 } 39 public ILookupParameter<T hreeOptMove> ThreeOptMoveParameter {40 get { return (LookupParameter<T hreeOptMove>)Parameters["ThreeOptMove"]; }39 public ILookupParameter<TranslocationMove> TranslocationMoveParameter { 40 get { return (LookupParameter<TranslocationMove>)Parameters["TranslocationMove"]; } 41 41 } 42 42 protected ScopeParameter CurrentScopeParameter { … … 44 44 } 45 45 46 public T hreeOptMoveGenerator()46 public TranslocationMoveGenerator() 47 47 : base() { 48 48 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The permutation for which moves should be generated.")); 49 Parameters.Add(new LookupParameter<T hreeOptMove>("ThreeOptMove", "The moves that should be generated in subscopes."));49 Parameters.Add(new LookupParameter<TranslocationMove>("TranslocationMove", "The moves that should be generated in subscopes.")); 50 50 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 51 51 } … … 53 53 public override IOperation Apply() { 54 54 Permutation p = PermutationParameter.ActualValue; 55 T hreeOptMove[] moves = GenerateMoves(p);55 TranslocationMove[] moves = GenerateMoves(p); 56 56 Scope[] moveScopes = new Scope[moves.Length]; 57 57 for (int i = 0; i < moveScopes.Length; i++) { 58 58 moveScopes[i] = new Scope(i.ToString()); 59 moveScopes[i].Variables.Add(new Variable(T hreeOptMoveParameter.ActualName, moves[i]));59 moveScopes[i].Variables.Add(new Variable(TranslocationMoveParameter.ActualName, moves[i])); 60 60 } 61 61 CurrentScopeParameter.ActualValue.SubScopes.AddRange(moveScopes); … … 63 63 } 64 64 65 protected abstract T hreeOptMove[] GenerateMoves(Permutation permutation);65 protected abstract TranslocationMove[] GenerateMoves(Permutation permutation); 66 66 } 67 67 } -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/TranslocationMoveMaker.cs
r3231 r3232 29 29 30 30 namespace HeuristicLab.Encodings.PermutationEncoding { 31 [Item("T hreeOptMoveMaker", "Peforms a 3-opt moveon a given permutation and updates the quality.")]31 [Item("TranslocationMoveMaker", "Peforms a translocation or insertion move (3-opt) on a given permutation and updates the quality.")] 32 32 [StorableClass] 33 public class T hreeOptMoveMaker : SingleSuccessorOperator, IThreeOptPermutationMoveOperator, IMoveMaker {33 public class TranslocationMoveMaker : SingleSuccessorOperator, IPermutationTranslocationMoveOperator, IMoveMaker { 34 34 public override bool CanChangeName { 35 35 get { return false; } … … 41 41 get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; } 42 42 } 43 public ILookupParameter<T hreeOptMove> ThreeOptMoveParameter {44 get { return (ILookupParameter<T hreeOptMove>)Parameters["ThreeOptMove"]; }43 public ILookupParameter<TranslocationMove> TranslocationMoveParameter { 44 get { return (ILookupParameter<TranslocationMove>)Parameters["TranslocationMove"]; } 45 45 } 46 46 public ILookupParameter<Permutation> PermutationParameter { … … 48 48 } 49 49 50 public T hreeOptMoveMaker()50 public TranslocationMoveMaker() 51 51 : base() { 52 52 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution.")); 53 Parameters.Add(new LookupParameter<T hreeOptMove>("ThreeOptMove", "The move to evaluate."));53 Parameters.Add(new LookupParameter<TranslocationMove>("TranslocationMove", "The move to evaluate.")); 54 54 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 55 55 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation.")); … … 57 57 58 58 public override IOperation Apply() { 59 T hreeOptMove move = ThreeOptMoveParameter.ActualValue;59 TranslocationMove move = TranslocationMoveParameter.ActualValue; 60 60 Permutation permutation = PermutationParameter.ActualValue; 61 61 DoubleValue moveQuality = MoveQualityParameter.ActualValue; -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/TranslocationMoveTabuMaker.cs
r3231 r3232 29 29 30 30 namespace HeuristicLab.Encodings.PermutationEncoding { 31 [Item("T hreeOptTabuMoveMaker", "Declares a given 3-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.")]31 [Item("TranslocationMoveTabuMaker", "Declares a given translocation or insertion move (3-opt) as tabu, by adding its attributes to the tabu list.")] 32 32 [StorableClass] 33 public class T hreeOptTabuMoveMaker : TabuMoveMaker, IThreeOptPermutationMoveOperator {33 public class TranslocationMoveTabuMaker : TabuMaker, IPermutationTranslocationMoveOperator { 34 34 public override bool CanChangeName { 35 35 get { return false; } … … 38 38 get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; } 39 39 } 40 public ILookupParameter<T hreeOptMove> ThreeOptMoveParameter {41 get { return (LookupParameter<T hreeOptMove>)Parameters["ThreeOptMove"]; }40 public ILookupParameter<TranslocationMove> TranslocationMoveParameter { 41 get { return (LookupParameter<TranslocationMove>)Parameters["TranslocationMove"]; } 42 42 } 43 43 44 public T hreeOptTabuMoveMaker()44 public TranslocationMoveTabuMaker() 45 45 : base() { 46 Parameters.Add(new LookupParameter<T hreeOptMove>("ThreeOptMove", "The move that was made."));46 Parameters.Add(new LookupParameter<TranslocationMove>("TranslocationMove", "The move that was made.")); 47 47 Parameters.Add(new LookupParameter<Permutation>("Permutation", "The solution as permutation.")); 48 48 } 49 49 50 50 protected override IItem GetTabuAttribute() { 51 T hreeOptMove move = ThreeOptMoveParameter.ActualValue;51 TranslocationMove move = TranslocationMoveParameter.ActualValue; 52 52 Permutation permutation = PermutationParameter.ActualValue; 53 53 if (move.Index3 > move.Index1) 54 return new T hreeOptTabuMoveAttribute(permutation.GetCircular(move.Index1 - 1),54 return new TranslocationMoveAttribute(permutation.GetCircular(move.Index1 - 1), 55 55 permutation[move.Index1], 56 56 permutation[move.Index2], … … 59 59 permutation.GetCircular(move.Index3 + move.Index2 - move.Index1 + 1)); 60 60 else 61 return new T hreeOptTabuMoveAttribute(permutation.GetCircular(move.Index1 - 1),61 return new TranslocationMoveAttribute(permutation.GetCircular(move.Index1 - 1), 62 62 permutation[move.Index1], 63 63 permutation[move.Index2],
Note: See TracChangeset
for help on using the changeset viewer.