Changeset 3340 for trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveTabuChecker.cs
- Timestamp:
- 04/14/10 03:52:07 (15 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveTabuChecker.cs
r3339 r3340 29 29 30 30 namespace HeuristicLab.Encodings.BinaryVectorEncoding { 31 [Item(" PreventOneBitflipTabuMoveEvaluator", "Prevents peforming a one bitflip move again.")]31 [Item("OneBitflipMoveTabuChecker", "Prevents peforming a one bitflip move again.")] 32 32 [StorableClass] 33 public class PreventOneBitflipTabuMoveEvaluator : SingleSuccessorOperator, IOneBitflipMoveOperator, ITabuChecker {33 public class OneBitflipMoveTabuChecker : SingleSuccessorOperator, IOneBitflipMoveOperator, ITabuChecker { 34 34 public ILookupParameter<OneBitflipMove> OneBitflipMoveParameter { 35 35 get { return (LookupParameter<OneBitflipMove>)Parameters["OneBitflipMove"]; } … … 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 PreventOneBitflipTabuMoveEvaluator() 56 public BoolValue UseAspirationCriterion { 57 get { return UseAspirationCriterionParameter.Value; } 58 set { UseAspirationCriterionParameter.Value = value; } 59 } 60 61 public OneBitflipMoveTabuChecker() 51 62 : base() { 52 63 Parameters.Add(new LookupParameter<OneBitflipMove>("OneBitflipMove", "The move to evaluate.")); … … 54 65 Parameters.Add(new LookupParameter<BinaryVector>("BinaryVector", "The solution as permutation.")); 55 66 Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list.")); 56 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope.")); 67 Parameters.Add(new ValueParameter<BoolValue>("UseAspirationCriterion", "Whether to use the aspiration criterion or not.", new BoolValue(true))); 68 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, else if it is a minimization problem.")); 69 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the current move.")); 57 70 } 58 71 … … 60 73 ItemList<IItem> tabuList = TabuListParameter.ActualValue; 61 74 OneBitflipMove move = OneBitflipMoveParameter.ActualValue; 75 double moveQuality = MoveQualityParameter.ActualValue.Value; 76 bool maximization = MaximizationParameter.ActualValue.Value; 77 bool useAspiration = UseAspirationCriterion.Value; 62 78 bool isTabu = false; 63 79 foreach (IItem tabuMove in tabuList) { 64 OneBitflipMove attribute = (tabuMove as OneBitflipMove);80 OneBitflipMoveAttribute attribute = (tabuMove as OneBitflipMoveAttribute); 65 81 if (attribute != null) { 66 if (attribute.Index == move.Index) { 67 isTabu = true; 68 break; 82 if (!useAspiration 83 || maximization && moveQuality <= attribute.MoveQuality 84 || !maximization && moveQuality >= attribute.MoveQuality) { 85 if (attribute.Index == move.Index) { 86 isTabu = true; 87 break; 88 } 69 89 } 70 90 }
Note: See TracChangeset
for help on using the changeset viewer.