Changeset 3145
- Timestamp:
- 03/20/10 20:16:18 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs
r3134 r3145 103 103 #endregion 104 104 105 [StorableConstructor] 106 private LocalSearch(bool deserializing) : base() { } 105 107 public LocalSearch() 106 108 : base() { … … 137 139 } 138 140 139 [StorableConstructor]140 private LocalSearch(bool deserializing) : base() { }141 142 141 public override IDeepCloneable Clone(Cloner cloner) { 143 142 LocalSearch clone = (LocalSearch)base.Clone(cloner); … … 156 155 ParameterizeSolutionsCreator(); 157 156 ParameterizeMainLoop(); 158 ParameterizeMoveEvaluator ();159 ParameterizeMoveMaker ();157 ParameterizeMoveEvaluators(); 158 ParameterizeMoveMakers(); 160 159 UpdateMoveGenerator(); 161 160 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); … … 171 170 ParameterizeSolutionsCreator(); 172 171 ParameterizeMainLoop(); 173 ParameterizeMoveEvaluator ();174 ParameterizeMoveMaker ();172 ParameterizeMoveEvaluators(); 173 ParameterizeMoveMakers(); 175 174 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 176 175 base.Problem_EvaluatorChanged(sender, e); … … 179 178 ParameterizeStochasticOperator(Problem.Visualizer); 180 179 ParameterizeMainLoop(); 180 if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged); 181 181 base.Problem_VisualizerChanged(sender, e); 182 182 } … … 194 194 UpdateMoveParameters(); 195 195 ParameterizeMainLoop(); 196 ParameterizeMoveEvaluator ();197 ParameterizeMoveMaker ();196 ParameterizeMoveEvaluators(); 197 ParameterizeMoveMakers(); 198 198 base.Problem_OperatorsChanged(sender, e); 199 199 } 200 200 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 201 201 ParameterizeMainLoop(); 202 ParameterizeMoveEvaluator ();203 ParameterizeMoveMaker ();202 ParameterizeMoveEvaluators(); 203 ParameterizeMoveMakers(); 204 204 } 205 205 private void MoveGeneratorParameter_ValueChanged(object sender, EventArgs e) { … … 208 208 private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) { 209 209 ParameterizeMainLoop(); 210 ParameterizeMoveEvaluator ();211 ParameterizeMoveMaker ();210 ParameterizeMoveEvaluators(); 211 ParameterizeMoveMakers(); 212 212 } 213 213 private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) { 214 214 ParameterizeMainLoop(); 215 ParameterizeMoveEvaluator(); 216 ParameterizeMoveMaker(); 215 ParameterizeMoveEvaluators(); 216 ParameterizeMoveMakers(); 217 } 218 private void Visualizer_VisualizationParameter_ActualNameChanged(object sender, EventArgs e) { 219 ParameterizeMainLoop(); 217 220 } 218 221 #endregion … … 237 240 MoveGeneratorParameter.ValidValues.Add(generator); 238 241 } 239 if (oldMoveGenerator != null && MoveGeneratorParameter.ValidValues.Any(x => x.GetType() == oldMoveGenerator.GetType())) 240 MoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType()); 242 if (oldMoveGenerator != null) { 243 IMoveGenerator newMoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType()); 244 if (newMoveGenerator != null) MoveGenerator = newMoveGenerator; 245 } 241 246 if (MoveGenerator == null) { 242 247 ClearMoveParameters(); … … 279 284 } 280 285 private void ParameterizeMainLoop() { 286 MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 281 287 MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 282 288 MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 283 289 if (MoveEvaluator != null) 284 290 MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName; 285 MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;286 291 MainLoop.VisualizerParameter.ActualName = Problem.VisualizerParameter.Name; 287 MainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName; 292 if (Problem.Visualizer != null) 293 MainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName; 288 294 } 289 295 private void ParameterizeStochasticOperator(IOperator op) { … … 291 297 ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName; 292 298 } 293 private void ParameterizeMoveEvaluator () {299 private void ParameterizeMoveEvaluators() { 294 300 foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) { 295 301 op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 296 302 } 297 303 } 298 private void ParameterizeMoveMaker () {304 private void ParameterizeMoveMakers() { 299 305 foreach (IMoveMaker op in Problem.Operators.OfType<IMoveMaker>()) { 300 306 op.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; -
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchMainLoop.cs
r3143 r3145 35 35 [Item("LocalSearchMainLoop", "An operator which represents the main loop of a best improvement local search (if only a single move is generated in each iteration it is a first improvement local search).")] 36 36 [StorableClass] 37 public class LocalSearchMainLoop : AlgorithmOperator {37 public sealed class LocalSearchMainLoop : AlgorithmOperator { 38 38 #region Parameter properties 39 39 public ValueLookupParameter<IRandom> RandomParameter { … … 82 82 #endregion 83 83 84 [StorableConstructor] 85 private LocalSearchMainLoop(bool deserializing) : base() { } 84 86 public LocalSearchMainLoop() 85 87 : base() { 88 Initialize(); 89 } 90 91 private void Initialize() { 86 92 #region Create parameters 87 93 Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator.")); -
trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs
r3131 r3145 35 35 [Item("Simulated Annealing", "A simulated annealing algorithm.")] 36 36 [Creatable("Algorithms")] 37 public class SimulatedAnnealing : EngineAlgorithm {37 public sealed class SimulatedAnnealing : EngineAlgorithm { 38 38 #region Problem Properties 39 39 public override Type ProblemType { … … 132 132 #endregion 133 133 134 [StorableConstructor] 135 private SimulatedAnnealing(bool deserializing) : base() { } 134 136 public SimulatedAnnealing() 135 137 : base() { … … 173 175 } 174 176 175 [StorableConstructor]176 private SimulatedAnnealing(bool deserializing) : base() { }177 178 177 public override IDeepCloneable Clone(Cloner cloner) { 179 178 SimulatedAnnealing clone = (SimulatedAnnealing)base.Clone(cloner); … … 213 212 base.Problem_EvaluatorChanged(sender, e); 214 213 } 214 protected override void Problem_VisualizerChanged(object sender, EventArgs e) { 215 ParameterizeStochasticOperator(Problem.Visualizer); 216 ParameterizeMainLoop(); 217 if (Problem.Visualizer != null) Problem.Visualizer.VisualizationParameter.ActualNameChanged += new EventHandler(Visualizer_VisualizationParameter_ActualNameChanged); 218 base.Problem_VisualizerChanged(sender, e); 219 } 215 220 protected override void Problem_OperatorsChanged(object sender, EventArgs e) { 216 221 foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op); … … 248 253 ParameterizeMoveEvaluators(); 249 254 ParameterizeMoveMakers(); 255 } 256 private void Visualizer_VisualizationParameter_ActualNameChanged(object sender, EventArgs e) { 257 ParameterizeMainLoop(); 250 258 } 251 259 #endregion … … 325 333 } 326 334 private void ParameterizeMainLoop() { 335 MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 327 336 MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 328 337 MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 329 338 if (MoveEvaluator != null) 330 339 MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName; 340 MainLoop.VisualizerParameter.ActualName = Problem.VisualizerParameter.Name; 341 if (Problem.Visualizer != null) 342 MainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName; 331 343 } 332 344 private void ParameterizeStochasticOperator(IOperator op) { -
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs
r3141 r3145 128 128 129 129 [StorableConstructor] 130 p ublicTabuSearch(bool deserializing) : base() { }130 private TabuSearch(bool deserializing) : base() { } 131 131 public TabuSearch() 132 132 : base() { -
trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearchMainLoop.cs
r3143 r3145 86 86 #endregion 87 87 88 [StorableConstructor] 89 private TabuSearchMainLoop(bool deserializing) : base() { } 88 90 public TabuSearchMainLoop() 89 91 : base() { 92 Initialize(); 93 } 94 95 private void Initialize() { 90 96 #region Create parameters 91 97 Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator.")); … … 97 103 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.")); 98 104 Parameters.Add(new ValueLookupParameter<IntValue>("TabuTenure", "The length of the tabu list, and also means the number of iterations a move is kept tabu")); 99 105 100 106 Parameters.Add(new ValueLookupParameter<IOperator>("MoveGenerator", "The operator that generates the moves.")); 101 107 Parameters.Add(new ValueLookupParameter<IOperator>("MoveMaker", "The operator that performs a move and updates the quality.")); … … 192 198 bestAverageWorstMoveQualityCalculator.QualityParameter.ActualName = MoveQualityParameter.Name; 193 199 bestAverageWorstMoveQualityCalculator.WorstQualityParameter.ActualName = "Worst Move Quality"; 194 200 195 201 valuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Move Quality")); 196 202 valuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Average Move Quality"));
Note: See TracChangeset
for help on using the changeset viewer.