- Timestamp:
- 04/14/10 03:52:07 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves
- Files:
-
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/AdditiveMoveTabuAttribute.cs
r3192 r3340 33 33 [Storable] 34 34 public double MovedPosition { get; protected set; } 35 [Storable] 36 public double MoveQuality { get; protected set; } 35 37 36 38 [StorableConstructor] … … 43 45 OriginalPosition = 0; 44 46 MovedPosition = 0; 47 MoveQuality = 0; 45 48 } 46 49 47 public AdditiveMoveTabuAttribute(int dimension, double originalPosition, double movedPosition )50 public AdditiveMoveTabuAttribute(int dimension, double originalPosition, double movedPosition, double moveQuality) 48 51 : base() { 49 52 Dimension = dimension; 50 53 OriginalPosition = originalPosition; 51 54 MovedPosition = movedPosition; 55 MoveQuality = moveQuality; 52 56 } 53 57 … … 57 61 clone.OriginalPosition = OriginalPosition; 58 62 clone.MovedPosition = MovedPosition; 63 clone.MoveQuality = MoveQuality; 59 64 return clone; 60 65 } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/AdditiveMoveTabuChecker.cs
r3339 r3340 29 29 30 30 namespace HeuristicLab.Encodings.RealVectorEncoding { 31 [Item(" PreventFallBackToSkippedPositions", "Prevents falling back into ranges that have been moved over before.")]31 [Item("AdditiveMoveTabuChecker", "Prevents falling back into ranges that have been moved over before.")] 32 32 [StorableClass] 33 public class PreventFallBackToSkippedPositions: SingleSuccessorOperator, IAdditiveRealVectorMoveOperator, ITabuChecker {33 public class AdditiveMoveTabuChecker : SingleSuccessorOperator, IAdditiveRealVectorMoveOperator, ITabuChecker { 34 34 public ILookupParameter<AdditiveMove> AdditiveMoveParameter { 35 35 get { return (LookupParameter<AdditiveMove>)Parameters["AdditiveMove"]; } … … 44 44 get { return (ILookupParameter<BoolValue>)Parameters["MoveTabu"]; } 45 45 } 46 private ScopeParameter CurrentScopeParameter { 47 get { return (ScopeParameter)Parameters["CurrentScope"]; } 46 public IValueLookupParameter<BoolValue> MaximizationParameter { 47 get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 48 } 49 public ILookupParameter<DoubleValue> MoveQualityParameter { 50 get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; } 51 } 52 public ValueParameter<BoolValue> UseAspirationCriterionParameter { 53 get { return (ValueParameter<BoolValue>)Parameters["UseAspirationCriterion"]; } 48 54 } 49 55 50 public PreventFallBackToSkippedPositions() 56 public BoolValue UseAspirationCriterion { 57 get { return UseAspirationCriterionParameter.Value; } 58 set { UseAspirationCriterionParameter.Value = value; } 59 } 60 61 62 public AdditiveMoveTabuChecker() 51 63 : base() { 52 64 Parameters.Add(new LookupParameter<AdditiveMove>("AdditiveMove", "The move to evaluate.")); … … 54 66 Parameters.Add(new LookupParameter<RealVector>("RealVector", "The solution as real vector.")); 55 67 Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list.")); 56 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope.")); 68 Parameters.Add(new ValueParameter<BoolValue>("UseAspirationCriterion", "Whether to use the aspiration criterion or not.", new BoolValue(true))); 69 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, else if it is a minimization problem.")); 70 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the current move.")); 57 71 } 58 72 … … 61 75 AdditiveMove move = AdditiveMoveParameter.ActualValue; 62 76 RealVector vector = RealVectorParameter.ActualValue; 77 double moveQuality = MoveQualityParameter.ActualValue.Value; 78 bool maximization = MaximizationParameter.ActualValue.Value; 79 bool useAspiration = UseAspirationCriterion.Value; 63 80 bool isTabu = false; 64 81 foreach (IItem tabuMove in tabuList) { 65 82 AdditiveMoveTabuAttribute attribute = (tabuMove as AdditiveMoveTabuAttribute); 66 83 if (attribute != null && attribute.Dimension == move.Dimension) { 67 double newPos = vector[move.Dimension] + move.MoveDistance; 68 if (Math.Min(attribute.MovedPosition, attribute.OriginalPosition) < newPos 69 && newPos < Math.Max(attribute.MovedPosition, attribute.OriginalPosition)) { 70 isTabu = true; 71 break; 84 if (!useAspiration 85 || maximization && moveQuality <= attribute.MoveQuality 86 || !maximization && moveQuality >= attribute.MoveQuality) { 87 88 double newPos = vector[move.Dimension] + move.MoveDistance; 89 if (Math.Min(attribute.MovedPosition, attribute.OriginalPosition) < newPos 90 && newPos < Math.Max(attribute.MovedPosition, attribute.OriginalPosition)) { 91 isTabu = true; 92 break; 93 } 72 94 } 73 95 } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/AdditiveMoveTabuMaker.cs
r3339 r3340 29 29 30 30 namespace HeuristicLab.Encodings.RealVectorEncoding { 31 [Item("Additive TabuMoveMaker", "Sets the move tabu.")]31 [Item("AdditiveMoveTabuMaker", "Sets the move tabu.")] 32 32 [StorableClass] 33 public class Additive TabuMoveMaker : TabuMaker, IAdditiveRealVectorMoveOperator {33 public class AdditiveMoveTabuMaker : TabuMaker, IAdditiveRealVectorMoveOperator { 34 34 public ILookupParameter<AdditiveMove> AdditiveMoveParameter { 35 35 get { return (ILookupParameter<AdditiveMove>)Parameters["AdditiveMove"]; } … … 39 39 } 40 40 41 public Additive TabuMoveMaker()41 public AdditiveMoveTabuMaker() 42 42 : base() { 43 43 Parameters.Add(new LookupParameter<AdditiveMove>("AdditiveMove", "The move to evaluate.")); … … 45 45 } 46 46 47 protected override IItem GetTabuAttribute( ) {47 protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) { 48 48 AdditiveMove move = AdditiveMoveParameter.ActualValue; 49 49 RealVector vector = RealVectorParameter.ActualValue; 50 return new AdditiveMoveTabuAttribute(move.Dimension, vector[move.Dimension], vector[move.Dimension] + move.MoveDistance); 50 double baseQuality = moveQuality; 51 if (maximization && quality > moveQuality || !maximization && quality < moveQuality) baseQuality = quality; 52 return new AdditiveMoveTabuAttribute(move.Dimension, vector[move.Dimension], vector[move.Dimension] + move.MoveDistance, baseQuality); 51 53 } 52 54
Note: See TracChangeset
for help on using the changeset viewer.