Changeset 7727 for branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearch.cs
- Timestamp:
- 04/13/12 18:42:59 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearch.cs
r7724 r7727 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HeuristicLab.Algorithms.LocalSearch;26 25 using HeuristicLab.Analysis; 27 26 using HeuristicLab.Common; … … 60 59 get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } 61 60 } 61 private ValueParameter<ILocalImprovementOperator> ImproverParameter { 62 get { return (ValueParameter<ILocalImprovementOperator>)Parameters["Improver"]; } 63 } 62 64 private ValueParameter<IntValue> MaximumIterationsParameter { 63 65 get { return (ValueParameter<IntValue>)Parameters["MaximumIterations"]; } 64 66 } 65 p ublicConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {67 private ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter { 66 68 get { return (ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; } 67 69 } 68 p ublicConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {70 private ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter { 69 71 get { return (ConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; } 70 72 } 71 p ublicConstrainedValueParameter<IMoveMaker> MoveMakerParameter {73 private ConstrainedValueParameter<IMoveMaker> MoveMakerParameter { 72 74 get { return (ConstrainedValueParameter<IMoveMaker>)Parameters["MoveMaker"]; } 73 75 } … … 106 108 set { AnalyzerParameter.Value = value; } 107 109 } 110 public ILocalImprovementOperator Improver { 111 get { return ImproverParameter.Value; } 112 set { ImproverParameter.Value = value; } 113 } 108 114 public IntValue MaximumIterations { 109 115 get { return MaximumIterationsParameter.Value; } … … 148 154 149 155 [Storable] 150 private BestAverageWorstQualityAnalyzer moveQualityAnalyzer;156 private BestAverageWorstQualityAnalyzer qualityAnalyzer; 151 157 #endregion 152 158 … … 159 165 private ScatterSearch(ScatterSearch original, Cloner cloner) 160 166 : base(original, cloner) { 161 moveQualityAnalyzer = cloner.Clone(original.moveQualityAnalyzer);167 qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); 162 168 Initialize(); 163 169 } … … 169 175 #region Create parameters 170 176 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution and moves.", new MultiAnalyzer())); 171 Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(5))); 177 Parameters.Add(new ValueParameter<ILocalImprovementOperator>("Improver", "The operator used to improve solutions.", new ScatterSearchImprovementOperator())); 178 Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(1000))); 172 179 Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move.")); 173 180 Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution.")); 174 181 Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move.")); 175 Parameters.Add(new ValueParameter<IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions that should be added to the reference set.", new IntValue( 6)));182 Parameters.Add(new ValueParameter<IntValue>("NumberOfHighQualitySolutions", "The number of high quality solutions that should be added to the reference set.", new IntValue(5))); 176 183 Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population.", new IntValue(30))); 177 184 Parameters.Add(new ValueParameter<IntValue>("ReferenceSetSize", "The size of the reference set.", new IntValue(10))); … … 185 192 SolutionsCreator solutionsCreator = new SolutionsCreator(); 186 193 UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor(); 187 LocalSearchImprovementOperator localImprovementOperator = new LocalSearchImprovementOperator(); 194 Placeholder solutionEvaluator = new Placeholder(); 195 Placeholder solutionImprover = new Placeholder(); 188 196 BestSelector bestSelector = new BestSelector(); 189 197 VariableCreator variableCreator = new VariableCreator(); … … 203 211 solutionsCreator.Successor = uniformSubScopesProcessor; 204 212 205 uniformSubScopesProcessor.Operator = localImprovementOperator;213 uniformSubScopesProcessor.Operator = solutionImprover; 206 214 uniformSubScopesProcessor.Successor = bestSelector; 207 215 208 localImprovementOperator.Name = "ImprovementMethod"; 209 localImprovementOperator.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name; 210 localImprovementOperator.SampleSizeParameter.ActualName = SampleSizeParameter.Name; 211 localImprovementOperator.Successor = null; 216 solutionImprover.Name = "SolutionImprover"; 217 solutionImprover.OperatorParameter.ActualName = "Improver"; 218 solutionImprover.Successor = solutionEvaluator; 219 220 solutionEvaluator.Name = "SolutionEvaluator"; 221 solutionEvaluator.OperatorParameter.ActualName = "Evaluator"; 222 solutionEvaluator.Successor = null; 212 223 213 224 bestSelector.NumberOfSelectedSubScopesParameter.ActualName = NumberOfHighQualitySolutionsParameter.Name; … … 233 244 #endregion 234 245 235 moveQualityAnalyzer = new BestAverageWorstQualityAnalyzer();246 qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 236 247 ParameterizeAnalyzers(); 237 248 UpdateAnalyzers(); … … 318 329 ParameterizeMoveEvaluators(); 319 330 ParameterizeMoveMakers(); 320 ParameterizeAnalyzers();321 331 } 322 332 #endregion … … 397 407 } 398 408 } 399 Analyzer.Operators.Add( moveQualityAnalyzer, moveQualityAnalyzer.EnabledByDefault);409 Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault); 400 410 } 401 411 private void ClearMoveParameters() { … … 450 460 } 451 461 private void ParameterizeAnalyzers() { 452 moveQualityAnalyzer.ResultsParameter.ActualName = "Results";453 moveQualityAnalyzer.ResultsParameter.Hidden = true;454 if (Problem != null) { 455 moveQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;456 moveQualityAnalyzer.MaximizationParameter.Hidden = true;462 qualityAnalyzer.ResultsParameter.ActualName = "Results"; 463 qualityAnalyzer.ResultsParameter.Hidden = true; 464 if (Problem != null) { 465 qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 466 qualityAnalyzer.MaximizationParameter.Hidden = true; 457 467 if (MoveEvaluator != null) { 458 moveQualityAnalyzer.QualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName; 459 moveQualityAnalyzer.QualityParameter.Hidden = true; 460 } else moveQualityAnalyzer.QualityParameter.Hidden = false; 461 moveQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 462 moveQualityAnalyzer.BestKnownQualityParameter.Hidden = true; 468 qualityAnalyzer.QualityParameter.Hidden = true; 469 } else qualityAnalyzer.QualityParameter.Hidden = false; 470 qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 471 qualityAnalyzer.BestKnownQualityParameter.Hidden = true; 463 472 } else { 464 moveQualityAnalyzer.MaximizationParameter.Hidden = false;465 moveQualityAnalyzer.BestKnownQualityParameter.Hidden = false;473 qualityAnalyzer.MaximizationParameter.Hidden = false; 474 qualityAnalyzer.BestKnownQualityParameter.Hidden = false; 466 475 } 467 476 }
Note: See TracChangeset
for help on using the changeset viewer.