- Timestamp:
- 04/14/10 03:52:07 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3
- Files:
-
- 1 added
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj
r3118 r3340 106 106 <Compile Include="Moves\OneBitflipMove\OneBitflipMoveGenerator.cs" /> 107 107 <Compile Include="Moves\OneBitflipMove\OneBitflipMoveMaker.cs" /> 108 <Compile Include="Moves\OneBitflipMove\OneBitflipTabuMoveMaker.cs" /> 109 <Compile Include="Moves\OneBitflipMove\PreventOneBitflipTabuMoveEvaluator.cs" /> 108 <Compile Include="Moves\OneBitflipMove\OneBitflipMoveTabuChecker.cs" /> 109 <Compile Include="Moves\OneBitflipMove\OneBitflipMoveTabuMaker.cs" /> 110 <Compile Include="Moves\OneBitflipMove\OneBitflipMoveAttribute.cs" /> 110 111 <Compile Include="Moves\OneBitflipMove\StochasticOneBitflipMultiMoveGenerator.cs" /> 111 112 <Compile Include="Moves\OneBitflipMove\StochasticOneBitflipSingleMoveGenerator.cs" /> -
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 } -
trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Moves/OneBitflipMove/OneBitflipMoveTabuMaker.cs
r3339 r3340 29 29 30 30 namespace HeuristicLab.Encodings.BinaryVectorEncoding { 31 [Item("OneBitflip TabuMoveMaker", "Declares a given one bitflip 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("OneBitflipMoveTabuMaker", "Declares a given one bitflip 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 OneBitflip TabuMoveMaker : TabuMaker, IOneBitflipMoveOperator {33 public class OneBitflipMoveTabuMaker : TabuMaker, IOneBitflipMoveOperator { 34 34 public ILookupParameter<BinaryVector> BinaryVectorParameter { 35 35 get { return (ILookupParameter<BinaryVector>)Parameters["BinaryVector"]; } … … 39 39 } 40 40 41 public OneBitflip TabuMoveMaker()41 public OneBitflipMoveTabuMaker() 42 42 : base() { 43 43 Parameters.Add(new LookupParameter<BinaryVector>("BinaryVector", "The solution as BinaryVector.")); … … 45 45 } 46 46 47 protected override IItem GetTabuAttribute() { 48 return OneBitflipMoveParameter.ActualValue; 47 protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality) { 48 double baseQuality = moveQuality; 49 if (maximization && quality > moveQuality || !maximization && quality < moveQuality) baseQuality = quality; 50 return new OneBitflipMoveAttribute(OneBitflipMoveParameter.ActualValue.Index, baseQuality); 49 51 } 50 52
Note: See TracChangeset
for help on using the changeset viewer.