- Timestamp:
- 04/13/12 18:42:59 (13 years ago)
- Location:
- branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/HeuristicLab.Algorithms.ScatterSearch-3.3.csproj
r7722 r7727 92 92 <Compile Include="PopulationRebuildMethod.cs" /> 93 93 <Compile Include="ScatterSearch.cs" /> 94 <Compile Include="ScatterSearchImprovementOperator.cs" /> 94 95 <Compile Include="ScatterSearchMainLoop.cs" /> 95 96 <Compile Include="SolutionCombinationMethod.cs" /> -
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 } -
branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/ScatterSearchMainLoop.cs
r7724 r7727 20 20 #endregion 21 21 22 using HeuristicLab.Algorithms.LocalSearch;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 74 73 get { return (LookupParameter<VariableCollection>)Parameters["Results"]; } 75 74 } 76 internal LookupParameter<IOperator> MoveEvaluatorParameter { 77 get { return (LookupParameter<IOperator>)Parameters["MoveEvaluator"]; } 78 } 79 internal LookupParameter<IOperator> MoveGeneratorParameter { 80 get { return (LookupParameter<IOperator>)Parameters["MoveGenerator"]; } 81 } 82 internal LookupParameter<IOperator> MoveMakerParameter { 83 get { return (LookupParameter<IOperator>)Parameters["MoveMaker"]; } 75 internal LookupParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter { 76 get { return (LookupParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; } 77 } 78 internal LookupParameter<IMoveGenerator> MoveGeneratorParameter { 79 get { return (LookupParameter<IMoveGenerator>)Parameters["MoveGenerator"]; } 80 } 81 internal LookupParameter<IMoveMaker> MoveMakerParameter { 82 get { return (LookupParameter<IMoveMaker>)Parameters["MoveMaker"]; } 83 } 84 internal LookupParameter<IOperator> ImproverParameter { 85 get { return (LookupParameter<IOperator>)Parameters["Improver"]; } 86 } 87 internal LookupParameter<IOperator> EvaluatorParameter { 88 get { return (LookupParameter<IOperator>)Parameters["Evaluator"]; } 84 89 } 85 90 internal LookupParameter<IMultiAnalyzer> AnalyzerParameter { … … 137 142 set { ResultsParameter.ActualValue = value; } 138 143 } 139 public I Operator MoveEvaluator {144 public ISingleObjectiveMoveEvaluator MoveEvaluator { 140 145 get { return MoveEvaluatorParameter.ActualValue; } 141 146 set { MoveEvaluatorParameter.ActualValue = value; } 142 147 } 143 public I Operator MoveGenerator {148 public IMoveGenerator MoveGenerator { 144 149 get { return MoveGeneratorParameter.ActualValue; } 145 150 set { MoveGeneratorParameter.ActualValue = value; } 146 151 } 147 public I Operator MoveMaker {152 public IMoveMaker MoveMaker { 148 153 get { return MoveMakerParameter.ActualValue; } 149 154 set { MoveMakerParameter.ActualValue = value; } 155 } 156 public IOperator Improver { 157 get { return ImproverParameter.ActualValue; } 158 set { ImproverParameter.ActualValue = value; } 159 } 160 public IOperator Evaluator { 161 get { return EvaluatorParameter.ActualValue; } 162 set { EvaluatorParameter.ActualValue = value; } 150 163 } 151 164 public IMultiAnalyzer Analyzer { … … 178 191 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move.")); 179 192 Parameters.Add(new LookupParameter<IOperator>("SolutionCreator", "The operator which is used to create new solutions.")); 180 Parameters.Add(new LookupParameter<IOperator>("Evaluator", "The operator which is used to evaluate new solutions. This operator is executed in parallel, if an engine is used which supports parallelization.")); 181 Parameters.Add(new LookupParameter<IOperator>("Improver", "The operator which is used to improve new solutions. This operator is executed in parallelm, if an engine is used which supports parallelization.")); 193 Parameters.Add(new LookupParameter<IOperator>("Evaluator", "The operator which is used to evaluate new solutions.")); 182 194 Parameters.Add(new LookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); 183 Parameters.Add(new LookupParameter<IOperator>("MoveGenerator", "The operator that generates the moves.")); 184 Parameters.Add(new LookupParameter<IOperator>("MoveMaker", "The operator that performs a move and updates the quality.")); 185 Parameters.Add(new LookupParameter<IOperator>("MoveEvaluator", "The operator that evaluates a move.")); 195 Parameters.Add(new LookupParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move.")); 196 Parameters.Add(new LookupParameter<IMoveGenerator>("MoveGenerator", "The operator that generates the moves.")); 197 Parameters.Add(new LookupParameter<IMoveMaker>("MoveMaker", "The operator that performs a move and updates the quality.")); 198 Parameters.Add(new LookupParameter<IOperator>("Improver", "The operator used to improve solutions.")); 186 199 Parameters.Add(new LookupParameter<IMultiAnalyzer>("Analyzer", "The operator used to analyze the solution and moves.")); 187 200 #endregion … … 195 208 ConditionalBranch terminateBranch = new ConditionalBranch(); 196 209 IntCounter interationsCounter = new IntCounter(); 197 LocalSearchImprovementOperator localImprovementOperator = new LocalSearchImprovementOperator();198 210 Placeholder analyzer = new Placeholder(); 199 Placeholder solutionImprover = new Placeholder(); 200 Placeholder solutionEvaluator = new Placeholder(); 211 Placeholder solutionEvaluator1 = new Placeholder(); 212 Placeholder solutionEvaluator2 = new Placeholder(); 213 Placeholder solutionImprover1 = new Placeholder(); 214 Placeholder solutionImprover2 = new Placeholder(); 201 215 PopulationRebuildMethod populationRebuildMethod = new PopulationRebuildMethod(); 202 216 ResultsCollector resultsCollector = new ResultsCollector(); … … 236 250 iterationsChecker.Successor = terminateBranch; 237 251 238 localImprovementOperator.Name = "ImprovementMethod"; 239 localImprovementOperator.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name; 240 localImprovementOperator.SampleSizeParameter.ActualName = SampleSizeParameter.Name; 241 localImprovementOperator.Successor = null; 252 solutionImprover2.Name = "SolutionImprover"; 253 solutionImprover2.OperatorParameter.ActualName = "Improver"; 254 solutionImprover2.Successor = solutionEvaluator2; 255 256 solutionEvaluator2.Name = "SolutionEvaluator"; 257 solutionEvaluator2.OperatorParameter.ActualName = "Evaluator"; 258 solutionEvaluator2.Successor = null; 242 259 243 260 newSolutionsBranch.Name = "NewSolutionChecker"; … … 261 278 analyzer.OperatorParameter.ActualName = "Analyzer"; 262 279 263 solutionImprover .Name = "SolutionImprover";264 solutionImprover .OperatorParameter.ActualName = "LocalImprovementOperator";265 solutionImprover .Successor = solutionEvaluator;266 267 solutionEvaluator .Name = "SolutionEvaluator";268 solutionEvaluator .OperatorParameter.ActualName = "Evaluator";269 solutionEvaluator .Successor = null;280 solutionImprover1.Name = "SolutionImprover"; 281 solutionImprover1.OperatorParameter.ActualName = "Improver"; 282 solutionImprover1.Successor = solutionEvaluator1; 283 284 solutionEvaluator1.Name = "SolutionEvaluator"; 285 solutionEvaluator1.OperatorParameter.ActualName = "Evaluator"; 286 solutionEvaluator1.Successor = null; 270 287 271 288 populationRebuildMethod.Successor = subScopesProcessor3; … … 308 325 309 326 uniformSubScopesProcessor2.DepthParameter.Value = new IntValue(1); 310 uniformSubScopesProcessor2.Operator = solutionImprover ;327 uniformSubScopesProcessor2.Operator = solutionImprover1; 311 328 uniformSubScopesProcessor2.Successor = null; 312 329 313 330 uniformSubScopesProcessor3.DepthParameter.Value = new IntValue(1); 314 uniformSubScopesProcessor3.Operator = localImprovementOperator;331 uniformSubScopesProcessor3.Operator = solutionImprover2; 315 332 uniformSubScopesProcessor3.Successor = null; 316 333 #endregion
Note: See TracChangeset
for help on using the changeset viewer.