Changeset 3104
- Timestamp:
- 03/18/10 22:57:22 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs
r3100 r3104 180 180 op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged); 181 181 } 182 foreach (ITabuMoveEvaluator op in Problem.Operators.OfType<ITabuMoveEvaluator>()) { 183 op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuMoveEvaluator_MoveTabuParameter_ActualNameChanged); 184 } 182 185 ParameterizeSolutionsCreator(); 183 Parameterize TSMainLoop();186 ParameterizeMainLoop(); 184 187 ParameterizeMoveEvaluator(); 185 188 ParameterizeMoveMaker(); … … 196 199 ParameterizeStochasticOperator(Problem.Evaluator); 197 200 ParameterizeSolutionsCreator(); 198 Parameterize TSMainLoop();201 ParameterizeMainLoop(); 199 202 ParameterizeMoveEvaluator(); 200 203 ParameterizeMoveMaker(); … … 210 213 op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged); 211 214 } 215 foreach (ITabuMoveEvaluator op in Problem.Operators.OfType<ITabuMoveEvaluator>()) { 216 op.MoveTabuParameter.ActualNameChanged -= new EventHandler(TabuMoveEvaluator_MoveTabuParameter_ActualNameChanged); 217 op.MoveTabuParameter.ActualNameChanged += new EventHandler(TabuMoveEvaluator_MoveTabuParameter_ActualNameChanged); 218 } 212 219 IMoveGenerator oldMoveGenerator = MoveGenerator; 213 220 UpdateMoveGenerator(); 214 221 if (oldMoveGenerator == MoveGenerator) // in this case MoveGeneratorParameter_ValueChanged did not fire 215 222 UpdateMoveParameters(); 216 Parameterize TSMainLoop();223 ParameterizeMainLoop(); 217 224 ParameterizeMoveEvaluator(); 218 225 ParameterizeMoveMaker(); … … 220 227 } 221 228 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 222 Parameterize TSMainLoop();229 ParameterizeMainLoop(); 223 230 ParameterizeMoveEvaluator(); 224 231 ParameterizeMoveMaker(); … … 228 235 } 229 236 private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) { 230 Parameterize TSMainLoop();237 ParameterizeMainLoop(); 231 238 ParameterizeMoveEvaluator(); 232 239 ParameterizeMoveMaker(); 233 240 } 234 241 private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) { 235 ParameterizeTSMainLoop(); 236 ParameterizeMoveEvaluator(); 237 ParameterizeMoveMaker(); 242 ParameterizeMainLoop(); 243 ParameterizeMoveEvaluator(); 244 ParameterizeMoveMaker(); 245 } 246 private void TabuMoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) { 247 ParameterizeMainLoop(); 248 } 249 private void TabuMoveEvaluator_MoveTabuParameter_ActualNameChanged(object sender, EventArgs e) { 250 ParameterizeMainLoop(); 238 251 } 239 252 #endregion … … 250 263 MoveGeneratorParameter.ValueChanged += new EventHandler(MoveGeneratorParameter_ValueChanged); 251 264 MoveEvaluatorParameter.ValueChanged += new EventHandler(MoveEvaluatorParameter_ValueChanged); 265 TabuMoveEvaluatorParameter.ValueChanged += new EventHandler(TabuMoveEvaluatorParameter_ValueChanged); 252 266 } 253 267 private void UpdateMoveGenerator() { … … 313 327 SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name; 314 328 } 315 private void Parameterize TSMainLoop() {329 private void ParameterizeMainLoop() { 316 330 MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 317 331 MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 318 332 if (MoveEvaluator != null) 319 333 MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName; 334 if (TabuMoveEvaluator != null) 335 MainLoop.MoveTabuParameter.ActualName = TabuMoveEvaluator.MoveTabuParameter.ActualName; 320 336 } 321 337 private void ParameterizeStochasticOperator(IOperator op) { -
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearchMainLoop.cs
r3100 r3104 48 48 get { return (LookupParameter<DoubleValue>)Parameters["MoveQuality"]; } 49 49 } 50 public LookupParameter<BoolValue> MoveTabuParameter { 51 get { return (LookupParameter<BoolValue>)Parameters["MoveTabu"]; } 52 } 50 53 public ValueLookupParameter<IntValue> MaximumIterationsParameter { 51 54 get { return (ValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; } … … 88 91 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution.")); 89 92 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move.")); 93 Parameters.Add(new LookupParameter<BoolValue>("MoveTabu", "The value that indicates if a move is tabu or not.")); 90 94 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.")); 91 95 Parameters.Add(new ValueLookupParameter<IntValue>("TabuTenure", "The length of the tabu list, and also means the number of iterations a move is kept tabu")); -
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj
r3098 r3104 111 111 <Compile Include="Moves\ThreeOpt\ThreeOptMove.cs" /> 112 112 <Compile Include="Moves\ThreeOpt\ThreeOptMoveGenerator.cs" /> 113 <Compile Include="Moves\TwoOpt\PreventReaddTwoOptTabuMoveEvaluator.cs" /> 113 114 <Compile Include="Moves\TwoOpt\StochasticTwoOptSingleMoveGenerator.cs" /> 114 115 <Compile Include="Moves\TwoOpt\ExhaustiveTwoOptMoveGenerator.cs"> … … 127 128 </Compile> 128 129 <Compile Include="Moves\TwoOpt\TwoOptTabuMoveAttribute.cs" /> 129 <Compile Include="Moves\TwoOpt\ TwoOptTabuMoveEvaluator.cs" />130 <Compile Include="Moves\TwoOpt\PreventReaddDeleteTwoOptTabuMoveEvaluator.cs" /> 130 131 <Compile Include="Moves\TwoOpt\TwoOptTabuMoveMaker.cs" /> 131 132 <Compile Include="PermutationManipulator.cs" /> -
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 -
trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r3098 r3104 112 112 <Compile Include="Interfaces\ITabuMoveEvaluator.cs" /> 113 113 <Compile Include="Interfaces\ITabuMoveMaker.cs" /> 114 <Compile Include="TabuMoveMaker.cs" /> 114 115 <Compile Include="UserDefinedAlgorithm.cs" /> 115 116 <Compile Include="EngineAlgorithm.cs" /> -
trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ITabuMoveEvaluator.cs
r3044 r3104 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 23 24 24 25 namespace HeuristicLab.Optimization { 25 26 public interface ITabuMoveEvaluator : IOperator { 27 ILookupParameter<BoolValue> MoveTabuParameter { get; } 26 28 } 27 29 }
Note: See TracChangeset
for help on using the changeset viewer.